@patternfly/react-charts
Version:
This library provides a set of React chart components for use with the PatternFly reference implementation.
42 lines • 1.8 kB
JavaScript
import { __rest } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import hoistNonReactStatics from 'hoist-non-react-statics';
import cloneDeep from 'lodash/cloneDeep';
import { VictoryLine } from 'victory-line';
import { ChartLine } from '../ChartLine/ChartLine';
import { getThresholdTheme } from '../ChartUtils/chart-theme-types';
export const ChartThreshold = (_a) => {
var { style = {}, themeColor,
// destructure last
theme = getThresholdTheme(themeColor) } = _a, rest = __rest(_a, ["style", "themeColor", "theme"]);
// Returned style prop takes precedence over default theme
const getStrokeDasharray = () => {
if (style && style.data && style.data.strokeDasharray) {
return style.data.strokeDasharray;
}
return getThresholdTheme(themeColor).line.style.data.strokeDasharray;
};
const getStrokeWidth = () => {
if (style && style.data && style.data.strokeWidth) {
return style.data.strokeWidth;
}
return getThresholdTheme(themeColor).line.style.data.strokeWidth;
};
// Clone style and apply strokeDasharray prop
const thresholdStyle = cloneDeep(style);
if (thresholdStyle.data) {
thresholdStyle.data.strokeDasharray = getStrokeDasharray();
thresholdStyle.data.strokeWidth = getStrokeWidth();
}
else {
thresholdStyle.data = {
strokeDasharray: getStrokeDasharray(),
strokeWidth: getStrokeWidth()
};
}
return _jsx(ChartLine, Object.assign({ style: thresholdStyle, theme: theme, themeColor: themeColor }, rest));
};
ChartThreshold.displayName = 'ChartThreshold';
// Note: VictoryLine.role must be hoisted
hoistNonReactStatics(ChartThreshold, VictoryLine);
//# sourceMappingURL=ChartThreshold.js.map