@mui/x-charts 8.4.0 → 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 +8 -1
- package/BarChart/useBarChartProps.js +1 -1
- package/CHANGELOG.md +103 -0
- package/ChartContainer/ChartContainer.d.ts +21 -2
- package/ChartContainer/ChartContainer.js +16 -0
- 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/LineChart/LineChart.d.ts +9 -2
- package/LineChart/LineChart.js +8 -1
- package/LineChart/useLineChartProps.js +1 -1
- package/PieChart/PieChart.d.ts +10 -3
- package/PieChart/PieChart.js +11 -3
- package/RadarChart/RadarChart.d.ts +21 -3
- package/RadarChart/RadarChart.js +17 -2
- 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/ScatterChart.d.ts +9 -2
- package/ScatterChart/ScatterChart.js +8 -1
- package/ScatterChart/useScatterChartProps.js +4 -2
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- 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 +24 -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/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 +8 -1
- package/esm/BarChart/useBarChartProps.js +1 -1
- package/esm/ChartContainer/ChartContainer.d.ts +21 -2
- package/esm/ChartContainer/ChartContainer.js +16 -0
- 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/LineChart/LineChart.d.ts +9 -2
- package/esm/LineChart/LineChart.js +8 -1
- package/esm/LineChart/useLineChartProps.js +1 -1
- package/esm/PieChart/PieChart.d.ts +10 -3
- package/esm/PieChart/PieChart.js +11 -3
- package/esm/RadarChart/RadarChart.d.ts +21 -3
- package/esm/RadarChart/RadarChart.js +17 -2
- 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/ScatterChart.d.ts +9 -2
- package/esm/ScatterChart/ScatterChart.js +8 -1
- package/esm/ScatterChart/useScatterChartProps.js +4 -2
- package/esm/SparkLineChart/SparkLineChart.d.ts +1 -1
- 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 +23 -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/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/index.js +1 -1
- package/esm/internals/constants.d.ts +3 -1
- package/esm/internals/constants.js +2 -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/featurePlugins/useChartCartesianAxis/computeAxisValue.js +2 -8
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +14 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +4 -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 +9 -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/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/index.js +1 -1
- package/internals/constants.d.ts +3 -1
- package/internals/constants.js +3 -2
- 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/featurePlugins/useChartCartesianAxis/computeAxisValue.js +5 -11
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +14 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +4 -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 +9 -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/models/index.d.ts +2 -2
- package/models/index.js +11 -0
- package/models/slots/chartsBaseSlotProps.d.ts +1 -0
- package/package.json +2 -2
package/Toolbar/index.js
CHANGED
|
@@ -24,4 +24,26 @@ Object.keys(_ToolbarButton).forEach(function (key) {
|
|
|
24
24
|
return _ToolbarButton[key];
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
+
});
|
|
28
|
+
var _Toolbar2 = require("./Toolbar.types");
|
|
29
|
+
Object.keys(_Toolbar2).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _Toolbar2[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _Toolbar2[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _chartToolbarClasses = require("./chartToolbarClasses");
|
|
40
|
+
Object.keys(_chartToolbarClasses).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _chartToolbarClasses[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _chartToolbarClasses[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
27
49
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ChartsToolbar = ChartsToolbar;
|
|
7
|
+
/**
|
|
8
|
+
* The chart toolbar component.
|
|
9
|
+
*
|
|
10
|
+
* In the community package, this component is empty and does not render anything.
|
|
11
|
+
*/
|
|
12
|
+
function ChartsToolbar() {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartsSlotProps, ChartsSlots } from "../internals/material/index.js";
|
|
3
|
+
type SlotProps<T extends Record<keyof T, React.ComponentType<any>>> = { [key in keyof T]: React.ComponentProps<T[key]> };
|
|
4
|
+
export interface ChartsSlotsContextValue<T extends ChartsSlots & Record<keyof T, React.ComponentType<any>> = ChartsSlots> {
|
|
5
|
+
slots: T;
|
|
6
|
+
slotProps: Partial<SlotProps<T>>;
|
|
7
|
+
}
|
|
8
|
+
export declare const ChartsSlotsContext: React.Context<ChartsSlotsContextValue<ChartsSlots> | null>;
|
|
9
|
+
/**
|
|
10
|
+
* Get the slots and slotProps from the nearest `ChartDataProvider` or `ChartDataProviderPro`.
|
|
11
|
+
* @returns {ChartsSlotsContextValue} The slots and slotProps from the context.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useChartsSlots<T extends ChartsSlots & Record<keyof T, React.ComponentType<any>> = ChartsSlots>(): ChartsSlotsContextValue<T>;
|
|
14
|
+
interface ChartsSlotsProviderProps {
|
|
15
|
+
slots?: Partial<ChartsSlots>;
|
|
16
|
+
slotProps?: Partial<ChartsSlotProps>;
|
|
17
|
+
defaultSlots: ChartsSlots;
|
|
18
|
+
}
|
|
19
|
+
export declare function ChartsSlotsProvider(props: React.PropsWithChildren<ChartsSlotsProviderProps>): React.JSX.Element;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.ChartsSlotsContext = void 0;
|
|
10
|
+
exports.ChartsSlotsProvider = ChartsSlotsProvider;
|
|
11
|
+
exports.useChartsSlots = useChartsSlots;
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
var React = _interopRequireWildcard(require("react"));
|
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
const ChartsSlotsContext = exports.ChartsSlotsContext = /*#__PURE__*/React.createContext(null);
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get the slots and slotProps from the nearest `ChartDataProvider` or `ChartDataProviderPro`.
|
|
19
|
+
* @returns {ChartsSlotsContextValue} The slots and slotProps from the context.
|
|
20
|
+
*/
|
|
21
|
+
if (process.env.NODE_ENV !== "production") ChartsSlotsContext.displayName = "ChartsSlotsContext";
|
|
22
|
+
function useChartsSlots() {
|
|
23
|
+
const context = React.useContext(ChartsSlotsContext);
|
|
24
|
+
if (context == null) {
|
|
25
|
+
throw new Error(['MUI X Charts: Could not find the Charts Slots context.', 'It looks like you rendered your component outside of a ChartDataProvider.', 'This can also happen if you are bundling multiple versions of the library.'].join('\n'));
|
|
26
|
+
}
|
|
27
|
+
return context;
|
|
28
|
+
}
|
|
29
|
+
function ChartsSlotsProvider(props) {
|
|
30
|
+
const {
|
|
31
|
+
slots,
|
|
32
|
+
slotProps = {},
|
|
33
|
+
defaultSlots,
|
|
34
|
+
children
|
|
35
|
+
} = props;
|
|
36
|
+
const value = React.useMemo(() => ({
|
|
37
|
+
slots: (0, _extends2.default)({}, defaultSlots, slots),
|
|
38
|
+
slotProps
|
|
39
|
+
}), [defaultSlots, slots, slotProps]);
|
|
40
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsSlotsContext.Provider, {
|
|
41
|
+
value: value,
|
|
42
|
+
children: children
|
|
43
|
+
});
|
|
44
|
+
}
|
package/context/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export type { HighlightScope, FadeOptions, HighlightItemData, HighlightOptions } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
|
|
1
|
+
export type { HighlightScope, FadeOptions, HighlightItemData, HighlightOptions } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
|
|
2
|
+
export * from "./useChartApiContext.js";
|
package/context/index.js
CHANGED
|
@@ -2,4 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
+
});
|
|
6
|
+
var _useChartApiContext = require("./useChartApiContext");
|
|
7
|
+
Object.keys(_useChartApiContext).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _useChartApiContext[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _useChartApiContext[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
5
16
|
});
|
|
@@ -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,9 +53,10 @@ 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
62
|
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
|
|
@@ -189,6 +191,11 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
189
191
|
* An array of [[BarSeriesType]] objects.
|
|
190
192
|
*/
|
|
191
193
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
194
|
+
/**
|
|
195
|
+
* If true, shows the default chart toolbar.
|
|
196
|
+
* @default false
|
|
197
|
+
*/
|
|
198
|
+
showToolbar: PropTypes.bool,
|
|
192
199
|
/**
|
|
193
200
|
* If `true`, animations are skipped.
|
|
194
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.
|
|
@@ -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
|
};
|
|
@@ -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,9 +58,10 @@ 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", {
|
|
@@ -189,6 +191,11 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
189
191
|
* An array of [[LineSeriesType]] objects.
|
|
190
192
|
*/
|
|
191
193
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
194
|
+
/**
|
|
195
|
+
* If true, shows the default chart toolbar.
|
|
196
|
+
* @default false
|
|
197
|
+
*/
|
|
198
|
+
showToolbar: PropTypes.bool,
|
|
192
199
|
/**
|
|
193
200
|
* If `true`, animations are skipped.
|
|
194
201
|
* @default false
|
|
@@ -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";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { MakeOptional } from '@mui/x-internals/types';
|
|
3
|
+
import { ChartsToolbarSlotProps, ChartsToolbarSlots } from "../Toolbar/index.js";
|
|
4
|
+
import { ChartsSlotProps, ChartsSlots } from "../internals/material/index.js";
|
|
3
5
|
import { ChartContainerProps } from "../ChartContainer/index.js";
|
|
4
6
|
import { PieSeriesType } from "../models/seriesType/index.js";
|
|
5
7
|
import { ChartsTooltipSlots, ChartsTooltipSlotProps } from "../ChartsTooltip/ChartTooltip.types.js";
|
|
@@ -8,9 +10,9 @@ import { PiePlotProps, PiePlotSlotProps, PiePlotSlots } from "./PiePlot.js";
|
|
|
8
10
|
import { PieValueType } from "../models/seriesType/pie.js";
|
|
9
11
|
import { ChartsOverlayProps, ChartsOverlaySlotProps, ChartsOverlaySlots } from "../ChartsOverlay/index.js";
|
|
10
12
|
import { PieChartPluginSignatures } from "./PieChart.plugins.js";
|
|
11
|
-
export interface PieChartSlots extends PiePlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots {}
|
|
12
|
-
export interface PieChartSlotProps extends PiePlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps {}
|
|
13
|
-
export interface PieChartProps extends Omit<ChartContainerProps<'pie', PieChartPluginSignatures>, 'series'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<PiePlotProps, 'skipAnimation'> {
|
|
13
|
+
export interface PieChartSlots extends PiePlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
|
|
14
|
+
export interface PieChartSlotProps extends PiePlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
|
|
15
|
+
export interface PieChartProps extends Omit<ChartContainerProps<'pie', PieChartPluginSignatures>, 'series' | 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'>, Pick<PiePlotProps, 'skipAnimation'> {
|
|
14
16
|
/**
|
|
15
17
|
* The series to display in the pie chart.
|
|
16
18
|
* An array of [[PieSeriesType]] objects.
|
|
@@ -24,6 +26,11 @@ export interface PieChartProps extends Omit<ChartContainerProps<'pie', PieChartP
|
|
|
24
26
|
* Callback fired when a pie arc is clicked.
|
|
25
27
|
*/
|
|
26
28
|
onItemClick?: PiePlotProps['onItemClick'];
|
|
29
|
+
/**
|
|
30
|
+
* If true, shows the default chart toolbar.
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
showToolbar?: boolean;
|
|
27
34
|
/**
|
|
28
35
|
* Overridable component slots.
|
|
29
36
|
* @default {}
|
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
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 = ["series", "width", "height", "margin", "colors", "sx", "skipAnimation", "hideLegend", "children", "slots", "slotProps", "onItemClick", "loading", "highlightedItem", "onHighlightChange", "className"];
|
|
5
|
+
const _excluded = ["series", "width", "height", "margin", "colors", "sx", "skipAnimation", "hideLegend", "children", "slots", "slotProps", "onItemClick", "loading", "highlightedItem", "onHighlightChange", "className", "showToolbar"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { useThemeProps } from '@mui/material/styles';
|
|
9
|
+
import { ChartsToolbar } from "../Toolbar/internals/ChartsToolbar.js";
|
|
9
10
|
import { ChartsTooltip } from "../ChartsTooltip/index.js";
|
|
10
11
|
import { ChartsLegend } from "../ChartsLegend/index.js";
|
|
11
12
|
import { PiePlot } from "./PiePlot.js";
|
|
@@ -55,7 +56,8 @@ const PieChart = /*#__PURE__*/React.forwardRef(function PieChart(inProps, ref) {
|
|
|
55
56
|
loading,
|
|
56
57
|
highlightedItem,
|
|
57
58
|
onHighlightChange,
|
|
58
|
-
className
|
|
59
|
+
className,
|
|
60
|
+
showToolbar
|
|
59
61
|
} = props,
|
|
60
62
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
61
63
|
const margin = defaultizeMargin(marginProps, defaultMargin);
|
|
@@ -77,12 +79,13 @@ const PieChart = /*#__PURE__*/React.forwardRef(function PieChart(inProps, ref) {
|
|
|
77
79
|
plugins: PIE_CHART_PLUGINS
|
|
78
80
|
}), ref);
|
|
79
81
|
const Tooltip = slots?.tooltip ?? ChartsTooltip;
|
|
82
|
+
const Toolbar = props.slots?.toolbar ?? ChartsToolbar;
|
|
80
83
|
return /*#__PURE__*/_jsx(ChartDataProvider, _extends({}, chartDataProviderProps, {
|
|
81
84
|
children: /*#__PURE__*/_jsxs(ChartsWrapper, {
|
|
82
85
|
legendPosition: props.slotProps?.legend?.position,
|
|
83
86
|
legendDirection: props?.slotProps?.legend?.direction ?? 'vertical',
|
|
84
87
|
sx: sx,
|
|
85
|
-
children: [!hideLegend && /*#__PURE__*/_jsx(ChartsLegend, {
|
|
88
|
+
children: [showToolbar ? /*#__PURE__*/_jsx(Toolbar, {}) : null, !hideLegend && /*#__PURE__*/_jsx(ChartsLegend, {
|
|
86
89
|
direction: props?.slotProps?.legend?.direction ?? 'vertical',
|
|
87
90
|
slots: slots,
|
|
88
91
|
slotProps: slotProps
|
|
@@ -180,6 +183,11 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
180
183
|
* An array of [[PieSeriesType]] objects.
|
|
181
184
|
*/
|
|
182
185
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
186
|
+
/**
|
|
187
|
+
* If true, shows the default chart toolbar.
|
|
188
|
+
* @default false
|
|
189
|
+
*/
|
|
190
|
+
showToolbar: PropTypes.bool,
|
|
183
191
|
/**
|
|
184
192
|
* If `true`, animations are skipped.
|
|
185
193
|
* If unset or `false`, the animations respects the user's `prefers-reduced-motion` setting.
|