UNPKG

@patternfly/react-charts

Version:

This library provides a set of React chart components for use with the PatternFly reference implementation.

33 lines 2.08 kB
import { __rest } from "tslib"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { cloneElement } from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; import { VictoryGroup } from 'victory-group'; import { ChartContainer } from '../ChartContainer/ChartContainer'; import { getClassName } from '../ChartUtils/chart-helpers'; import { useDefaultPatternProps, getPatternDefs, renderChildrenWithPatterns } from '../ChartUtils/chart-patterns'; import { getTheme } from '../ChartUtils/chart-theme'; export const ChartGroup = (_a) => { var { ariaDesc, ariaTitle, children, colorScale, containerComponent = _jsx(ChartContainer, {}), hasPatterns, patternScale, themeColor, // destructure last theme = getTheme(themeColor) } = _a, rest = __rest(_a, ["ariaDesc", "ariaTitle", "children", "colorScale", "containerComponent", "hasPatterns", "patternScale", "themeColor", "theme"]); // Clone so users can override container props const container = cloneElement(containerComponent, Object.assign(Object.assign({ desc: ariaDesc, title: ariaTitle, theme }, containerComponent.props), { className: getClassName({ className: containerComponent.props.className }) // Override VictoryContainer class name })); const { defaultColorScale, defaultPatternScale, isPatternDefs, patternId } = useDefaultPatternProps({ colorScale, hasPatterns, patternScale, themeColorScale: theme.group.colorScale }); // Note: containerComponent is required for theme return (_jsxs(VictoryGroup, Object.assign({ colorScale: colorScale, containerComponent: container, theme: theme }, rest, { children: [renderChildrenWithPatterns({ children, patternScale: defaultPatternScale, themeColor }), isPatternDefs && getPatternDefs({ patternId, colorScale: defaultColorScale })] }))); }; ChartGroup.displayName = 'ChartGroup'; // Note: VictoryGroup.role must be hoisted hoistNonReactStatics(ChartGroup, VictoryGroup); //# sourceMappingURL=ChartGroup.js.map