UNPKG

@patternfly/react-charts

Version:

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

46 lines 2.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChartBulletPrimaryDotMeasure = 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_scatter_1 = require("victory-scatter"); const chart_bullet_data_1 = require("./utils/chart-bullet-data"); const ChartContainer_1 = require("../ChartContainer/ChartContainer"); const ChartScatter_1 = require("../ChartScatter/ChartScatter"); const ChartStyles_1 = require("../ChartTheme/ChartStyles"); const ChartTooltip_1 = require("../ChartTooltip/ChartTooltip"); const chart_theme_types_1 = require("../ChartUtils/chart-theme-types"); const ChartBulletPrimaryDotMeasure = ({ allowTooltip = true, ariaDesc, ariaTitle, constrainToVisibleArea = false, data, domain, horizontal = true, invert = false, labels, measureComponent = (0, jsx_runtime_1.jsx)(ChartScatter_1.ChartScatter, {}), padding, size = ChartStyles_1.ChartBulletStyles.primaryDotMeasureSize, standalone = true, themeColor, y, y0, // destructure last theme = (0, chart_theme_types_1.getBulletPrimaryDotMeasureTheme)(themeColor), labelComponent = (0, jsx_runtime_1.jsx)(ChartTooltip_1.ChartTooltip, {}), height = theme.group.height, width = theme.group.width }) => { const computedData = (0, chart_bullet_data_1.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 = (0, react_1.cloneElement)(labelComponent, Object.assign({ constrainToVisibleArea, dx: 0, dy: horizontal ? -size : 0, orientation: 'top' }, labelComponent.props)); const measure = computedData.map((dataPoint, index) => (0, react_1.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 ? ((0, jsx_runtime_1.jsx)(ChartContainer_1.ChartContainer, { desc: ariaDesc, height: height, title: ariaTitle, width: width, children: measure })) : ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: measure })); }; exports.ChartBulletPrimaryDotMeasure = ChartBulletPrimaryDotMeasure; exports.ChartBulletPrimaryDotMeasure.displayName = 'ChartBulletPrimaryDotMeasure'; // Note: VictoryBar.role must be hoisted (0, hoist_non_react_statics_1.default)(exports.ChartBulletPrimaryDotMeasure, victory_scatter_1.VictoryScatter); //# sourceMappingURL=ChartBulletPrimaryDotMeasure.js.map