UNPKG

recharts

Version:
76 lines (74 loc) 3.03 kB
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); } import * as React from 'react'; import { forwardRef } from 'react'; import { RechartsStoreProvider } from '../state/RechartsStoreProvider'; import { ChartDataContextProvider } from '../context/chartDataContext'; import { ReportMainChartProps } from '../state/ReportMainChartProps'; import { ReportChartProps } from '../state/ReportChartProps'; import { CategoricalChart } from './CategoricalChart'; import { resolveDefaultProps } from '../util/resolveDefaultProps'; var defaultMargin = { top: 5, right: 5, bottom: 5, left: 5 }; export var defaultCartesianChartProps = { accessibilityLayer: true, barCategoryGap: '10%', barGap: 4, layout: 'horizontal', margin: defaultMargin, responsive: false, reverseStackOrder: false, stackOffset: 'none', syncMethod: 'index' }; /** * These are one-time, immutable options that decide the chart's behavior. * Users who wish to call CartesianChart may decide to pass these options explicitly, * but usually we would expect that they use one of the convenience components like BarChart, LineChart, etc. */ export var CartesianChart = /*#__PURE__*/forwardRef(function CartesianChart(props, ref) { var _categoricalChartProp; var rootChartProps = resolveDefaultProps(props.categoricalChartProps, defaultCartesianChartProps); var { chartName, defaultTooltipEventType, validateTooltipEventTypes, tooltipPayloadSearcher, categoricalChartProps } = props; var options = { chartName, defaultTooltipEventType, validateTooltipEventTypes, tooltipPayloadSearcher, eventEmitter: undefined }; return /*#__PURE__*/React.createElement(RechartsStoreProvider, { preloadedState: { options }, reduxStoreName: (_categoricalChartProp = categoricalChartProps.id) !== null && _categoricalChartProp !== void 0 ? _categoricalChartProp : chartName }, /*#__PURE__*/React.createElement(ChartDataContextProvider, { chartData: categoricalChartProps.data }), /*#__PURE__*/React.createElement(ReportMainChartProps, { layout: rootChartProps.layout, margin: rootChartProps.margin }), /*#__PURE__*/React.createElement(ReportChartProps, { baseValue: rootChartProps.baseValue, accessibilityLayer: rootChartProps.accessibilityLayer, barCategoryGap: rootChartProps.barCategoryGap, maxBarSize: rootChartProps.maxBarSize, stackOffset: rootChartProps.stackOffset, barGap: rootChartProps.barGap, barSize: rootChartProps.barSize, syncId: rootChartProps.syncId, syncMethod: rootChartProps.syncMethod, className: rootChartProps.className, reverseStackOrder: rootChartProps.reverseStackOrder }), /*#__PURE__*/React.createElement(CategoricalChart, _extends({}, rootChartProps, { ref: ref }))); });