UNPKG

@patternfly/react-charts

Version:

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

32 lines 1.91 kB
import { __rest } from "tslib"; import { jsx as _jsx } from "react/jsx-runtime"; import { cloneElement } from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; import { VictoryStack } from 'victory-stack'; import { ChartContainer } from '../ChartContainer/ChartContainer'; import { getClassName } from '../ChartUtils/chart-helpers'; import { useDefaultPatternProps, renderChildrenWithPatterns } from '../ChartUtils/chart-patterns'; import { getTheme } from '../ChartUtils/chart-theme'; export const ChartStack = (_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 { defaultPatternScale } = useDefaultPatternProps({ colorScale, hasPatterns, patternScale, themeColorScale: theme.stack.colorScale }); // Note: containerComponent is required for theme return (_jsx(VictoryStack, Object.assign({ colorScale: colorScale, containerComponent: container, theme: theme }, rest, { children: renderChildrenWithPatterns({ children, patternScale: defaultPatternScale }) }))); }; ChartStack.displayName = 'ChartStack'; // Note: VictoryStack.getChildren & VictoryStack.role must be hoisted hoistNonReactStatics(ChartStack, VictoryStack); //# sourceMappingURL=ChartStack.js.map