@patternfly/react-charts
Version:
This library provides a set of React chart components for use with the PatternFly reference implementation.
37 lines • 2.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ChartGroup = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const hoist_non_react_statics_1 = tslib_1.__importDefault(require("hoist-non-react-statics"));
const victory_group_1 = require("victory-group");
const ChartContainer_1 = require("../ChartContainer/ChartContainer");
const chart_helpers_1 = require("../ChartUtils/chart-helpers");
const chart_patterns_1 = require("../ChartUtils/chart-patterns");
const chart_theme_1 = require("../ChartUtils/chart-theme");
const ChartGroup = (_a) => {
var { ariaDesc, ariaTitle, children, colorScale, containerComponent = (0, jsx_runtime_1.jsx)(ChartContainer_1.ChartContainer, {}), hasPatterns, patternScale, themeColor,
// destructure last
theme = (0, chart_theme_1.getTheme)(themeColor) } = _a, rest = tslib_1.__rest(_a, ["ariaDesc", "ariaTitle", "children", "colorScale", "containerComponent", "hasPatterns", "patternScale", "themeColor", "theme"]);
// Clone so users can override container props
const container = (0, react_1.cloneElement)(containerComponent, Object.assign(Object.assign({ desc: ariaDesc, title: ariaTitle, theme }, containerComponent.props), { className: (0, chart_helpers_1.getClassName)({ className: containerComponent.props.className }) // Override VictoryContainer class name
}));
const { defaultColorScale, defaultPatternScale, isPatternDefs, patternId } = (0, chart_patterns_1.useDefaultPatternProps)({
colorScale,
hasPatterns,
patternScale,
themeColorScale: theme.group.colorScale
});
// Note: containerComponent is required for theme
return ((0, jsx_runtime_1.jsxs)(victory_group_1.VictoryGroup, Object.assign({ colorScale: colorScale, containerComponent: container, theme: theme }, rest, { children: [(0, chart_patterns_1.renderChildrenWithPatterns)({
children,
patternScale: defaultPatternScale,
themeColor
}), isPatternDefs && (0, chart_patterns_1.getPatternDefs)({ patternId, colorScale: defaultColorScale })] })));
};
exports.ChartGroup = ChartGroup;
exports.ChartGroup.displayName = 'ChartGroup';
// Note: VictoryGroup.role must be hoisted
(0, hoist_non_react_statics_1.default)(exports.ChartGroup, victory_group_1.VictoryGroup);
//# sourceMappingURL=ChartGroup.js.map