UNPKG

@patternfly/react-charts

Version:

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

48 lines 2.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createContainer = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const chart_container_cursor_line_Fill_1 = tslib_1.__importDefault(require('@patternfly/react-tokens/dist/js/chart_container_cursor_line_Fill')); const victory_create_container_1 = require("victory-create-container"); const ChartCursorTooltip_1 = require("../ChartCursorTooltip/ChartCursorTooltip"); const ChartLabel_1 = require("../ChartLabel/ChartLabel"); const victory_core_1 = require("victory-core"); /** * Makes a container component with multiple behaviors. It allows you to effectively combine any two * containers of type 'brush', 'cursor', 'selection', 'voronoi', or 'zoom'. Default container props are applied to * support the PatternFly theme. * * Each behavior must be one of the following strings: 'brush', 'cursor', 'selection', 'voronoi', and 'zoom'. The * resulting container uses the events from both behaviors. For example, if both behaviors use the click event (like * zoom and selection) the combined container will trigger both behaviors' events on each click. * * Note: Order of the behaviors matters in a few cases. It is recommended to use 'zoom' before any other behaviors: for * example, createContainer('zoom', 'voronoi') instead of createContainer('voronoi', 'zoom'). * * See https://formidable.com/open-source/victory/docs/create-container * * @param {string} behaviorA 'brush', 'cursor', 'selection', 'voronoi', or 'zoom' * @param {string} behaviorB 'brush', 'cursor', 'selection', 'voronoi', or 'zoom' * @public */ const createContainer = (behaviorA, behaviorB) => { const Container = (0, victory_create_container_1.createContainer)(behaviorA, behaviorB); const isCursor = behaviorA === 'cursor' || behaviorB === 'cursor'; const isVoronoi = behaviorA === 'voronoi' || behaviorB === 'voronoi'; const containerWrapper = (props) => { const containerProps = Object.assign(Object.assign(Object.assign({}, (isCursor && { cursorLabelComponent: (0, jsx_runtime_1.jsx)(ChartLabel_1.ChartLabel, { textAnchor: "start" }), cursorComponent: ((0, jsx_runtime_1.jsx)(victory_core_1.LineSegment, { style: { stroke: chart_container_cursor_line_Fill_1.default.var } })) })), (isVoronoi && { labelComponent: (0, jsx_runtime_1.jsx)(ChartCursorTooltip_1.ChartCursorTooltip, {}) })), props); return (0, jsx_runtime_1.jsx)(Container, Object.assign({}, containerProps)); }; containerWrapper.defaultEvents = Container.defaultEvents; containerWrapper.displayName = Container.displayName; containerWrapper.role = Container.role; return containerWrapper; }; exports.createContainer = createContainer; //# sourceMappingURL=chart-container.js.map