@mui/x-charts 8.3.1 → 8.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.d.ts +9 -2
- package/BarChart/BarChart.js +11 -3
- package/BarChart/useBarChartProps.js +1 -1
- package/CHANGELOG.md +213 -0
- package/ChartContainer/ChartContainer.d.ts +21 -2
- package/ChartContainer/ChartContainer.js +17 -1
- package/ChartContainer/useChartContainerProps.js +7 -3
- package/ChartDataProvider/ChartDataProvider.d.ts +11 -1
- package/ChartDataProvider/ChartDataProvider.js +19 -2
- package/ChartDataProvider/useChartDataProviderProps.d.ts +2 -0
- package/ChartDataProvider/useChartDataProviderProps.js +7 -3
- package/ChartsAxis/axisClasses.d.ts +5 -0
- package/ChartsAxis/axisClasses.js +1 -1
- package/ChartsLegend/ChartsLegend.js +1 -0
- package/ChartsLocalizationProvider/ChartsLocalizationProvider.js +1 -3
- package/ChartsSurface/ChartsSurface.js +1 -0
- package/ChartsXAxis/ChartsXAxis.js +7 -16
- package/ChartsYAxis/ChartsYAxis.js +4 -8
- package/Gauge/Gauge.js +1 -0
- package/Gauge/GaugeContainer.js +1 -0
- package/Gauge/GaugeProvider.js +1 -3
- package/LineChart/AnimatedLine.js +1 -0
- package/LineChart/LineChart.d.ts +9 -2
- package/LineChart/LineChart.js +11 -3
- package/LineChart/LineHighlightPlot.js +1 -4
- package/LineChart/MarkPlot.js +1 -4
- package/LineChart/useLineChartProps.js +1 -1
- package/PieChart/PieArc.js +1 -0
- package/PieChart/PieArcLabel.js +1 -0
- package/PieChart/PieChart.d.ts +10 -3
- package/PieChart/PieChart.js +18 -9
- package/RadarChart/RadarChart.d.ts +21 -3
- package/RadarChart/RadarChart.js +20 -4
- package/RadarChart/RadarChart.plugins.d.ts +5 -0
- package/RadarChart/RadarChart.plugins.js +10 -0
- package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +6 -11
- package/RadarChart/RadarDataProvider/RadarDataProvider.js +6 -116
- package/RadarChart/index.d.ts +2 -0
- package/RadarChart/index.js +15 -1
- package/RadarChart/useRadarChartProps.d.ts +2 -1
- package/RadarChart/useRadarChartProps.js +3 -1
- package/ScatterChart/Scatter.js +3 -11
- package/ScatterChart/ScatterChart.d.ts +9 -2
- package/ScatterChart/ScatterChart.js +13 -5
- package/ScatterChart/useScatterChartProps.js +4 -2
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +31 -26
- package/Toolbar/Toolbar.d.ts +9 -3
- package/Toolbar/Toolbar.js +23 -7
- package/Toolbar/Toolbar.types.d.ts +15 -0
- package/Toolbar/Toolbar.types.js +5 -0
- package/Toolbar/ToolbarButton.d.ts +8 -2
- package/Toolbar/ToolbarButton.js +25 -6
- package/Toolbar/chartToolbarClasses.d.ts +6 -0
- package/Toolbar/chartToolbarClasses.js +9 -0
- package/Toolbar/index.d.ts +3 -1
- package/Toolbar/index.js +22 -0
- package/Toolbar/internals/ChartsToolbar.d.ts +6 -0
- package/Toolbar/internals/ChartsToolbar.js +14 -0
- package/context/ChartProvider/ChartContext.js +1 -3
- package/context/ChartsSlotsContext.d.ts +20 -0
- package/context/ChartsSlotsContext.js +44 -0
- package/context/index.d.ts +2 -1
- package/context/index.js +11 -0
- package/context/useChartApiContext.d.ts +10 -0
- package/context/useChartApiContext.js +27 -0
- package/esm/BarChart/BarChart.d.ts +9 -2
- package/esm/BarChart/BarChart.js +11 -3
- package/esm/BarChart/useBarChartProps.js +1 -1
- package/esm/ChartContainer/ChartContainer.d.ts +21 -2
- package/esm/ChartContainer/ChartContainer.js +17 -1
- package/esm/ChartContainer/useChartContainerProps.js +7 -3
- package/esm/ChartDataProvider/ChartDataProvider.d.ts +11 -1
- package/esm/ChartDataProvider/ChartDataProvider.js +19 -2
- package/esm/ChartDataProvider/useChartDataProviderProps.d.ts +2 -0
- package/esm/ChartDataProvider/useChartDataProviderProps.js +7 -3
- package/esm/ChartsAxis/axisClasses.d.ts +5 -0
- package/esm/ChartsAxis/axisClasses.js +1 -1
- package/esm/ChartsLegend/ChartsLegend.js +1 -0
- package/esm/ChartsLocalizationProvider/ChartsLocalizationProvider.js +1 -3
- package/esm/ChartsSurface/ChartsSurface.js +1 -0
- package/esm/ChartsXAxis/ChartsXAxis.js +7 -16
- package/esm/ChartsYAxis/ChartsYAxis.js +4 -8
- package/esm/Gauge/Gauge.js +1 -0
- package/esm/Gauge/GaugeContainer.js +1 -0
- package/esm/Gauge/GaugeProvider.js +1 -3
- package/esm/LineChart/AnimatedLine.js +1 -0
- package/esm/LineChart/LineChart.d.ts +9 -2
- package/esm/LineChart/LineChart.js +11 -3
- package/esm/LineChart/LineHighlightPlot.js +1 -4
- package/esm/LineChart/MarkPlot.js +1 -4
- package/esm/LineChart/useLineChartProps.js +1 -1
- package/esm/PieChart/PieArc.js +1 -0
- package/esm/PieChart/PieArcLabel.js +1 -0
- package/esm/PieChart/PieChart.d.ts +10 -3
- package/esm/PieChart/PieChart.js +16 -7
- package/esm/RadarChart/RadarChart.d.ts +21 -3
- package/esm/RadarChart/RadarChart.js +20 -4
- package/esm/RadarChart/RadarChart.plugins.d.ts +5 -0
- package/esm/RadarChart/RadarChart.plugins.js +4 -0
- package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +6 -11
- package/esm/RadarChart/RadarDataProvider/RadarDataProvider.js +5 -115
- package/esm/RadarChart/index.d.ts +2 -0
- package/esm/RadarChart/index.js +2 -0
- package/esm/RadarChart/useRadarChartProps.d.ts +2 -1
- package/esm/RadarChart/useRadarChartProps.js +3 -1
- package/esm/ScatterChart/Scatter.js +3 -11
- package/esm/ScatterChart/ScatterChart.d.ts +9 -2
- package/esm/ScatterChart/ScatterChart.js +13 -5
- package/esm/ScatterChart/useScatterChartProps.js +4 -2
- package/esm/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +31 -26
- package/esm/Toolbar/Toolbar.d.ts +9 -3
- package/esm/Toolbar/Toolbar.js +22 -7
- package/esm/Toolbar/Toolbar.types.d.ts +15 -0
- package/esm/Toolbar/Toolbar.types.js +1 -0
- package/esm/Toolbar/ToolbarButton.d.ts +8 -2
- package/esm/Toolbar/ToolbarButton.js +24 -5
- package/esm/Toolbar/chartToolbarClasses.d.ts +6 -0
- package/esm/Toolbar/chartToolbarClasses.js +2 -0
- package/esm/Toolbar/index.d.ts +3 -1
- package/esm/Toolbar/index.js +3 -1
- package/esm/Toolbar/internals/ChartsToolbar.d.ts +6 -0
- package/esm/Toolbar/internals/ChartsToolbar.js +8 -0
- package/esm/context/ChartProvider/ChartContext.js +1 -3
- package/esm/context/ChartsSlotsContext.d.ts +20 -0
- package/esm/context/ChartsSlotsContext.js +35 -0
- package/esm/context/index.d.ts +2 -1
- package/esm/context/index.js +1 -0
- package/esm/context/useChartApiContext.d.ts +10 -0
- package/esm/context/useChartApiContext.js +21 -0
- package/esm/hooks/index.d.ts +1 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/useTicks.js +2 -6
- package/esm/index.js +1 -1
- package/esm/internals/constants.d.ts +3 -1
- package/esm/internals/constants.js +2 -1
- package/esm/internals/consumeSlots.js +2 -1
- package/esm/internals/consumeThemeProps.js +3 -1
- package/esm/internals/dateHelpers.d.ts +15 -0
- package/esm/internals/dateHelpers.js +20 -0
- package/esm/internals/domUtils.d.ts +1 -2
- package/esm/internals/domUtils.js +8 -19
- package/esm/internals/index.d.ts +4 -1
- package/esm/internals/index.js +4 -1
- package/esm/internals/material/index.d.ts +2 -0
- package/esm/internals/plugins/allPlugins.d.ts +1 -0
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +11 -17
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +16 -13
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +2 -8
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +14 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +5 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js +4 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +1 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +5 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +83 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +8 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +17 -0
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +5 -0
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +11 -5
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -8
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +1 -3
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +2 -5
- package/esm/models/index.d.ts +2 -2
- package/esm/models/index.js +1 -0
- package/esm/models/slots/chartsBaseSlotProps.d.ts +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +12 -0
- package/hooks/useTicks.js +2 -6
- package/index.js +1 -1
- package/internals/constants.d.ts +3 -1
- package/internals/constants.js +3 -2
- package/internals/consumeSlots.js +2 -1
- package/internals/consumeThemeProps.js +3 -1
- package/internals/dateHelpers.d.ts +15 -0
- package/internals/dateHelpers.js +28 -0
- package/internals/domUtils.d.ts +1 -2
- package/internals/domUtils.js +8 -20
- package/internals/index.d.ts +4 -1
- package/internals/index.js +44 -8
- package/internals/material/index.d.ts +2 -0
- package/internals/plugins/allPlugins.d.ts +1 -0
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +11 -17
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +16 -13
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +7 -8
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +14 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +6 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.js +4 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +1 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +5 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +83 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +9 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +17 -0
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +5 -0
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +11 -5
- package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +5 -11
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +1 -3
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +2 -5
- package/models/index.d.ts +2 -2
- package/models/index.js +11 -0
- package/models/slots/chartsBaseSlotProps.d.ts +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartApi } from "../ChartContainer/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* The `useChartApiContext` hook provides access to the chart API.
|
|
5
|
+
* This is only available when the chart is rendered within a chart or a `ChartDataProvider` component.
|
|
6
|
+
* If you want to access the chart API outside those components, you should use the `apiRef` prop instead.
|
|
7
|
+
* @example
|
|
8
|
+
* const apiRef = useChartApiContext<ChartApi<'bar'>>();
|
|
9
|
+
*/
|
|
10
|
+
export declare function useChartApiContext<Api extends ChartApi>(): React.RefObject<Api>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useChartApiContext = useChartApiContext;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _ChartProvider = require("./ChartProvider");
|
|
11
|
+
/**
|
|
12
|
+
* The `useChartApiContext` hook provides access to the chart API.
|
|
13
|
+
* This is only available when the chart is rendered within a chart or a `ChartDataProvider` component.
|
|
14
|
+
* If you want to access the chart API outside those components, you should use the `apiRef` prop instead.
|
|
15
|
+
* @example
|
|
16
|
+
* const apiRef = useChartApiContext<ChartApi<'bar'>>();
|
|
17
|
+
*/
|
|
18
|
+
function useChartApiContext() {
|
|
19
|
+
const {
|
|
20
|
+
publicAPI
|
|
21
|
+
} = (0, _ChartProvider.useChartContext)();
|
|
22
|
+
const apiRef = React.useRef(publicAPI);
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
apiRef.current = publicAPI;
|
|
25
|
+
}, [publicAPI]);
|
|
26
|
+
return apiRef;
|
|
27
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MakeOptional } from '@mui/x-internals/types';
|
|
3
|
+
import { ChartsSlotProps, ChartsSlots } from "../internals/material/index.js";
|
|
4
|
+
import { ChartsToolbarSlotProps, ChartsToolbarSlots } from "../Toolbar/index.js";
|
|
3
5
|
import { BarPlotProps, BarPlotSlotProps, BarPlotSlots } from "./BarPlot.js";
|
|
4
6
|
import { ChartContainerProps } from "../ChartContainer/index.js";
|
|
5
7
|
import { ChartsAxisProps } from "../ChartsAxis/index.js";
|
|
@@ -11,8 +13,8 @@ import { ChartsAxisSlots, ChartsAxisSlotProps } from "../models/axis.js";
|
|
|
11
13
|
import { ChartsGridProps } from "../ChartsGrid/index.js";
|
|
12
14
|
import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from "../ChartsOverlay/ChartsOverlay.js";
|
|
13
15
|
import { BarChartPluginsSignatures } from "./BarChart.plugins.js";
|
|
14
|
-
export interface BarChartSlots extends ChartsAxisSlots, BarPlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots {}
|
|
15
|
-
export interface BarChartSlotProps extends ChartsAxisSlotProps, BarPlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps {}
|
|
16
|
+
export interface BarChartSlots extends ChartsAxisSlots, BarPlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
|
|
17
|
+
export interface BarChartSlotProps extends ChartsAxisSlotProps, BarPlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
|
|
16
18
|
export interface BarChartProps extends Omit<ChartContainerProps<'bar', BarChartPluginsSignatures>, 'series' | 'plugins' | 'zAxis'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<BarPlotProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
|
|
17
19
|
/**
|
|
18
20
|
* The series to display in the bar chart.
|
|
@@ -50,6 +52,11 @@ export interface BarChartProps extends Omit<ChartContainerProps<'bar', BarChartP
|
|
|
50
52
|
* @default 'vertical'
|
|
51
53
|
*/
|
|
52
54
|
layout?: BarSeriesType['layout'];
|
|
55
|
+
/**
|
|
56
|
+
* If true, shows the default chart toolbar.
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
showToolbar?: boolean;
|
|
53
60
|
}
|
|
54
61
|
/**
|
|
55
62
|
* Demos:
|
package/esm/BarChart/BarChart.js
CHANGED
|
@@ -17,6 +17,7 @@ import { ChartDataProvider } from "../ChartDataProvider/index.js";
|
|
|
17
17
|
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
18
18
|
import { useChartContainerProps } from "../ChartContainer/useChartContainerProps.js";
|
|
19
19
|
import { ChartsWrapper } from "../internals/components/ChartsWrapper/index.js";
|
|
20
|
+
import { ChartsToolbar } from "../Toolbar/internals/ChartsToolbar.js";
|
|
20
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
22
|
/**
|
|
22
23
|
* Demos:
|
|
@@ -52,16 +53,18 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(inProps, ref) {
|
|
|
52
53
|
chartsSurfaceProps
|
|
53
54
|
} = useChartContainerProps(chartContainerProps, ref);
|
|
54
55
|
const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
|
|
56
|
+
const Toolbar = props.slots?.toolbar ?? ChartsToolbar;
|
|
55
57
|
return /*#__PURE__*/_jsx(ChartDataProvider, _extends({}, chartDataProviderProps, {
|
|
56
58
|
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
57
|
-
children: [!props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
59
|
+
children: [props.showToolbar ? /*#__PURE__*/_jsx(Toolbar, {}) : null, !props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
58
60
|
children: [/*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
|
|
59
61
|
children: [/*#__PURE__*/_jsx(BarPlot, _extends({}, barPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
|
|
60
|
-
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)),
|
|
61
|
-
}))]
|
|
62
|
+
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
|
|
63
|
+
})), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip))]
|
|
62
64
|
}))
|
|
63
65
|
}));
|
|
64
66
|
});
|
|
67
|
+
if (process.env.NODE_ENV !== "production") BarChart.displayName = "BarChart";
|
|
65
68
|
process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
66
69
|
// ----------------------------- Warning --------------------------------
|
|
67
70
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -188,6 +191,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
188
191
|
* An array of [[BarSeriesType]] objects.
|
|
189
192
|
*/
|
|
190
193
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
194
|
+
/**
|
|
195
|
+
* If true, shows the default chart toolbar.
|
|
196
|
+
* @default false
|
|
197
|
+
*/
|
|
198
|
+
showToolbar: PropTypes.bool,
|
|
191
199
|
/**
|
|
192
200
|
* If `true`, animations are skipped.
|
|
193
201
|
* If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "axisHighlight", "grid", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend"];
|
|
5
|
+
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "axisHighlight", "grid", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend", "showToolbar"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import useId from '@mui/utils/useId';
|
|
8
8
|
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from "../constants/index.js";
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { PieChartPluginSignatures } from "../PieChart/PieChart.plugins.js";
|
|
3
|
+
import { BarChartPluginsSignatures } from "../BarChart/BarChart.plugins.js";
|
|
4
|
+
import { ScatterChartPluginsSignatures } from "../ScatterChart/ScatterChart.plugins.js";
|
|
5
|
+
import { LineChartPluginsSignatures } from "../LineChart/LineChart.plugins.js";
|
|
2
6
|
import { ChartSeriesType } from "../models/seriesType/config.js";
|
|
3
7
|
import { ChartDataProviderProps } from "../ChartDataProvider/index.js";
|
|
4
8
|
import { ChartsSurfaceProps } from "../ChartsSurface/index.js";
|
|
5
|
-
import { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
9
|
+
import { AllPluginSignatures, DefaultPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
6
10
|
import { ChartAnyPluginSignature } from "../internals/plugins/models/plugin.js";
|
|
11
|
+
import { ChartPublicAPI } from "../internals/plugins/models/index.js";
|
|
7
12
|
export type ChartContainerProps<SeriesType extends ChartSeriesType = ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[] = AllPluginSignatures<SeriesType>> = Omit<ChartDataProviderProps<SeriesType, TSignatures>, 'children'> & ChartsSurfaceProps;
|
|
8
|
-
|
|
13
|
+
type PluginsPerSeriesType = {
|
|
14
|
+
line: LineChartPluginsSignatures;
|
|
15
|
+
scatter: ScatterChartPluginsSignatures;
|
|
16
|
+
bar: BarChartPluginsSignatures;
|
|
17
|
+
pie: PieChartPluginSignatures;
|
|
18
|
+
composition: DefaultPluginSignatures;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The API of the chart `apiRef` object.
|
|
22
|
+
* The chart type can be passed as the first generic parameter to narrow down the API to the specific chart type.
|
|
23
|
+
* @example ChartApi<'bar'>
|
|
24
|
+
* If the chart is being created using composition, the `composition` value can be used.
|
|
25
|
+
* @example ChartApi<'composition'>
|
|
26
|
+
*/
|
|
27
|
+
export type ChartApi<TSeries extends keyof PluginsPerSeriesType | undefined = undefined, TSignatures extends readonly ChartAnyPluginSignature[] = (TSeries extends keyof PluginsPerSeriesType ? PluginsPerSeriesType[TSeries] : AllPluginSignatures)> = ChartPublicAPI<TSignatures>;
|
|
9
28
|
/**
|
|
10
29
|
* It sets up the data providers as well as the `<svg>` for the chart.
|
|
11
30
|
*
|
|
@@ -6,6 +6,14 @@ import PropTypes from 'prop-types';
|
|
|
6
6
|
import { ChartDataProvider } from "../ChartDataProvider/index.js";
|
|
7
7
|
import { useChartContainerProps } from "./useChartContainerProps.js";
|
|
8
8
|
import { ChartsSurface } from "../ChartsSurface/index.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The API of the chart `apiRef` object.
|
|
12
|
+
* The chart type can be passed as the first generic parameter to narrow down the API to the specific chart type.
|
|
13
|
+
* @example ChartApi<'bar'>
|
|
14
|
+
* If the chart is being created using composition, the `composition` value can be used.
|
|
15
|
+
* @example ChartApi<'composition'>
|
|
16
|
+
*/
|
|
9
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
18
|
/**
|
|
11
19
|
* It sets up the data providers as well as the `<svg>` for the chart.
|
|
@@ -45,7 +53,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
45
53
|
});
|
|
46
54
|
|
|
47
55
|
// @ts-ignore
|
|
48
|
-
|
|
56
|
+
if (process.env.NODE_ENV !== "production") ChartContainer.displayName = "ChartContainer";
|
|
49
57
|
process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
50
58
|
// ----------------------------- Warning --------------------------------
|
|
51
59
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -586,6 +594,14 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
586
594
|
* If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
|
|
587
595
|
*/
|
|
588
596
|
skipAnimation: PropTypes.bool,
|
|
597
|
+
/**
|
|
598
|
+
* The props for the slots.
|
|
599
|
+
*/
|
|
600
|
+
slotProps: PropTypes.object,
|
|
601
|
+
/**
|
|
602
|
+
* Slots to customize charts' components.
|
|
603
|
+
*/
|
|
604
|
+
slots: PropTypes.object,
|
|
589
605
|
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
590
606
|
theme: PropTypes.oneOf(['dark', 'light']),
|
|
591
607
|
title: PropTypes.string,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "onAxisClick", "disableVoronoi", "voronoiMaxRadius", "onItemClick", "disableAxisListener", "highlightedItem", "onHighlightChange", "sx", "title", "xAxis", "yAxis", "zAxis", "rotationAxis", "radiusAxis", "skipAnimation", "seriesConfig", "plugins", "localeText"];
|
|
5
|
+
const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "onAxisClick", "disableVoronoi", "voronoiMaxRadius", "onItemClick", "disableAxisListener", "highlightedItem", "onHighlightChange", "sx", "title", "xAxis", "yAxis", "zAxis", "rotationAxis", "radiusAxis", "skipAnimation", "seriesConfig", "plugins", "localeText", "slots", "slotProps"];
|
|
6
6
|
import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
|
|
7
7
|
export const useChartContainerProps = (props, ref) => {
|
|
8
8
|
const _ref = props,
|
|
@@ -32,7 +32,9 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
32
32
|
skipAnimation,
|
|
33
33
|
seriesConfig,
|
|
34
34
|
plugins,
|
|
35
|
-
localeText
|
|
35
|
+
localeText,
|
|
36
|
+
slots,
|
|
37
|
+
slotProps
|
|
36
38
|
} = _ref,
|
|
37
39
|
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
38
40
|
const chartsSurfaceProps = _extends({
|
|
@@ -63,7 +65,9 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
63
65
|
height,
|
|
64
66
|
localeText,
|
|
65
67
|
seriesConfig,
|
|
66
|
-
plugins: plugins ?? DEFAULT_PLUGINS
|
|
68
|
+
plugins: plugins ?? DEFAULT_PLUGINS,
|
|
69
|
+
slots,
|
|
70
|
+
slotProps
|
|
67
71
|
};
|
|
68
72
|
return {
|
|
69
73
|
chartDataProviderProps,
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { ChartsSlotProps, ChartsSlots } from "../internals/material/index.js";
|
|
2
3
|
import { ChartProviderProps } from "../context/ChartProvider/index.js";
|
|
3
4
|
import { ChartSeriesType } from "../models/seriesType/config.js";
|
|
4
5
|
import { ChartAnyPluginSignature } from "../internals/plugins/models/plugin.js";
|
|
5
6
|
import { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
6
7
|
import { ChartsLocalizationProviderProps } from "../ChartsLocalizationProvider/index.js";
|
|
7
|
-
export type ChartDataProviderProps<TSeries extends ChartSeriesType = ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[] = AllPluginSignatures<TSeries>> = React.PropsWithChildren<ChartProviderProps<TSeries, TSignatures>['pluginParams'] & Pick<ChartProviderProps<TSeries, TSignatures>, 'seriesConfig' | 'plugins'>> & ChartsLocalizationProviderProps
|
|
8
|
+
export type ChartDataProviderProps<TSeries extends ChartSeriesType = ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[] = AllPluginSignatures<TSeries>> = React.PropsWithChildren<ChartProviderProps<TSeries, TSignatures>['pluginParams'] & Pick<ChartProviderProps<TSeries, TSignatures>, 'seriesConfig' | 'plugins'>> & ChartsLocalizationProviderProps & {
|
|
9
|
+
/**
|
|
10
|
+
* Slots to customize charts' components.
|
|
11
|
+
*/
|
|
12
|
+
slots?: Partial<ChartsSlots>;
|
|
13
|
+
/**
|
|
14
|
+
* The props for the slots.
|
|
15
|
+
*/
|
|
16
|
+
slotProps?: Partial<ChartsSlotProps>;
|
|
17
|
+
};
|
|
8
18
|
/**
|
|
9
19
|
* Orchestrates the data providers for the chart components and hooks.
|
|
10
20
|
*
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
+
import { defaultSlotsMaterial } from "../internals/material/index.js";
|
|
7
|
+
import { ChartsSlotsProvider } from "../context/ChartsSlotsContext.js";
|
|
6
8
|
import { useChartDataProviderProps } from "./useChartDataProviderProps.js";
|
|
7
9
|
import { ChartProvider } from "../context/ChartProvider/index.js";
|
|
8
10
|
import { ChartsLocalizationProvider } from "../ChartsLocalizationProvider/index.js";
|
|
@@ -38,12 +40,19 @@ function ChartDataProvider(props) {
|
|
|
38
40
|
const {
|
|
39
41
|
children,
|
|
40
42
|
localeText,
|
|
41
|
-
chartProviderProps
|
|
43
|
+
chartProviderProps,
|
|
44
|
+
slots,
|
|
45
|
+
slotProps
|
|
42
46
|
} = useChartDataProviderProps(props);
|
|
43
47
|
return /*#__PURE__*/_jsx(ChartProvider, _extends({}, chartProviderProps, {
|
|
44
48
|
children: /*#__PURE__*/_jsx(ChartsLocalizationProvider, {
|
|
45
49
|
localeText: localeText,
|
|
46
|
-
children:
|
|
50
|
+
children: /*#__PURE__*/_jsx(ChartsSlotsProvider, {
|
|
51
|
+
slots: slots,
|
|
52
|
+
slotProps: slotProps,
|
|
53
|
+
defaultSlots: defaultSlotsMaterial,
|
|
54
|
+
children: children
|
|
55
|
+
})
|
|
47
56
|
})
|
|
48
57
|
}));
|
|
49
58
|
}
|
|
@@ -100,6 +109,14 @@ process.env.NODE_ENV !== "production" ? ChartDataProvider.propTypes = {
|
|
|
100
109
|
* If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
|
|
101
110
|
*/
|
|
102
111
|
skipAnimation: PropTypes.bool,
|
|
112
|
+
/**
|
|
113
|
+
* The props for the slots.
|
|
114
|
+
*/
|
|
115
|
+
slotProps: PropTypes.object,
|
|
116
|
+
/**
|
|
117
|
+
* Slots to customize charts' components.
|
|
118
|
+
*/
|
|
119
|
+
slots: PropTypes.object,
|
|
103
120
|
theme: PropTypes.oneOf(['dark', 'light']),
|
|
104
121
|
/**
|
|
105
122
|
* The width of the chart in px. If not defined, it takes the width of the parent element.
|
|
@@ -8,4 +8,6 @@ export declare const useChartDataProviderProps: <TSeries extends ChartSeriesType
|
|
|
8
8
|
children: import("react").ReactNode;
|
|
9
9
|
localeText: Partial<import("../locales/index.js").ChartsLocaleText> | undefined;
|
|
10
10
|
chartProviderProps: ChartProviderProps<TSeries, TSignatures>;
|
|
11
|
+
slots: Partial<import("../internals/index.js").ChartsSlots> | undefined;
|
|
12
|
+
slotProps: Partial<import("../internals/index.js").ChartsSlotProps> | undefined;
|
|
11
13
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["children", "localeText", "plugins", "seriesConfig"];
|
|
5
|
+
const _excluded = ["children", "localeText", "plugins", "seriesConfig", "slots", "slotProps"];
|
|
6
6
|
import { useTheme } from '@mui/material/styles';
|
|
7
7
|
import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
|
|
8
8
|
export const useChartDataProviderProps = props => {
|
|
@@ -10,7 +10,9 @@ export const useChartDataProviderProps = props => {
|
|
|
10
10
|
children,
|
|
11
11
|
localeText,
|
|
12
12
|
plugins = DEFAULT_PLUGINS,
|
|
13
|
-
seriesConfig
|
|
13
|
+
seriesConfig,
|
|
14
|
+
slots,
|
|
15
|
+
slotProps
|
|
14
16
|
} = props,
|
|
15
17
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
16
18
|
const theme = useTheme();
|
|
@@ -24,6 +26,8 @@ export const useChartDataProviderProps = props => {
|
|
|
24
26
|
return {
|
|
25
27
|
children,
|
|
26
28
|
localeText,
|
|
27
|
-
chartProviderProps
|
|
29
|
+
chartProviderProps,
|
|
30
|
+
slots,
|
|
31
|
+
slotProps
|
|
28
32
|
};
|
|
29
33
|
};
|
|
@@ -27,6 +27,11 @@ export interface ChartsAxisClasses {
|
|
|
27
27
|
left: string;
|
|
28
28
|
/** Styles applied to the right axis. */
|
|
29
29
|
right: string;
|
|
30
|
+
/**
|
|
31
|
+
* Styles applied to the root element for the axis with the given ID.
|
|
32
|
+
* Needs to be suffixed with the axis ID: `.${axisClasses.id}-${axisId}`.
|
|
33
|
+
*/
|
|
34
|
+
id: string;
|
|
30
35
|
}
|
|
31
36
|
export type ChartsAxisClassKey = keyof ChartsAxisClasses;
|
|
32
37
|
export declare function getAxisUtilityClass(slot: string): string;
|
|
@@ -3,4 +3,4 @@ import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
|
3
3
|
export function getAxisUtilityClass(slot) {
|
|
4
4
|
return generateUtilityClass('MuiChartsAxis', slot);
|
|
5
5
|
}
|
|
6
|
-
export const axisClasses = generateUtilityClasses('MuiChartsAxis', ['root', 'line', 'tickContainer', 'tick', 'tickLabel', 'label', 'directionX', 'directionY', 'top', 'bottom', 'left', 'right']);
|
|
6
|
+
export const axisClasses = generateUtilityClasses('MuiChartsAxis', ['root', 'line', 'tickContainer', 'tick', 'tickLabel', 'label', 'directionX', 'directionY', 'top', 'bottom', 'left', 'right', 'id']);
|
|
@@ -100,6 +100,7 @@ const ChartsLegend = consumeSlots('MuiChartsLegend', 'legend', {
|
|
|
100
100
|
})
|
|
101
101
|
}));
|
|
102
102
|
}));
|
|
103
|
+
if (process.env.NODE_ENV !== "production") ChartsLegend.displayName = "ChartsLegend";
|
|
103
104
|
process.env.NODE_ENV !== "production" ? ChartsLegend.propTypes = {
|
|
104
105
|
// ----------------------------- Warning --------------------------------
|
|
105
106
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -9,9 +9,7 @@ import { useThemeProps } from '@mui/material/styles';
|
|
|
9
9
|
import { DEFAULT_LOCALE } from "../locales/enUS.js";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
export const ChartsLocalizationContext = /*#__PURE__*/React.createContext(null);
|
|
12
|
-
if (process.env.NODE_ENV !==
|
|
13
|
-
ChartsLocalizationContext.displayName = 'ChartsLocalizationContext';
|
|
14
|
-
}
|
|
12
|
+
if (process.env.NODE_ENV !== "production") ChartsLocalizationContext.displayName = "ChartsLocalizationContext";
|
|
15
13
|
/**
|
|
16
14
|
* Demos:
|
|
17
15
|
*
|
|
@@ -86,6 +86,7 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(inPro
|
|
|
86
86
|
}), /*#__PURE__*/_jsx(ChartsAxesGradients, {}), hasIntrinsicSize && children]
|
|
87
87
|
}));
|
|
88
88
|
});
|
|
89
|
+
if (process.env.NODE_ENV !== "production") ChartsSurface.displayName = "ChartsSurface";
|
|
89
90
|
process.env.NODE_ENV !== "production" ? ChartsSurface.propTypes = {
|
|
90
91
|
// ----------------------------- Warning --------------------------------
|
|
91
92
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -31,10 +31,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
31
31
|
const useUtilityClasses = ownerState => {
|
|
32
32
|
const {
|
|
33
33
|
classes,
|
|
34
|
-
position
|
|
34
|
+
position,
|
|
35
|
+
id
|
|
35
36
|
} = ownerState;
|
|
36
37
|
const slots = {
|
|
37
|
-
root: ['root', 'directionX', position],
|
|
38
|
+
root: ['root', 'directionX', position, `id-${id}`],
|
|
38
39
|
line: ['line'],
|
|
39
40
|
tickContainer: ['tickContainer'],
|
|
40
41
|
tick: ['tick'],
|
|
@@ -56,7 +57,7 @@ function getVisibleLabels(xTicks, {
|
|
|
56
57
|
tickLabelMinGap,
|
|
57
58
|
reverse,
|
|
58
59
|
isMounted,
|
|
59
|
-
|
|
60
|
+
isXInside
|
|
60
61
|
}) {
|
|
61
62
|
const getTickLabelSize = tick => {
|
|
62
63
|
if (!isMounted || tick.formattedValue === undefined) {
|
|
@@ -91,7 +92,7 @@ function getVisibleLabels(xTicks, {
|
|
|
91
92
|
if (labelIndex > 0 && direction * textPosition < direction * (previousTextLimit + tickLabelMinGap)) {
|
|
92
93
|
return false;
|
|
93
94
|
}
|
|
94
|
-
if (!
|
|
95
|
+
if (!isXInside(textPosition)) {
|
|
95
96
|
return false;
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -259,12 +260,7 @@ function ChartsXAxis(inProps) {
|
|
|
259
260
|
tickLabelMinGap,
|
|
260
261
|
reverse,
|
|
261
262
|
isMounted,
|
|
262
|
-
|
|
263
|
-
x,
|
|
264
|
-
y: -1
|
|
265
|
-
}, {
|
|
266
|
-
direction: 'x'
|
|
267
|
-
})
|
|
263
|
+
isXInside: instance.isXInside
|
|
268
264
|
});
|
|
269
265
|
const axisLabelProps = useSlotProps({
|
|
270
266
|
elementType: Label,
|
|
@@ -312,12 +308,7 @@ function ChartsXAxis(inProps) {
|
|
|
312
308
|
} = item;
|
|
313
309
|
const xTickLabel = labelOffset ?? 0;
|
|
314
310
|
const yTickLabel = positionSign * (tickSize + TICK_LABEL_GAP);
|
|
315
|
-
const showTick = instance.
|
|
316
|
-
x: tickOffset,
|
|
317
|
-
y: -1
|
|
318
|
-
}, {
|
|
319
|
-
direction: 'x'
|
|
320
|
-
});
|
|
311
|
+
const showTick = instance.isXInside(tickOffset);
|
|
321
312
|
const tickLabel = tickLabels.get(item);
|
|
322
313
|
const showTickLabel = visibleLabels.has(item);
|
|
323
314
|
return /*#__PURE__*/_jsxs("g", {
|
|
@@ -28,10 +28,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
28
28
|
const useUtilityClasses = ownerState => {
|
|
29
29
|
const {
|
|
30
30
|
classes,
|
|
31
|
-
position
|
|
31
|
+
position,
|
|
32
|
+
id
|
|
32
33
|
} = ownerState;
|
|
33
34
|
const slots = {
|
|
34
|
-
root: ['root', 'directionY', position],
|
|
35
|
+
root: ['root', 'directionY', position, `id-${id}`],
|
|
35
36
|
line: ['line'],
|
|
36
37
|
tickContainer: ['tickContainer'],
|
|
37
38
|
tick: ['tick'],
|
|
@@ -236,12 +237,7 @@ function ChartsYAxis(inProps) {
|
|
|
236
237
|
const xTickLabel = positionSign * (tickSize + TICK_LABEL_GAP);
|
|
237
238
|
const yTickLabel = labelOffset;
|
|
238
239
|
const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
|
|
239
|
-
const showLabel = instance.
|
|
240
|
-
x: -1,
|
|
241
|
-
y: tickOffset
|
|
242
|
-
}, {
|
|
243
|
-
direction: 'y'
|
|
244
|
-
});
|
|
240
|
+
const showLabel = instance.isYInside(tickOffset);
|
|
245
241
|
const tickLabel = tickLabels.get(item);
|
|
246
242
|
if (!showLabel) {
|
|
247
243
|
return null;
|
package/esm/Gauge/Gauge.js
CHANGED
|
@@ -48,6 +48,7 @@ const Gauge = /*#__PURE__*/React.forwardRef(function Gauge(props, ref) {
|
|
|
48
48
|
}), children]
|
|
49
49
|
}));
|
|
50
50
|
});
|
|
51
|
+
if (process.env.NODE_ENV !== "production") Gauge.displayName = "Gauge";
|
|
51
52
|
process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
|
|
52
53
|
// ----------------------------- Warning --------------------------------
|
|
53
54
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -78,6 +78,7 @@ const GaugeContainer = /*#__PURE__*/React.forwardRef(function GaugeContainer(pro
|
|
|
78
78
|
})
|
|
79
79
|
});
|
|
80
80
|
});
|
|
81
|
+
if (process.env.NODE_ENV !== "production") GaugeContainer.displayName = "GaugeContainer";
|
|
81
82
|
process.env.NODE_ENV !== "production" ? GaugeContainer.propTypes = {
|
|
82
83
|
// ----------------------------- Warning --------------------------------
|
|
83
84
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -21,9 +21,7 @@ export const GaugeContext = /*#__PURE__*/React.createContext({
|
|
|
21
21
|
maxRadius: 0,
|
|
22
22
|
valueAngle: null
|
|
23
23
|
});
|
|
24
|
-
if (process.env.NODE_ENV !==
|
|
25
|
-
GaugeContext.displayName = 'GaugeContext';
|
|
26
|
-
}
|
|
24
|
+
if (process.env.NODE_ENV !== "production") GaugeContext.displayName = "GaugeContext";
|
|
27
25
|
export function GaugeProvider(props) {
|
|
28
26
|
const {
|
|
29
27
|
value = null,
|
|
@@ -40,6 +40,7 @@ const AnimatedLine = /*#__PURE__*/React.forwardRef(function AnimatedLine(props,
|
|
|
40
40
|
}, other, animateProps))
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
|
+
if (process.env.NODE_ENV !== "production") AnimatedLine.displayName = "AnimatedLine";
|
|
43
44
|
process.env.NODE_ENV !== "production" ? AnimatedLine.propTypes = {
|
|
44
45
|
// ----------------------------- Warning --------------------------------
|
|
45
46
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MakeOptional } from '@mui/x-internals/types';
|
|
3
|
+
import { ChartsSlots, ChartsSlotProps } from "../internals/material/index.js";
|
|
3
4
|
import { AreaPlotProps, AreaPlotSlotProps, AreaPlotSlots } from "./AreaPlot.js";
|
|
4
5
|
import { LinePlotProps, LinePlotSlotProps, LinePlotSlots } from "./LinePlot.js";
|
|
5
6
|
import { ChartContainerProps } from "../ChartContainer/index.js";
|
|
@@ -14,8 +15,9 @@ import { LineHighlightPlotSlots, LineHighlightPlotSlotProps } from "./LineHighli
|
|
|
14
15
|
import { ChartsGridProps } from "../ChartsGrid/index.js";
|
|
15
16
|
import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from "../ChartsOverlay/index.js";
|
|
16
17
|
import { LineChartPluginsSignatures } from "./LineChart.plugins.js";
|
|
17
|
-
|
|
18
|
-
export interface
|
|
18
|
+
import { ChartsToolbarSlots, ChartsToolbarSlotProps } from "../Toolbar/index.js";
|
|
19
|
+
export interface LineChartSlots extends ChartsAxisSlots, AreaPlotSlots, LinePlotSlots, MarkPlotSlots, LineHighlightPlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
|
|
20
|
+
export interface LineChartSlotProps extends ChartsAxisSlotProps, AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
|
|
19
21
|
export interface LineChartProps extends Omit<ChartContainerProps<'line', LineChartPluginsSignatures>, 'series' | 'plugins' | 'zAxis'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
|
|
20
22
|
/**
|
|
21
23
|
* The series to display in the line chart.
|
|
@@ -67,6 +69,11 @@ export interface LineChartProps extends Omit<ChartContainerProps<'line', LineCha
|
|
|
67
69
|
* @default false
|
|
68
70
|
*/
|
|
69
71
|
skipAnimation?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* If true, shows the default chart toolbar.
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
showToolbar?: boolean;
|
|
70
77
|
}
|
|
71
78
|
/**
|
|
72
79
|
* Demos:
|
|
@@ -4,6 +4,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { useThemeProps } from '@mui/material/styles';
|
|
7
|
+
import { ChartsToolbar } from "../Toolbar/internals/ChartsToolbar.js";
|
|
7
8
|
import { AreaPlot } from "./AreaPlot.js";
|
|
8
9
|
import { LinePlot } from "./LinePlot.js";
|
|
9
10
|
import { MarkPlot } from "./MarkPlot.js";
|
|
@@ -57,19 +58,21 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(inProps, ref)
|
|
|
57
58
|
chartsSurfaceProps
|
|
58
59
|
} = useChartContainerProps(chartContainerProps, ref);
|
|
59
60
|
const Tooltip = props.slots?.tooltip ?? ChartsTooltip;
|
|
61
|
+
const Toolbar = props.slots?.toolbar ?? ChartsToolbar;
|
|
60
62
|
return /*#__PURE__*/_jsx(ChartDataProvider, _extends({}, chartDataProviderProps, {
|
|
61
63
|
children: /*#__PURE__*/_jsxs(ChartsWrapper, _extends({}, chartsWrapperProps, {
|
|
62
|
-
children: [!props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
64
|
+
children: [props.showToolbar ? /*#__PURE__*/_jsx(Toolbar, {}) : null, !props.hideLegend && /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
63
65
|
children: [/*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
|
|
64
66
|
children: [/*#__PURE__*/_jsx(AreaPlot, _extends({}, areaPlotProps)), /*#__PURE__*/_jsx(LinePlot, _extends({}, linePlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
|
|
65
67
|
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx("g", {
|
|
66
68
|
"data-drawing-container": true,
|
|
67
69
|
children: /*#__PURE__*/_jsx(MarkPlot, _extends({}, markPlotProps))
|
|
68
|
-
}), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)),
|
|
69
|
-
}))]
|
|
70
|
+
}), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
|
|
71
|
+
})), !props.loading && /*#__PURE__*/_jsx(Tooltip, _extends({}, props.slotProps?.tooltip))]
|
|
70
72
|
}))
|
|
71
73
|
}));
|
|
72
74
|
});
|
|
75
|
+
if (process.env.NODE_ENV !== "production") LineChart.displayName = "LineChart";
|
|
73
76
|
process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
74
77
|
// ----------------------------- Warning --------------------------------
|
|
75
78
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -188,6 +191,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
188
191
|
* An array of [[LineSeriesType]] objects.
|
|
189
192
|
*/
|
|
190
193
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
194
|
+
/**
|
|
195
|
+
* If true, shows the default chart toolbar.
|
|
196
|
+
* @default false
|
|
197
|
+
*/
|
|
198
|
+
showToolbar: PropTypes.bool,
|
|
191
199
|
/**
|
|
192
200
|
* If `true`, animations are skipped.
|
|
193
201
|
* @default false
|
|
@@ -84,10 +84,7 @@ function LineHighlightPlot(props) {
|
|
|
84
84
|
const x = xScale(xData[highlightedIndex]);
|
|
85
85
|
const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
|
|
86
86
|
|
|
87
|
-
if (!instance.isPointInside({
|
|
88
|
-
x,
|
|
89
|
-
y
|
|
90
|
-
})) {
|
|
87
|
+
if (!instance.isPointInside(x, y)) {
|
|
91
88
|
return null;
|
|
92
89
|
}
|
|
93
90
|
const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "hideLegend", "grid", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className"];
|
|
5
|
+
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "onAreaClick", "onLineClick", "onMarkClick", "axisHighlight", "disableLineItemHighlight", "hideLegend", "grid", "children", "slots", "slotProps", "skipAnimation", "loading", "highlightedItem", "onHighlightChange", "className", "showToolbar"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import useId from '@mui/utils/useId';
|
|
8
8
|
import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
|