| 1 | function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|---|
| 2 | import * as React from 'react';
|
|---|
| 3 | import { forwardRef } from 'react';
|
|---|
| 4 | import { RechartsStoreProvider } from '../state/RechartsStoreProvider';
|
|---|
| 5 | import { ChartDataContextProvider } from '../context/chartDataContext';
|
|---|
| 6 | import { ReportMainChartProps } from '../state/ReportMainChartProps';
|
|---|
| 7 | import { ReportChartProps } from '../state/ReportChartProps';
|
|---|
| 8 | import { CategoricalChart } from './CategoricalChart';
|
|---|
| 9 | import { resolveDefaultProps } from '../util/resolveDefaultProps';
|
|---|
| 10 | var defaultMargin = {
|
|---|
| 11 | top: 5,
|
|---|
| 12 | right: 5,
|
|---|
| 13 | bottom: 5,
|
|---|
| 14 | left: 5
|
|---|
| 15 | };
|
|---|
| 16 | export var defaultCartesianChartProps = {
|
|---|
| 17 | accessibilityLayer: true,
|
|---|
| 18 | barCategoryGap: '10%',
|
|---|
| 19 | barGap: 4,
|
|---|
| 20 | layout: 'horizontal',
|
|---|
| 21 | margin: defaultMargin,
|
|---|
| 22 | responsive: false,
|
|---|
| 23 | reverseStackOrder: false,
|
|---|
| 24 | stackOffset: 'none',
|
|---|
| 25 | syncMethod: 'index'
|
|---|
| 26 | };
|
|---|
| 27 |
|
|---|
| 28 | /**
|
|---|
| 29 | * These are one-time, immutable options that decide the chart's behavior.
|
|---|
| 30 | * Users who wish to call CartesianChart may decide to pass these options explicitly,
|
|---|
| 31 | * but usually we would expect that they use one of the convenience components like BarChart, LineChart, etc.
|
|---|
| 32 | */
|
|---|
| 33 |
|
|---|
| 34 | export var CartesianChart = /*#__PURE__*/forwardRef(function CartesianChart(props, ref) {
|
|---|
| 35 | var _categoricalChartProp;
|
|---|
| 36 | var rootChartProps = resolveDefaultProps(props.categoricalChartProps, defaultCartesianChartProps);
|
|---|
| 37 | var {
|
|---|
| 38 | chartName,
|
|---|
| 39 | defaultTooltipEventType,
|
|---|
| 40 | validateTooltipEventTypes,
|
|---|
| 41 | tooltipPayloadSearcher,
|
|---|
| 42 | categoricalChartProps
|
|---|
| 43 | } = props;
|
|---|
| 44 | var options = {
|
|---|
| 45 | chartName,
|
|---|
| 46 | defaultTooltipEventType,
|
|---|
| 47 | validateTooltipEventTypes,
|
|---|
| 48 | tooltipPayloadSearcher,
|
|---|
| 49 | eventEmitter: undefined
|
|---|
| 50 | };
|
|---|
| 51 | return /*#__PURE__*/React.createElement(RechartsStoreProvider, {
|
|---|
| 52 | preloadedState: {
|
|---|
| 53 | options
|
|---|
| 54 | },
|
|---|
| 55 | reduxStoreName: (_categoricalChartProp = categoricalChartProps.id) !== null && _categoricalChartProp !== void 0 ? _categoricalChartProp : chartName
|
|---|
| 56 | }, /*#__PURE__*/React.createElement(ChartDataContextProvider, {
|
|---|
| 57 | chartData: categoricalChartProps.data
|
|---|
| 58 | }), /*#__PURE__*/React.createElement(ReportMainChartProps, {
|
|---|
| 59 | layout: rootChartProps.layout,
|
|---|
| 60 | margin: rootChartProps.margin
|
|---|
| 61 | }), /*#__PURE__*/React.createElement(ReportChartProps, {
|
|---|
| 62 | baseValue: rootChartProps.baseValue,
|
|---|
| 63 | accessibilityLayer: rootChartProps.accessibilityLayer,
|
|---|
| 64 | barCategoryGap: rootChartProps.barCategoryGap,
|
|---|
| 65 | maxBarSize: rootChartProps.maxBarSize,
|
|---|
| 66 | stackOffset: rootChartProps.stackOffset,
|
|---|
| 67 | barGap: rootChartProps.barGap,
|
|---|
| 68 | barSize: rootChartProps.barSize,
|
|---|
| 69 | syncId: rootChartProps.syncId,
|
|---|
| 70 | syncMethod: rootChartProps.syncMethod,
|
|---|
| 71 | className: rootChartProps.className,
|
|---|
| 72 | reverseStackOrder: rootChartProps.reverseStackOrder
|
|---|
| 73 | }), /*#__PURE__*/React.createElement(CategoricalChart, _extends({}, rootChartProps, {
|
|---|
| 74 | ref: ref
|
|---|
| 75 | })));
|
|---|
| 76 | }); |
|---|