@patternfly/react-charts
Version:
This library provides a set of React chart components for use with the PatternFly reference implementation.
46 lines • 2.2 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChartThreshold = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const hoist_non_react_statics_1 = tslib_1.__importDefault(require("hoist-non-react-statics"));
const cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
const victory_line_1 = require("victory-line");
const ChartLine_1 = require("../ChartLine/ChartLine");
const chart_theme_types_1 = require("../ChartUtils/chart-theme-types");
const ChartThreshold = (_a) => {
var { style = {}, themeColor,
// destructure last
theme = (0, chart_theme_types_1.getThresholdTheme)(themeColor) } = _a, rest = tslib_1.__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 (0, chart_theme_types_1.getThresholdTheme)(themeColor).line.style.data.strokeDasharray;
};
const getStrokeWidth = () => {
if (style && style.data && style.data.strokeWidth) {
return style.data.strokeWidth;
}
return (0, chart_theme_types_1.getThresholdTheme)(themeColor).line.style.data.strokeWidth;
};
// Clone style and apply strokeDasharray prop
const thresholdStyle = (0, cloneDeep_1.default)(style);
if (thresholdStyle.data) {
thresholdStyle.data.strokeDasharray = getStrokeDasharray();
thresholdStyle.data.strokeWidth = getStrokeWidth();
}
else {
thresholdStyle.data = {
strokeDasharray: getStrokeDasharray(),
strokeWidth: getStrokeWidth()
};
}
return (0, jsx_runtime_1.jsx)(ChartLine_1.ChartLine, Object.assign({ style: thresholdStyle, theme: theme, themeColor: themeColor }, rest));
};
exports.ChartThreshold = ChartThreshold;
exports.ChartThreshold.displayName = 'ChartThreshold';
// Note: VictoryLine.role must be hoisted
(0, hoist_non_react_statics_1.default)(exports.ChartThreshold, victory_line_1.VictoryLine);
//# sourceMappingURL=ChartThreshold.js.map