@patternfly/react-charts
Version:
This library provides a set of React chart components for use with the PatternFly reference implementation.
41 lines • 2.48 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { cloneElement, Fragment } from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { VictoryScatter } from 'victory-scatter';
import { getPrimaryDotMeasureData } from './utils/chart-bullet-data';
import { ChartContainer } from '../ChartContainer/ChartContainer';
import { ChartScatter } from '../ChartScatter/ChartScatter';
import { ChartBulletStyles } from '../ChartTheme/ChartStyles';
import { ChartTooltip } from '../ChartTooltip/ChartTooltip';
import { getBulletPrimaryDotMeasureTheme } from '../ChartUtils/chart-theme-types';
export const ChartBulletPrimaryDotMeasure = ({ allowTooltip = true, ariaDesc, ariaTitle, constrainToVisibleArea = false, data, domain, horizontal = true, invert = false, labels, measureComponent = _jsx(ChartScatter, {}), padding, size = ChartBulletStyles.primaryDotMeasureSize, standalone = true, themeColor, y, y0,
// destructure last
theme = getBulletPrimaryDotMeasureTheme(themeColor), labelComponent = _jsx(ChartTooltip, {}), height = theme.group.height, width = theme.group.width }) => {
const computedData = getPrimaryDotMeasureData({
data,
invert,
theme,
y,
y0
});
// Label component
//
// Note: SVG height and width are provided by ChartBullet as a workaround to support constrainToVisibleArea
const tooltip = cloneElement(labelComponent, Object.assign({ constrainToVisibleArea, dx: 0, dy: horizontal ? -size : 0, orientation: 'top' }, labelComponent.props));
const measure = computedData.map((dataPoint, index) => cloneElement(measureComponent, Object.assign({ data: [Object.assign({}, dataPoint)], domain,
height,
horizontal, key: `pf-chart-bullet-primary-dot-measure-${index}`, labelComponent: allowTooltip ? tooltip : undefined, labels,
padding,
size, standalone: false, style: {
data: {
fill: dataPoint._color
}
}, theme,
themeColor,
width }, measureComponent.props)));
return standalone ? (_jsx(ChartContainer, { desc: ariaDesc, height: height, title: ariaTitle, width: width, children: measure })) : (_jsx(Fragment, { children: measure }));
};
ChartBulletPrimaryDotMeasure.displayName = 'ChartBulletPrimaryDotMeasure';
// Note: VictoryBar.role must be hoisted
hoistNonReactStatics(ChartBulletPrimaryDotMeasure, VictoryScatter);
//# sourceMappingURL=ChartBulletPrimaryDotMeasure.js.map