@mui/x-charts 7.6.0 → 7.6.2
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 +1 -1
- package/BarChart/BarChart.js +2 -2
- package/BarChart/BarPlot.js +2 -2
- package/BarChart/formatter.js +2 -2
- package/BarChart/getColor.d.ts +1 -1
- package/BarChart/getColor.js +4 -4
- package/BarChart/plugin.d.ts +2 -0
- package/BarChart/plugin.js +17 -0
- package/CHANGELOG.md +91 -0
- package/ChartContainer/ChartContainer.d.ts +14 -2
- package/ChartContainer/ChartContainer.js +13 -2
- package/ChartContainer/defaultPlugins.d.ts +2 -0
- package/ChartContainer/defaultPlugins.js +11 -0
- package/ChartContainer/usePluginsMerge.d.ts +10 -0
- package/ChartContainer/usePluginsMerge.js +39 -0
- package/ChartsLegend/ChartsLegend.js +2 -2
- package/ChartsLegend/utils.js +4 -1
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
- package/ChartsTooltip/ChartsAxisTooltipContent.js +4 -4
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -1
- package/ChartsTooltip/utils.d.ts +1 -7
- package/ChartsTooltip/utils.js +2 -10
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/ChartsXAxis/ChartsXAxis.js +17 -19
- package/ChartsYAxis/ChartsYAxis.js +17 -19
- package/LineChart/AreaPlot.js +2 -2
- package/LineChart/LineChart.d.ts +1 -1
- package/LineChart/LineChart.js +2 -2
- package/LineChart/LineHighlightPlot.js +2 -2
- package/LineChart/LinePlot.js +2 -2
- package/LineChart/MarkPlot.js +2 -2
- package/LineChart/formatter.js +2 -2
- package/LineChart/getColor.d.ts +1 -1
- package/LineChart/getColor.js +2 -2
- package/LineChart/plugin.d.ts +2 -0
- package/LineChart/plugin.js +17 -0
- package/PieChart/PieChart.d.ts +1 -1
- package/PieChart/PieChart.js +2 -2
- package/PieChart/PiePlot.js +2 -2
- package/PieChart/plugin.d.ts +2 -0
- package/PieChart/plugin.js +14 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -2
- package/ScatterChart/ScatterChart.d.ts +1 -1
- package/ScatterChart/ScatterChart.js +2 -2
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/formatter.js +2 -3
- package/ScatterChart/getColor.d.ts +1 -1
- package/ScatterChart/getColor.js +2 -2
- package/ScatterChart/plugin.d.ts +2 -0
- package/ScatterChart/plugin.js +17 -0
- package/SparkLineChart/SparkLineChart.d.ts +3 -3
- package/SparkLineChart/SparkLineChart.js +1 -1
- package/context/CartesianContextProvider.d.ts +13 -10
- package/context/CartesianContextProvider.js +2 -2
- package/context/DrawingProvider.d.ts +3 -1
- package/context/DrawingProvider.js +9 -2
- package/context/HighlightedProvider/HighlightedContext.d.ts +2 -1
- package/context/HighlightedProvider/HighlightedContext.js +8 -5
- package/context/HighlightedProvider/HighlightedProvider.js +15 -12
- package/context/HighlightedProvider/useHighlighted.js +6 -3
- package/context/HighlightedProvider/useItemHighlighted.js +2 -8
- package/context/SeriesContextProvider.d.ts +16 -5
- package/context/SeriesContextProvider.js +14 -17
- package/context/context.types.d.ts +4 -0
- package/context/context.types.js +5 -0
- package/esm/BarChart/BarChart.js +2 -2
- package/esm/BarChart/BarPlot.js +2 -2
- package/esm/BarChart/formatter.js +1 -1
- package/esm/BarChart/getColor.js +4 -4
- package/esm/BarChart/plugin.js +10 -0
- package/esm/ChartContainer/ChartContainer.js +13 -2
- package/esm/ChartContainer/defaultPlugins.js +5 -0
- package/esm/ChartContainer/usePluginsMerge.js +31 -0
- package/esm/ChartsLegend/ChartsLegend.js +2 -2
- package/esm/ChartsLegend/utils.js +4 -1
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -1
- package/esm/ChartsTooltip/utils.js +2 -8
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/esm/ChartsXAxis/ChartsXAxis.js +17 -19
- package/esm/ChartsYAxis/ChartsYAxis.js +17 -19
- package/esm/LineChart/AreaPlot.js +2 -2
- package/esm/LineChart/LineChart.js +2 -2
- package/esm/LineChart/LineHighlightPlot.js +2 -2
- package/esm/LineChart/LinePlot.js +2 -2
- package/esm/LineChart/MarkPlot.js +2 -2
- package/esm/LineChart/formatter.js +1 -1
- package/esm/LineChart/getColor.js +2 -2
- package/esm/LineChart/plugin.js +10 -0
- package/esm/PieChart/PieChart.js +2 -2
- package/esm/PieChart/PiePlot.js +2 -2
- package/esm/PieChart/plugin.js +7 -0
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -2
- package/esm/ScatterChart/ScatterChart.js +2 -2
- package/esm/ScatterChart/ScatterPlot.js +2 -2
- package/esm/ScatterChart/formatter.js +1 -1
- package/esm/ScatterChart/getColor.js +2 -2
- package/esm/ScatterChart/plugin.js +10 -0
- package/esm/SparkLineChart/SparkLineChart.js +1 -1
- package/esm/context/CartesianContextProvider.js +2 -2
- package/esm/context/DrawingProvider.js +9 -2
- package/esm/context/HighlightedProvider/HighlightedContext.js +8 -5
- package/esm/context/HighlightedProvider/HighlightedProvider.js +15 -12
- package/esm/context/HighlightedProvider/useHighlighted.js +6 -3
- package/esm/context/HighlightedProvider/useItemHighlighted.js +2 -6
- package/esm/context/SeriesContextProvider.js +14 -17
- package/esm/context/context.types.js +1 -0
- package/esm/hooks/useInteractionItemProps.js +2 -2
- package/esm/hooks/useSeries.js +6 -3
- package/esm/hooks/useSvgRef.js +6 -3
- package/esm/internals/configInit.js +20 -0
- package/esm/internals/defaultizeValueFormatter.js +2 -3
- package/esm/internals/index.js +1 -0
- package/esm/internals/isCartesian.js +7 -0
- package/esm/models/index.js +1 -0
- package/esm/models/plugin.js +1 -0
- package/esm/models/seriesType/index.js +6 -0
- package/hooks/useInteractionItemProps.js +1 -1
- package/hooks/useSeries.d.ts +6 -11
- package/hooks/useSeries.js +6 -3
- package/hooks/useSvgRef.js +6 -3
- package/hooks/useTicks.d.ts +4 -2
- package/index.js +1 -1
- package/internals/configInit.d.ts +9 -0
- package/internals/configInit.js +26 -0
- package/internals/defaultizeValueFormatter.d.ts +1 -2
- package/internals/defaultizeValueFormatter.js +2 -3
- package/internals/index.d.ts +1 -0
- package/internals/index.js +16 -0
- package/internals/isCartesian.d.ts +7 -0
- package/internals/isCartesian.js +14 -0
- package/internals/package.json +6 -0
- package/models/axis.d.ts +3 -3
- package/models/index.d.ts +1 -0
- package/models/index.js +11 -0
- package/models/plugin.d.ts +16 -0
- package/models/plugin.js +5 -0
- package/models/seriesType/config.d.ts +30 -5
- package/models/seriesType/index.d.ts +8 -11
- package/models/seriesType/index.js +6 -0
- package/modern/BarChart/BarChart.js +2 -2
- package/modern/BarChart/BarPlot.js +2 -2
- package/modern/BarChart/formatter.js +1 -1
- package/modern/BarChart/getColor.js +4 -4
- package/modern/BarChart/plugin.js +10 -0
- package/modern/ChartContainer/ChartContainer.js +13 -2
- package/modern/ChartContainer/defaultPlugins.js +5 -0
- package/modern/ChartContainer/usePluginsMerge.js +31 -0
- package/modern/ChartsLegend/ChartsLegend.js +2 -2
- package/modern/ChartsLegend/utils.js +4 -1
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +4 -4
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +3 -3
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +2 -1
- package/modern/ChartsTooltip/utils.js +2 -8
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +2 -2
- package/modern/ChartsXAxis/ChartsXAxis.js +17 -19
- package/modern/ChartsYAxis/ChartsYAxis.js +17 -19
- package/modern/LineChart/AreaPlot.js +2 -2
- package/modern/LineChart/LineChart.js +2 -2
- package/modern/LineChart/LineHighlightPlot.js +2 -2
- package/modern/LineChart/LinePlot.js +2 -2
- package/modern/LineChart/MarkPlot.js +2 -2
- package/modern/LineChart/formatter.js +1 -1
- package/modern/LineChart/getColor.js +2 -2
- package/modern/LineChart/plugin.js +10 -0
- package/modern/PieChart/PieChart.js +2 -2
- package/modern/PieChart/PiePlot.js +2 -2
- package/modern/PieChart/plugin.js +7 -0
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +7 -2
- package/modern/ScatterChart/ScatterChart.js +2 -2
- package/modern/ScatterChart/ScatterPlot.js +2 -2
- package/modern/ScatterChart/formatter.js +1 -1
- package/modern/ScatterChart/getColor.js +2 -2
- package/modern/ScatterChart/plugin.js +10 -0
- package/modern/SparkLineChart/SparkLineChart.js +1 -1
- package/modern/context/CartesianContextProvider.js +2 -2
- package/modern/context/DrawingProvider.js +9 -2
- package/modern/context/HighlightedProvider/HighlightedContext.js +8 -5
- package/modern/context/HighlightedProvider/HighlightedProvider.js +15 -12
- package/modern/context/HighlightedProvider/useHighlighted.js +6 -3
- package/modern/context/HighlightedProvider/useItemHighlighted.js +2 -6
- package/modern/context/SeriesContextProvider.js +14 -17
- package/modern/context/context.types.js +1 -0
- package/modern/hooks/useInteractionItemProps.js +2 -2
- package/modern/hooks/useSeries.js +6 -3
- package/modern/hooks/useSvgRef.js +6 -3
- package/modern/index.js +1 -1
- package/modern/internals/configInit.js +20 -0
- package/modern/internals/defaultizeValueFormatter.js +2 -3
- package/modern/internals/index.js +1 -0
- package/modern/internals/isCartesian.js +7 -0
- package/modern/models/index.js +1 -0
- package/modern/models/plugin.js +1 -0
- package/modern/models/seriesType/index.js +6 -0
- package/package.json +1 -1
|
@@ -1,24 +1,16 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { useTheme } from '@mui/material/styles';
|
|
4
|
-
import barSeriesFormatter from '../BarChart/formatter';
|
|
5
|
-
import scatterSeriesFormatter from '../ScatterChart/formatter';
|
|
6
|
-
import lineSeriesFormatter from '../LineChart/formatter';
|
|
7
|
-
import pieSeriesFormatter from '../PieChart/formatter';
|
|
8
4
|
import { defaultizeColor } from '../internals/defaultizeColor';
|
|
9
5
|
import { blueberryTwilightPalette } from '../colorPalettes';
|
|
10
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
export const SeriesContext = /*#__PURE__*/React.createContext({
|
|
7
|
+
export const SeriesContext = /*#__PURE__*/React.createContext({
|
|
8
|
+
isInitialized: false,
|
|
9
|
+
data: {}
|
|
10
|
+
});
|
|
12
11
|
if (process.env.NODE_ENV !== 'production') {
|
|
13
12
|
SeriesContext.displayName = 'SeriesContext';
|
|
14
13
|
}
|
|
15
|
-
const seriesTypeFormatter = {
|
|
16
|
-
bar: barSeriesFormatter,
|
|
17
|
-
scatter: scatterSeriesFormatter,
|
|
18
|
-
line: lineSeriesFormatter,
|
|
19
|
-
pie: pieSeriesFormatter
|
|
20
|
-
};
|
|
21
|
-
|
|
22
14
|
/**
|
|
23
15
|
* This methods is the interface between what the developer is providing and what components receives
|
|
24
16
|
* To simplify the components behaviors, it groups series by type, such that LinePlots props are not updated if some line data are modified
|
|
@@ -27,7 +19,7 @@ const seriesTypeFormatter = {
|
|
|
27
19
|
* @param colors The color palette used to defaultize series colors
|
|
28
20
|
* @returns An object structuring all the series by type.
|
|
29
21
|
*/
|
|
30
|
-
const
|
|
22
|
+
const preprocessSeries = (series, colors, seriesFormatters, dataset) => {
|
|
31
23
|
// Group series by type
|
|
32
24
|
const seriesGroups = {};
|
|
33
25
|
series.forEach((seriesData, seriesIndex) => {
|
|
@@ -51,9 +43,10 @@ const formatSeries = (series, colors, dataset) => {
|
|
|
51
43
|
});
|
|
52
44
|
const formattedSeries = {};
|
|
53
45
|
// Apply formatter on a type group
|
|
54
|
-
Object.keys(
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
Object.keys(seriesFormatters).forEach(type => {
|
|
47
|
+
const group = seriesGroups[type];
|
|
48
|
+
if (group !== undefined) {
|
|
49
|
+
formattedSeries[type] = seriesFormatters[type]?.(group, dataset) ?? seriesGroups[type];
|
|
57
50
|
}
|
|
58
51
|
});
|
|
59
52
|
return formattedSeries;
|
|
@@ -63,10 +56,14 @@ function SeriesContextProvider(props) {
|
|
|
63
56
|
series,
|
|
64
57
|
dataset,
|
|
65
58
|
colors = blueberryTwilightPalette,
|
|
59
|
+
seriesFormatters,
|
|
66
60
|
children
|
|
67
61
|
} = props;
|
|
68
62
|
const theme = useTheme();
|
|
69
|
-
const formattedSeries = React.useMemo(() =>
|
|
63
|
+
const formattedSeries = React.useMemo(() => ({
|
|
64
|
+
isInitialized: true,
|
|
65
|
+
data: preprocessSeries(series, typeof colors === 'function' ? colors(theme.palette.mode) : colors, seriesFormatters, dataset)
|
|
66
|
+
}), [series, colors, theme.palette.mode, seriesFormatters, dataset]);
|
|
70
67
|
return /*#__PURE__*/_jsx(SeriesContext.Provider, {
|
|
71
68
|
value: formattedSeries,
|
|
72
69
|
children: children
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
3
|
-
import {
|
|
3
|
+
import { useHighlighted } from '../context';
|
|
4
4
|
export const useInteractionItemProps = skip => {
|
|
5
5
|
const {
|
|
6
6
|
dispatch: dispatchInteraction
|
|
@@ -8,7 +8,7 @@ export const useInteractionItemProps = skip => {
|
|
|
8
8
|
const {
|
|
9
9
|
setHighlighted,
|
|
10
10
|
clearHighlighted
|
|
11
|
-
} =
|
|
11
|
+
} = useHighlighted();
|
|
12
12
|
if (skip) {
|
|
13
13
|
return () => ({});
|
|
14
14
|
}
|
package/esm/hooks/useSeries.js
CHANGED
|
@@ -8,11 +8,14 @@ import { SeriesContext } from '../context/SeriesContextProvider';
|
|
|
8
8
|
* @returns FormattedSeries series
|
|
9
9
|
*/
|
|
10
10
|
export function useSeries() {
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const {
|
|
12
|
+
isInitialized,
|
|
13
|
+
data
|
|
14
|
+
} = React.useContext(SeriesContext);
|
|
15
|
+
if (!isInitialized) {
|
|
13
16
|
throw new Error(['MUI X: Could not find the series ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
14
17
|
}
|
|
15
|
-
return
|
|
18
|
+
return data;
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
/**
|
package/esm/hooks/useSvgRef.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SvgContext } from '../context/DrawingProvider';
|
|
3
3
|
export function useSvgRef() {
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const {
|
|
5
|
+
isInitialized,
|
|
6
|
+
data
|
|
7
|
+
} = React.useContext(SvgContext);
|
|
8
|
+
if (!isInitialized) {
|
|
6
9
|
throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
7
10
|
}
|
|
8
|
-
return
|
|
11
|
+
return data;
|
|
9
12
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
let instance;
|
|
2
|
+
class CartesianSeriesTypes {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.types = new Set();
|
|
5
|
+
if (instance) {
|
|
6
|
+
throw new Error('You can only create one instance!');
|
|
7
|
+
}
|
|
8
|
+
instance = this.types;
|
|
9
|
+
}
|
|
10
|
+
addType(value) {
|
|
11
|
+
this.types.add(value);
|
|
12
|
+
}
|
|
13
|
+
getTypes() {
|
|
14
|
+
return this.types;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export const cartesianSeriesTypes = new CartesianSeriesTypes();
|
|
18
|
+
cartesianSeriesTypes.addType('bar');
|
|
19
|
+
cartesianSeriesTypes.addType('line');
|
|
20
|
+
cartesianSeriesTypes.addType('scatter');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
function defaultizeValueFormatter(series, defaultValueFormatter) {
|
|
2
|
+
export function defaultizeValueFormatter(series, defaultValueFormatter) {
|
|
3
3
|
const defaultizedSeries = {};
|
|
4
4
|
Object.keys(series).forEach(seriesId => {
|
|
5
5
|
defaultizedSeries[seriesId] = _extends({}, series[seriesId], {
|
|
@@ -7,5 +7,4 @@ function defaultizeValueFormatter(series, defaultValueFormatter) {
|
|
|
7
7
|
});
|
|
8
8
|
});
|
|
9
9
|
return defaultizedSeries;
|
|
10
|
-
}
|
|
11
|
-
export default defaultizeValueFormatter;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './configInit';
|
package/esm/models/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
// Series definition
|
|
2
|
+
|
|
3
|
+
// item identifier
|
|
4
|
+
|
|
1
5
|
export * from './line';
|
|
2
6
|
export * from './bar';
|
|
3
7
|
export * from './scatter';
|
|
4
8
|
export * from './pie';
|
|
9
|
+
// Helpers
|
|
10
|
+
|
|
5
11
|
export function isDefaultizedBarSeries(series) {
|
|
6
12
|
return series.type === 'bar';
|
|
7
13
|
}
|
package/hooks/useSeries.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { FormattedSeries } from '../context/SeriesContextProvider';
|
|
1
2
|
/**
|
|
2
3
|
* Get access to the internal state of series.
|
|
3
4
|
* Structured by type of series:
|
|
4
5
|
* { seriesType?: { series: { id1: precessedValue, ... }, seriesOrder: [id1, ...] } }
|
|
5
6
|
* @returns FormattedSeries series
|
|
6
7
|
*/
|
|
7
|
-
export declare function useSeries():
|
|
8
|
+
export declare function useSeries(): FormattedSeries;
|
|
8
9
|
/**
|
|
9
10
|
* Get access to the internal state of pie series.
|
|
10
11
|
* The returned object contains:
|
|
@@ -12,10 +13,7 @@ export declare function useSeries(): import("../context/SeriesContextProvider").
|
|
|
12
13
|
* - seriesOrder: the array of series ids.
|
|
13
14
|
* @returns { series: Record<SeriesId, DefaultizedPieSeriesType>; seriesOrder: SeriesId[]; } | undefined pieSeries
|
|
14
15
|
*/
|
|
15
|
-
export declare function usePieSeries():
|
|
16
|
-
series: Record<import("../models/seriesType/common").SeriesId, import("..").DefaultizedPieSeriesType>;
|
|
17
|
-
seriesOrder: import("../models/seriesType/common").SeriesId[];
|
|
18
|
-
} | undefined;
|
|
16
|
+
export declare function usePieSeries(): FormattedSeries['pie'];
|
|
19
17
|
/**
|
|
20
18
|
* Get access to the internal state of line series.
|
|
21
19
|
* The returned object contains:
|
|
@@ -23,7 +21,7 @@ export declare function usePieSeries(): {
|
|
|
23
21
|
* - seriesOrder: the array of series ids.
|
|
24
22
|
* @returns { series: Record<SeriesId, DefaultizedLineSeriesType>; seriesOrder: SeriesId[]; } | undefined lineSeries
|
|
25
23
|
*/
|
|
26
|
-
export declare function useLineSeries():
|
|
24
|
+
export declare function useLineSeries(): FormattedSeries['line'];
|
|
27
25
|
/**
|
|
28
26
|
* Get access to the internal state of bar series.
|
|
29
27
|
* The returned object contains:
|
|
@@ -31,7 +29,7 @@ export declare function useLineSeries(): import("../models/seriesType/config").F
|
|
|
31
29
|
* - seriesOrder: the array of series ids.
|
|
32
30
|
* @returns { series: Record<SeriesId, DefaultizedBarSeriesType>; seriesOrder: SeriesId[]; } | undefined barSeries
|
|
33
31
|
*/
|
|
34
|
-
export declare function useBarSeries():
|
|
32
|
+
export declare function useBarSeries(): FormattedSeries['bar'];
|
|
35
33
|
/**
|
|
36
34
|
* Get access to the internal state of scatter series.
|
|
37
35
|
* The returned object contains:
|
|
@@ -39,7 +37,4 @@ export declare function useBarSeries(): import("../models/seriesType/config").Fo
|
|
|
39
37
|
* - seriesOrder: the array of series ids.
|
|
40
38
|
* @returns { series: Record<SeriesId, DefaultizedScatterSeriesType>; seriesOrder: SeriesId[]; } | undefined scatterSeries
|
|
41
39
|
*/
|
|
42
|
-
export declare function useScatterSeries():
|
|
43
|
-
series: Record<import("../models/seriesType/common").SeriesId, import("..").DefaultizedScatterSeriesType>;
|
|
44
|
-
seriesOrder: import("../models/seriesType/common").SeriesId[];
|
|
45
|
-
} | undefined;
|
|
40
|
+
export declare function useScatterSeries(): FormattedSeries['scatter'];
|
package/hooks/useSeries.js
CHANGED
|
@@ -19,11 +19,14 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
19
19
|
* @returns FormattedSeries series
|
|
20
20
|
*/
|
|
21
21
|
function useSeries() {
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
const {
|
|
23
|
+
isInitialized,
|
|
24
|
+
data
|
|
25
|
+
} = React.useContext(_SeriesContextProvider.SeriesContext);
|
|
26
|
+
if (!isInitialized) {
|
|
24
27
|
throw new Error(['MUI X: Could not find the series ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
25
28
|
}
|
|
26
|
-
return
|
|
29
|
+
return data;
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
/**
|
package/hooks/useSvgRef.js
CHANGED
|
@@ -9,9 +9,12 @@ var _DrawingProvider = require("../context/DrawingProvider");
|
|
|
9
9
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
10
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
11
|
function useSvgRef() {
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const {
|
|
13
|
+
isInitialized,
|
|
14
|
+
data
|
|
15
|
+
} = React.useContext(_DrawingProvider.SvgContext);
|
|
16
|
+
if (!isInitialized) {
|
|
14
17
|
throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
|
|
15
18
|
}
|
|
16
|
-
return
|
|
19
|
+
return data;
|
|
17
20
|
}
|
package/hooks/useTicks.d.ts
CHANGED
|
@@ -18,10 +18,12 @@ export interface TickParams {
|
|
|
18
18
|
*/
|
|
19
19
|
tickNumber?: number;
|
|
20
20
|
/**
|
|
21
|
-
* Defines which ticks are displayed.
|
|
21
|
+
* Defines which ticks are displayed.
|
|
22
|
+
* Its value can be:
|
|
22
23
|
* - 'auto' In such case the ticks are computed based on axis scale and other parameters.
|
|
23
|
-
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has
|
|
24
|
+
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has "point" scale.
|
|
24
25
|
* - an array containing the values where ticks should be displayed.
|
|
26
|
+
* @see See {@link https://mui.com/x/react-charts/axis/#fixed-tick-positions}
|
|
25
27
|
* @default 'auto'
|
|
26
28
|
*/
|
|
27
29
|
tickInterval?: 'auto' | ((value: any, index: number) => boolean) | any[];
|
package/index.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ChartSeriesType } from '../models/seriesType/config';
|
|
2
|
+
declare class CartesianSeriesTypes {
|
|
3
|
+
types: Set<ChartSeriesType>;
|
|
4
|
+
constructor();
|
|
5
|
+
addType(value: ChartSeriesType): void;
|
|
6
|
+
getTypes(): Set<keyof import("../models/seriesType/config").ChartsSeriesConfig>;
|
|
7
|
+
}
|
|
8
|
+
export declare const cartesianSeriesTypes: CartesianSeriesTypes;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cartesianSeriesTypes = void 0;
|
|
7
|
+
let instance;
|
|
8
|
+
class CartesianSeriesTypes {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.types = new Set();
|
|
11
|
+
if (instance) {
|
|
12
|
+
throw new Error('You can only create one instance!');
|
|
13
|
+
}
|
|
14
|
+
instance = this.types;
|
|
15
|
+
}
|
|
16
|
+
addType(value) {
|
|
17
|
+
this.types.add(value);
|
|
18
|
+
}
|
|
19
|
+
getTypes() {
|
|
20
|
+
return this.types;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const cartesianSeriesTypes = exports.cartesianSeriesTypes = new CartesianSeriesTypes();
|
|
24
|
+
cartesianSeriesTypes.addType('bar');
|
|
25
|
+
cartesianSeriesTypes.addType('line');
|
|
26
|
+
cartesianSeriesTypes.addType('scatter');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SeriesId, SeriesValueFormatter } from '../models/seriesType/common';
|
|
2
|
-
declare function defaultizeValueFormatter<TValue, ISeries extends {
|
|
2
|
+
export declare function defaultizeValueFormatter<TValue, ISeries extends {
|
|
3
3
|
valueFormatter?: SeriesValueFormatter<TValue>;
|
|
4
4
|
}>(series: Record<SeriesId, ISeries>, defaultValueFormatter: SeriesValueFormatter<TValue>): Record<SeriesId, ISeries & {
|
|
5
5
|
valueFormatter: SeriesValueFormatter<TValue>;
|
|
6
6
|
}>;
|
|
7
|
-
export default defaultizeValueFormatter;
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.defaultizeValueFormatter = defaultizeValueFormatter;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
function defaultizeValueFormatter(series, defaultValueFormatter) {
|
|
10
10
|
const defaultizedSeries = {};
|
|
@@ -14,5 +14,4 @@ function defaultizeValueFormatter(series, defaultValueFormatter) {
|
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
return defaultizedSeries;
|
|
17
|
-
}
|
|
18
|
-
var _default = exports.default = defaultizeValueFormatter;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './configInit';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _configInit = require("./configInit");
|
|
7
|
+
Object.keys(_configInit).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _configInit[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _configInit[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ChartSeriesType, CartesianChartSeriesType, ChartSeriesDefaultized } from '../models/seriesType/config';
|
|
2
|
+
export declare function isCartesianSeriesType(seriesType: string): seriesType is CartesianChartSeriesType;
|
|
3
|
+
export declare function isCartesianSeries(series: ChartSeriesDefaultized<ChartSeriesType> & {
|
|
4
|
+
getColor: (dataIndex: number) => string;
|
|
5
|
+
}): series is ChartSeriesDefaultized<CartesianChartSeriesType> & {
|
|
6
|
+
getColor: (dataIndex: number) => string;
|
|
7
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isCartesianSeries = isCartesianSeries;
|
|
7
|
+
exports.isCartesianSeriesType = isCartesianSeriesType;
|
|
8
|
+
var _configInit = require("./configInit");
|
|
9
|
+
function isCartesianSeriesType(seriesType) {
|
|
10
|
+
return _configInit.cartesianSeriesTypes.getTypes().has(seriesType);
|
|
11
|
+
}
|
|
12
|
+
function isCartesianSeries(series) {
|
|
13
|
+
return isCartesianSeriesType(series.type);
|
|
14
|
+
}
|
package/models/axis.d.ts
CHANGED
|
@@ -216,7 +216,7 @@ export type AxisValueFormatterContext = {
|
|
|
216
216
|
*/
|
|
217
217
|
location: 'tick' | 'tooltip';
|
|
218
218
|
};
|
|
219
|
-
export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
|
|
219
|
+
export type AxisConfig<S extends ScaleName = ScaleName, V = any, AxisProps = ChartsXAxisProps | ChartsYAxisProps> = {
|
|
220
220
|
/**
|
|
221
221
|
* Id used to identify the axis.
|
|
222
222
|
*/
|
|
@@ -254,8 +254,8 @@ export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
|
|
|
254
254
|
* If `true`, Reverse the axis scaleBand.
|
|
255
255
|
*/
|
|
256
256
|
reverse?: boolean;
|
|
257
|
-
} & Partial<
|
|
258
|
-
export type AxisDefaultized<S extends ScaleName = ScaleName, V = any> = Omit<AxisConfig<S, V>, 'scaleType'> & AxisScaleConfig[S] & AxisScaleComputedConfig[S] & {
|
|
257
|
+
} & Partial<AxisProps> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & TickParams;
|
|
258
|
+
export type AxisDefaultized<S extends ScaleName = ScaleName, V = any, AxisProps = ChartsXAxisProps | ChartsYAxisProps> = Omit<AxisConfig<S, V, AxisProps>, 'scaleType'> & AxisScaleConfig[S] & AxisScaleComputedConfig[S] & {
|
|
259
259
|
/**
|
|
260
260
|
* An indication of the expected number of ticks.
|
|
261
261
|
*/
|
package/models/index.d.ts
CHANGED
package/models/index.js
CHANGED
|
@@ -35,4 +35,15 @@ Object.keys(_stacking).forEach(function (key) {
|
|
|
35
35
|
return _stacking[key];
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
+
});
|
|
39
|
+
var _plugin = require("./plugin");
|
|
40
|
+
Object.keys(_plugin).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _plugin[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _plugin[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
38
49
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ChartSeriesType, ExtremumGetter, Formatter } from './seriesType/config';
|
|
2
|
+
import { AxisDefaultized } from './axis';
|
|
3
|
+
import { DefaultizedSeriesType } from './seriesType';
|
|
4
|
+
import { ZAxisDefaultized } from './z-axis';
|
|
5
|
+
type ColorProcessor<T extends ChartSeriesType> = (series: DefaultizedSeriesType<T>, xAxis?: AxisDefaultized, yAxis?: AxisDefaultized, zAxis?: ZAxisDefaultized) => (dataIndex: number) => string;
|
|
6
|
+
export type ColorProcessorsConfig<T extends ChartSeriesType> = {
|
|
7
|
+
[Key in T]?: ColorProcessor<Key>;
|
|
8
|
+
};
|
|
9
|
+
export type ChartsPluginType<T> = T extends ChartSeriesType ? {
|
|
10
|
+
seriesType: T;
|
|
11
|
+
seriesFormatter: Formatter<T>;
|
|
12
|
+
colorProcessor: ColorProcessor<T>;
|
|
13
|
+
xExtremumGetter?: ExtremumGetter<T>;
|
|
14
|
+
yExtremumGetter?: ExtremumGetter<T>;
|
|
15
|
+
} : never;
|
|
16
|
+
export {};
|
package/models/plugin.js
ADDED
|
@@ -6,29 +6,44 @@ import { AxisConfig } from '../axis';
|
|
|
6
6
|
import { DefaultizedProps, MakeOptional } from '../helpers';
|
|
7
7
|
import { StackingGroupsType } from '../../internals/stackSeries';
|
|
8
8
|
import { SeriesId } from './common';
|
|
9
|
-
interface ChartsSeriesConfig {
|
|
9
|
+
export interface ChartsSeriesConfig {
|
|
10
10
|
bar: {
|
|
11
|
+
/**
|
|
12
|
+
* Series type when passed to the formatter (some ids are given default values to simplify the DX)
|
|
13
|
+
*/
|
|
11
14
|
seriesInput: DefaultizedProps<BarSeriesType, 'id'> & {
|
|
12
15
|
color: string;
|
|
13
16
|
};
|
|
17
|
+
/**
|
|
18
|
+
* Series type when stored in the context (with all the preprocessing added))
|
|
19
|
+
*/
|
|
14
20
|
series: DefaultizedBarSeriesType;
|
|
15
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Series typing such that the one user need to provide
|
|
23
|
+
*/
|
|
24
|
+
seriesProp: BarSeriesType;
|
|
16
25
|
itemIdentifier: BarItemIdentifier;
|
|
26
|
+
canBeStacked: true;
|
|
27
|
+
cartesian: true;
|
|
17
28
|
};
|
|
18
29
|
line: {
|
|
19
30
|
seriesInput: DefaultizedProps<LineSeriesType, 'id'> & {
|
|
20
31
|
color: string;
|
|
21
32
|
};
|
|
22
33
|
series: DefaultizedLineSeriesType;
|
|
23
|
-
|
|
34
|
+
seriesProp: LineSeriesType;
|
|
24
35
|
itemIdentifier: LineItemIdentifier;
|
|
36
|
+
canBeStacked: true;
|
|
37
|
+
cartesian: true;
|
|
25
38
|
};
|
|
26
39
|
scatter: {
|
|
27
40
|
seriesInput: DefaultizedProps<ScatterSeriesType, 'id'> & {
|
|
28
41
|
color: string;
|
|
29
42
|
};
|
|
30
43
|
series: DefaultizedScatterSeriesType;
|
|
44
|
+
seriesProp: ScatterSeriesType;
|
|
31
45
|
itemIdentifier: ScatterItemIdentifier;
|
|
46
|
+
cartesian: true;
|
|
32
47
|
};
|
|
33
48
|
pie: {
|
|
34
49
|
seriesInput: Omit<DefaultizedProps<PieSeriesType, 'id'>, 'data'> & {
|
|
@@ -37,11 +52,21 @@ interface ChartsSeriesConfig {
|
|
|
37
52
|
})[];
|
|
38
53
|
};
|
|
39
54
|
series: DefaultizedPieSeriesType;
|
|
55
|
+
seriesProp: PieSeriesType<MakeOptional<PieValueType, 'id'>>;
|
|
40
56
|
itemIdentifier: PieItemIdentifier;
|
|
41
57
|
};
|
|
42
58
|
}
|
|
43
|
-
export type
|
|
44
|
-
export type
|
|
59
|
+
export type ChartSeriesType = keyof ChartsSeriesConfig;
|
|
60
|
+
export type CartesianChartSeriesType = keyof Pick<ChartsSeriesConfig, {
|
|
61
|
+
[Key in ChartSeriesType]: ChartsSeriesConfig[Key] extends {
|
|
62
|
+
cartesian: true;
|
|
63
|
+
} ? Key : never;
|
|
64
|
+
}[ChartSeriesType]>;
|
|
65
|
+
export type StackableChartSeriesType = keyof Pick<ChartsSeriesConfig, {
|
|
66
|
+
[Key in ChartSeriesType]: ChartsSeriesConfig[Key] extends {
|
|
67
|
+
canBeStacked: true;
|
|
68
|
+
} ? Key : never;
|
|
69
|
+
}[ChartSeriesType]>;
|
|
45
70
|
export type ChartSeries<T extends ChartSeriesType> = ChartsSeriesConfig[T] extends {
|
|
46
71
|
canBeStacked: true;
|
|
47
72
|
} ? ChartsSeriesConfig[T]['seriesInput'] & {
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
type
|
|
8
|
-
type
|
|
9
|
-
type DefaultizedSeriesType = DefaultizedCartesianSeriesType | DefaultizedPieSeriesType;
|
|
10
|
-
type StackableSeriesType = DefaultizedBarSeriesType | DefaultizedLineSeriesType;
|
|
11
|
-
export type SeriesItemIdentifier = BarItemIdentifier | LineItemIdentifier | ScatterItemIdentifier | PieItemIdentifier;
|
|
1
|
+
import { BarSeriesType, DefaultizedBarSeriesType } from './bar';
|
|
2
|
+
import { CartesianChartSeriesType, ChartSeriesType, ChartsSeriesConfig, StackableChartSeriesType } from './config';
|
|
3
|
+
type AllSeriesType<T extends ChartSeriesType = ChartSeriesType> = ChartsSeriesConfig[T]['seriesProp'];
|
|
4
|
+
type CartesianSeriesType = AllSeriesType<CartesianChartSeriesType>;
|
|
5
|
+
type DefaultizedSeriesType<T extends ChartSeriesType = ChartSeriesType> = ChartsSeriesConfig[T]['series'];
|
|
6
|
+
type DefaultizedCartesianSeriesType = DefaultizedSeriesType<CartesianChartSeriesType>;
|
|
7
|
+
type StackableSeriesType = DefaultizedSeriesType<StackableChartSeriesType>;
|
|
8
|
+
export type SeriesItemIdentifier<T extends ChartSeriesType = ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifier'];
|
|
12
9
|
export * from './line';
|
|
13
10
|
export * from './bar';
|
|
14
11
|
export * from './scatter';
|
|
@@ -351,7 +351,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
351
351
|
labelStyle: PropTypes.object,
|
|
352
352
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
353
353
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
354
|
-
position: PropTypes.oneOf(['bottom', '
|
|
354
|
+
position: PropTypes.oneOf(['bottom', 'top']),
|
|
355
355
|
reverse: PropTypes.bool,
|
|
356
356
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
357
357
|
slotProps: PropTypes.object,
|
|
@@ -404,7 +404,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
404
404
|
labelStyle: PropTypes.object,
|
|
405
405
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
406
406
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
407
|
-
position: PropTypes.oneOf(['
|
|
407
|
+
position: PropTypes.oneOf(['left', 'right']),
|
|
408
408
|
reverse: PropTypes.bool,
|
|
409
409
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
410
410
|
slotProps: PropTypes.object,
|