@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
|
@@ -4,7 +4,6 @@ const _excluded = ["skipAnimation", "onItemClick", "borderRadius", "barLabel"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { useTransition } from '@react-spring/web';
|
|
7
|
-
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
8
7
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
8
|
import { BarElement } from './BarElement';
|
|
10
9
|
import getColor from './getColor';
|
|
@@ -12,6 +11,7 @@ import { useChartId } from '../hooks';
|
|
|
12
11
|
import { BarClipPath } from './BarClipPath';
|
|
13
12
|
import { BarLabelPlot } from './BarLabel/BarLabelPlot';
|
|
14
13
|
import { checkScaleErrors } from './checkScaleErrors';
|
|
14
|
+
import { useBarSeries } from '../hooks/useSeries';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Solution of the equations
|
|
@@ -42,7 +42,7 @@ function getBandSize({
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
const useAggregatedData = () => {
|
|
45
|
-
const seriesData =
|
|
45
|
+
const seriesData = useBarSeries() ?? {
|
|
46
46
|
series: {},
|
|
47
47
|
stackingGroups: [],
|
|
48
48
|
seriesOrder: []
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { stack as d3Stack } from 'd3-shape';
|
|
3
3
|
import { getStackingGroups } from '../internals/stackSeries';
|
|
4
|
-
import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
|
|
4
|
+
import { defaultizeValueFormatter } from '../internals/defaultizeValueFormatter';
|
|
5
5
|
let warnOnce = false;
|
|
6
6
|
const formatter = (params, dataset) => {
|
|
7
7
|
const {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default function getColor(series, xAxis, yAxis) {
|
|
2
2
|
const verticalLayout = series.layout === 'vertical';
|
|
3
|
-
const bandColorScale = verticalLayout ? xAxis
|
|
4
|
-
const valueColorScale = verticalLayout ? yAxis
|
|
5
|
-
const bandValues = verticalLayout ? xAxis
|
|
3
|
+
const bandColorScale = verticalLayout ? xAxis?.colorScale : yAxis?.colorScale;
|
|
4
|
+
const valueColorScale = verticalLayout ? yAxis?.colorScale : xAxis?.colorScale;
|
|
5
|
+
const bandValues = verticalLayout ? xAxis?.data : yAxis?.data;
|
|
6
6
|
if (valueColorScale) {
|
|
7
7
|
return dataIndex => {
|
|
8
8
|
const value = series.data[dataIndex];
|
|
@@ -13,7 +13,7 @@ export default function getColor(series, xAxis, yAxis) {
|
|
|
13
13
|
return color;
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
if (bandColorScale) {
|
|
16
|
+
if (bandColorScale && bandValues) {
|
|
17
17
|
return dataIndex => {
|
|
18
18
|
const value = bandValues[dataIndex];
|
|
19
19
|
const color = value === null ? series.color : bandColorScale(value);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getExtremumX, getExtremumY } from './extremums';
|
|
2
|
+
import formatter from './formatter';
|
|
3
|
+
import getColor from './getColor';
|
|
4
|
+
export const plugin = {
|
|
5
|
+
seriesType: 'bar',
|
|
6
|
+
seriesFormatter: formatter,
|
|
7
|
+
colorProcessor: getColor,
|
|
8
|
+
xExtremumGetter: getExtremumX,
|
|
9
|
+
yExtremumGetter: getExtremumY
|
|
10
|
+
};
|
|
@@ -9,6 +9,7 @@ import { ChartsSurface } from '../ChartsSurface';
|
|
|
9
9
|
import { CartesianContextProvider } from '../context/CartesianContextProvider';
|
|
10
10
|
import { ChartsAxesGradients } from '../internals/components/ChartsAxesGradients';
|
|
11
11
|
import { HighlightedProvider } from '../context';
|
|
12
|
+
import { usePluginsMerge } from './usePluginsMerge';
|
|
12
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
|
|
14
15
|
const {
|
|
@@ -26,10 +27,14 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
26
27
|
disableAxisListener,
|
|
27
28
|
highlightedItem,
|
|
28
29
|
onHighlightChange,
|
|
30
|
+
plugins,
|
|
29
31
|
children
|
|
30
32
|
} = props;
|
|
31
33
|
const svgRef = React.useRef(null);
|
|
32
34
|
const handleRef = useForkRef(ref, svgRef);
|
|
35
|
+
const {
|
|
36
|
+
seriesFormatters
|
|
37
|
+
} = usePluginsMerge(plugins);
|
|
33
38
|
useReducedMotion(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
|
|
34
39
|
|
|
35
40
|
return /*#__PURE__*/_jsx(DrawingProvider, {
|
|
@@ -41,6 +46,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
41
46
|
series: series,
|
|
42
47
|
colors: colors,
|
|
43
48
|
dataset: dataset,
|
|
49
|
+
seriesFormatters: seriesFormatters,
|
|
44
50
|
children: /*#__PURE__*/_jsx(CartesianContextProvider, {
|
|
45
51
|
xAxis: xAxis,
|
|
46
52
|
yAxis: yAxis,
|
|
@@ -117,6 +123,11 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
117
123
|
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
118
124
|
*/
|
|
119
125
|
onHighlightChange: PropTypes.func,
|
|
126
|
+
/**
|
|
127
|
+
* An array of plugins defining how to preprocess data.
|
|
128
|
+
* If not provided, the container supports line, bar, scatter and pie charts.
|
|
129
|
+
*/
|
|
130
|
+
plugins: PropTypes.arrayOf(PropTypes.object),
|
|
120
131
|
/**
|
|
121
132
|
* The array of series to display.
|
|
122
133
|
* Each type of series has its own specificity.
|
|
@@ -170,7 +181,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
170
181
|
labelStyle: PropTypes.object,
|
|
171
182
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
172
183
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
173
|
-
position: PropTypes.oneOf(['bottom', '
|
|
184
|
+
position: PropTypes.oneOf(['bottom', 'top']),
|
|
174
185
|
reverse: PropTypes.bool,
|
|
175
186
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
176
187
|
slotProps: PropTypes.object,
|
|
@@ -223,7 +234,7 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
223
234
|
labelStyle: PropTypes.object,
|
|
224
235
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
225
236
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
226
|
-
position: PropTypes.oneOf(['
|
|
237
|
+
position: PropTypes.oneOf(['left', 'right']),
|
|
227
238
|
reverse: PropTypes.bool,
|
|
228
239
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
229
240
|
slotProps: PropTypes.object,
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { plugin as barPlugin } from '../BarChart/plugin';
|
|
2
|
+
import { plugin as scatterPlugin } from '../ScatterChart/plugin';
|
|
3
|
+
import { plugin as linePlugin } from '../LineChart/plugin';
|
|
4
|
+
import { plugin as piePlugin } from '../PieChart/plugin';
|
|
5
|
+
export const defaultPlugins = [barPlugin, scatterPlugin, linePlugin, piePlugin];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { defaultPlugins } from './defaultPlugins';
|
|
3
|
+
export function usePluginsMerge(plugins) {
|
|
4
|
+
const defaultizedPlugins = plugins ?? defaultPlugins;
|
|
5
|
+
return React.useMemo(() => {
|
|
6
|
+
const seriesFormatters = {};
|
|
7
|
+
const colorProcessors = {};
|
|
8
|
+
const xExtremumGetters = {};
|
|
9
|
+
const yExtremumGetters = {};
|
|
10
|
+
for (let i = 0; i < defaultizedPlugins.length; i += 1) {
|
|
11
|
+
const plugin = defaultizedPlugins[i];
|
|
12
|
+
|
|
13
|
+
// To remove those any we will need to solve this union discrimination issue:
|
|
14
|
+
// https://www.typescriptlang.org/play/?#code/FDAuE8AcFMAIDkCuBbARtATgYQPYDsAzASwHNYBeWAb2FlgGsi8ATALlgHI8V0MOBuWrBwwMAQ1A4M7ABQAPdtzSYAlBQB8sJb0EBfEBBiwAyqAxMSuQqQrUhjFuw4BnMxYFCRmCVNkLYruZ4JGrkmoEWeiAAxviuWqhWxCTsSMrY+Mm2VAxMbLAARNqYBQA0wqI+0rByGrAATLAAVDWw+rF48YFJpOymQZaZNpQ5DvkFEcFlFd6S1bVhsAAG9S0AJFRyukttMXGgsB3JzrYA2niJQyTl3VcAugZQcADylXPOALJikJAW2ULFDAAflSPEwPRIpw4XnEcw4d1KQkmJBBJjcwQhUJhVXhiN0gmAHXi2LmXx+FnYr1mUk+31+wWy+JABCksBkABtoAcjjYcARDldnGoaCA6AB6MWwADqUnoJxw9FgRH5AHc4L9ooroGJogALQ5iZxwPJEABuRGYiDE7PASJVRFAerZPJIADoxsKhHRooa4FwwXxWF66DNYVIyfTIS73Xk7rZoySpIIQyHUBhtfRkyGfUbOMiOEGU3RExgIxZTtGxnHKAm3kng8xoAQxIh2aBC0W0xms-pvftqLkWOUS2141chBLYABJDimuB4HBKxtiWBiVA4RAHXU4FWwSSwTkHAAqxlgiBYmFcYhYAusbrGq5vtepGFX6YPTHo0GYnjrpbp5ZVrYJZ6EAA
|
|
15
|
+
seriesFormatters[plugin.seriesType] = plugin.seriesFormatter;
|
|
16
|
+
colorProcessors[plugin.seriesType] = plugin.colorProcessor;
|
|
17
|
+
if (plugin.xExtremumGetter) {
|
|
18
|
+
xExtremumGetters[plugin.seriesType] = plugin.xExtremumGetter;
|
|
19
|
+
}
|
|
20
|
+
if (plugin.yExtremumGetter) {
|
|
21
|
+
yExtremumGetters[plugin.seriesType] = plugin.yExtremumGetter;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
seriesFormatters,
|
|
26
|
+
colorProcessors,
|
|
27
|
+
xExtremumGetters,
|
|
28
|
+
yExtremumGetters
|
|
29
|
+
};
|
|
30
|
+
}, [defaultizedPlugins]);
|
|
31
|
+
}
|
|
@@ -5,10 +5,10 @@ import { useSlotProps } from '@mui/base/utils';
|
|
|
5
5
|
import { unstable_composeClasses as composeClasses } from '@mui/utils';
|
|
6
6
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
7
7
|
import { getSeriesToDisplay } from './utils';
|
|
8
|
-
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
9
8
|
import { getLegendUtilityClass } from './chartsLegendClasses';
|
|
10
9
|
import { DefaultChartsLegend } from './DefaultChartsLegend';
|
|
11
10
|
import { useDrawingArea } from '../hooks';
|
|
11
|
+
import { useSeries } from '../hooks/useSeries';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
const useUtilityClasses = ownerState => {
|
|
14
14
|
const {
|
|
@@ -47,7 +47,7 @@ function ChartsLegend(inProps) {
|
|
|
47
47
|
theme
|
|
48
48
|
}));
|
|
49
49
|
const drawingArea = useDrawingArea();
|
|
50
|
-
const series =
|
|
50
|
+
const series = useSeries();
|
|
51
51
|
const seriesToDisplay = getSeriesToDisplay(series);
|
|
52
52
|
const ChartLegendRender = slots?.legend ?? DefaultChartsLegend;
|
|
53
53
|
const chartLegendRenderProps = useSlotProps({
|
|
@@ -9,5 +9,8 @@ const legendGetter = {
|
|
|
9
9
|
pie: getPieLegend
|
|
10
10
|
};
|
|
11
11
|
export function getSeriesToDisplay(series) {
|
|
12
|
-
return Object.keys(series).flatMap(seriesType =>
|
|
12
|
+
return Object.keys(series).flatMap(seriesType => {
|
|
13
|
+
const getter = legendGetter[seriesType];
|
|
14
|
+
return getter === undefined ? [] : getter(series[seriesType]);
|
|
15
|
+
});
|
|
13
16
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { SvgContext } from '../context/DrawingProvider';
|
|
4
3
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
5
4
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
6
|
-
import {
|
|
5
|
+
import { useSeries } from '../hooks/useSeries';
|
|
6
|
+
import { useSvgRef } from '../hooks';
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
8
|
function ChartsOnAxisClickHandler(props) {
|
|
9
9
|
const {
|
|
10
10
|
onAxisClick
|
|
11
11
|
} = props;
|
|
12
|
-
const svgRef =
|
|
13
|
-
const series =
|
|
12
|
+
const svgRef = useSvgRef();
|
|
13
|
+
const series = useSeries();
|
|
14
14
|
const {
|
|
15
15
|
axis
|
|
16
16
|
} = React.useContext(InteractionContext);
|
|
@@ -2,12 +2,12 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { useSlotProps } from '@mui/base/utils';
|
|
5
|
-
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
6
5
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
7
6
|
import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
|
|
8
|
-
import { isCartesianSeriesType } from '
|
|
7
|
+
import { isCartesianSeriesType } from '../internals/isCartesian';
|
|
9
8
|
import colorGetter from '../internals/colorGetter';
|
|
10
9
|
import { ZAxisContext } from '../context/ZAxisContextProvider';
|
|
10
|
+
import { useSeries } from '../hooks/useSeries';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
function ChartsAxisTooltipContent(props) {
|
|
13
13
|
const {
|
|
@@ -30,7 +30,7 @@ function ChartsAxisTooltipContent(props) {
|
|
|
30
30
|
zAxisIds,
|
|
31
31
|
zAxis
|
|
32
32
|
} = React.useContext(ZAxisContext);
|
|
33
|
-
const series =
|
|
33
|
+
const series = useSeries();
|
|
34
34
|
const USED_AXIS_ID = isXaxis ? xAxisIds[0] : yAxisIds[0];
|
|
35
35
|
const relevantSeries = React.useMemo(() => {
|
|
36
36
|
const rep = [];
|
|
@@ -2,11 +2,11 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { useSlotProps } from '@mui/base/utils';
|
|
5
|
-
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
6
5
|
import { DefaultChartsItemTooltipContent } from './DefaultChartsItemTooltipContent';
|
|
7
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
8
7
|
import colorGetter from '../internals/colorGetter';
|
|
9
8
|
import { ZAxisContext } from '../context/ZAxisContextProvider';
|
|
9
|
+
import { useSeries } from '../hooks/useSeries';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
function ChartsItemTooltipContent(props) {
|
|
12
12
|
const {
|
|
@@ -16,7 +16,7 @@ function ChartsItemTooltipContent(props) {
|
|
|
16
16
|
classes,
|
|
17
17
|
contentProps
|
|
18
18
|
} = props;
|
|
19
|
-
const series =
|
|
19
|
+
const series = useSeries()[itemData.type].series[itemData.seriesId];
|
|
20
20
|
const {
|
|
21
21
|
xAxis,
|
|
22
22
|
yAxis,
|
|
@@ -3,8 +3,9 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import clsx from 'clsx';
|
|
4
4
|
import Typography from '@mui/material/Typography';
|
|
5
5
|
import { ChartsTooltipCell, ChartsTooltipPaper, ChartsTooltipTable, ChartsTooltipMark, ChartsTooltipRow } from './ChartsTooltipTable';
|
|
6
|
-
import {
|
|
6
|
+
import { utcFormatter } from './utils';
|
|
7
7
|
import { getLabel } from '../internals/getLabel';
|
|
8
|
+
import { isCartesianSeries } from '../internals/isCartesian';
|
|
8
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
function DefaultChartsAxisTooltipContent(props) {
|
|
10
11
|
const {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { useSvgRef } from '../hooks';
|
|
3
3
|
export function generateVirtualElement(mousePosition) {
|
|
4
4
|
if (mousePosition === null) {
|
|
5
5
|
return {
|
|
@@ -44,7 +44,7 @@ export function generateVirtualElement(mousePosition) {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
export function useMouseTracker() {
|
|
47
|
-
const svgRef =
|
|
47
|
+
const svgRef = useSvgRef();
|
|
48
48
|
|
|
49
49
|
// Use a ref to avoid rerendering on every mousemove event.
|
|
50
50
|
const [mousePosition, setMousePosition] = React.useState(null);
|
|
@@ -84,12 +84,6 @@ export function getTooltipHasData(trigger, displayedData) {
|
|
|
84
84
|
const hasAxisYData = displayedData.y !== null;
|
|
85
85
|
return hasAxisXData || hasAxisYData;
|
|
86
86
|
}
|
|
87
|
-
export function isCartesianSeriesType(seriesType) {
|
|
88
|
-
return ['bar', 'line', 'scatter'].includes(seriesType);
|
|
89
|
-
}
|
|
90
|
-
export function isCartesianSeries(series) {
|
|
91
|
-
return isCartesianSeriesType(series.type);
|
|
92
|
-
}
|
|
93
87
|
export function utcFormatter(v) {
|
|
94
88
|
if (v instanceof Date) {
|
|
95
89
|
return v.toUTCString();
|
|
@@ -4,11 +4,11 @@ import { Delaunay } from 'd3-delaunay';
|
|
|
4
4
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
5
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
6
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
7
|
-
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
8
7
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
9
8
|
import { getSVGPoint } from '../internals/utils';
|
|
10
9
|
import { useDrawingArea, useSvgRef } from '../hooks';
|
|
11
10
|
import { useHighlighted } from '../context';
|
|
11
|
+
import { useScatterSeries } from '../hooks/useSeries';
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
function ChartsVoronoiHandler(props) {
|
|
14
14
|
const {
|
|
@@ -34,7 +34,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
34
34
|
const {
|
|
35
35
|
series,
|
|
36
36
|
seriesOrder
|
|
37
|
-
} =
|
|
37
|
+
} = useScatterSeries() ?? {};
|
|
38
38
|
const voronoiRef = React.useRef({});
|
|
39
39
|
const delauneyRef = React.useRef(undefined);
|
|
40
40
|
const {
|
|
@@ -104,27 +104,23 @@ const defaultProps = {
|
|
|
104
104
|
* - [ChartsXAxis API](https://mui.com/x/api/charts/charts-x-axis/)
|
|
105
105
|
*/
|
|
106
106
|
function ChartsXAxis(inProps) {
|
|
107
|
-
const props = useThemeProps({
|
|
108
|
-
props: _extends({}, defaultProps, inProps),
|
|
109
|
-
name: 'MuiChartsXAxis'
|
|
110
|
-
});
|
|
111
107
|
const {
|
|
112
|
-
xAxisIds
|
|
108
|
+
xAxisIds,
|
|
109
|
+
xAxis
|
|
113
110
|
} = React.useContext(CartesianContext);
|
|
114
|
-
const
|
|
115
|
-
_ref = props.axisId ?? xAxisIds[0],
|
|
111
|
+
const _xAxis = xAxis[inProps.axisId ?? xAxisIds[0]],
|
|
116
112
|
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
} = _React$useContext,
|
|
125
|
-
settings = _objectWithoutPropertiesLoose(_React$useContext.xAxis[_ref], _excluded);
|
|
113
|
+
scale: xScale,
|
|
114
|
+
tickNumber,
|
|
115
|
+
reverse
|
|
116
|
+
} = _xAxis,
|
|
117
|
+
settings = _objectWithoutPropertiesLoose(_xAxis, _excluded);
|
|
126
118
|
const isMounted = useMounted();
|
|
127
|
-
const
|
|
119
|
+
const themedProps = useThemeProps({
|
|
120
|
+
props: _extends({}, settings, inProps),
|
|
121
|
+
name: 'MuiChartsXAxis'
|
|
122
|
+
});
|
|
123
|
+
const defaultizedProps = _extends({}, defaultProps, themedProps);
|
|
128
124
|
const {
|
|
129
125
|
position,
|
|
130
126
|
disableLine,
|
|
@@ -314,10 +310,12 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
314
310
|
*/
|
|
315
311
|
tickFontSize: PropTypes.number,
|
|
316
312
|
/**
|
|
317
|
-
* Defines which ticks are displayed.
|
|
313
|
+
* Defines which ticks are displayed.
|
|
314
|
+
* Its value can be:
|
|
318
315
|
* - 'auto' In such case the ticks are computed based on axis scale and other parameters.
|
|
319
|
-
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has
|
|
316
|
+
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has "point" scale.
|
|
320
317
|
* - an array containing the values where ticks should be displayed.
|
|
318
|
+
* @see See {@link https://mui.com/x/react-charts/axis/#fixed-tick-positions}
|
|
321
319
|
* @default 'auto'
|
|
322
320
|
*/
|
|
323
321
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
3
|
const _excluded = ["scale", "tickNumber"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
@@ -47,25 +47,21 @@ const defaultProps = {
|
|
|
47
47
|
* - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
|
|
48
48
|
*/
|
|
49
49
|
function ChartsYAxis(inProps) {
|
|
50
|
-
const props = useThemeProps({
|
|
51
|
-
props: _extends({}, defaultProps, inProps),
|
|
52
|
-
name: 'MuiChartsYAxis'
|
|
53
|
-
});
|
|
54
50
|
const {
|
|
55
|
-
yAxisIds
|
|
51
|
+
yAxisIds,
|
|
52
|
+
yAxis
|
|
56
53
|
} = React.useContext(CartesianContext);
|
|
57
|
-
const
|
|
58
|
-
_ref = props.axisId ?? yAxisIds[0],
|
|
54
|
+
const _yAxis = yAxis[inProps.axisId ?? yAxisIds[0]],
|
|
59
55
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const defaultizedProps = _extends({}, defaultProps,
|
|
56
|
+
scale: yScale,
|
|
57
|
+
tickNumber
|
|
58
|
+
} = _yAxis,
|
|
59
|
+
settings = _objectWithoutPropertiesLoose(_yAxis, _excluded);
|
|
60
|
+
const themedProps = useThemeProps({
|
|
61
|
+
props: _extends({}, settings, inProps),
|
|
62
|
+
name: 'MuiChartsYAxis'
|
|
63
|
+
});
|
|
64
|
+
const defaultizedProps = _extends({}, defaultProps, themedProps);
|
|
69
65
|
const {
|
|
70
66
|
position,
|
|
71
67
|
disableLine,
|
|
@@ -250,10 +246,12 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
250
246
|
*/
|
|
251
247
|
tickFontSize: PropTypes.number,
|
|
252
248
|
/**
|
|
253
|
-
* Defines which ticks are displayed.
|
|
249
|
+
* Defines which ticks are displayed.
|
|
250
|
+
* Its value can be:
|
|
254
251
|
* - 'auto' In such case the ticks are computed based on axis scale and other parameters.
|
|
255
|
-
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has
|
|
252
|
+
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has "point" scale.
|
|
256
253
|
* - an array containing the values where ticks should be displayed.
|
|
254
|
+
* @see See {@link https://mui.com/x/react-charts/axis/#fixed-tick-positions}
|
|
257
255
|
* @default 'auto'
|
|
258
256
|
*/
|
|
259
257
|
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
@@ -4,16 +4,16 @@ const _excluded = ["slots", "slotProps", "onItemClick", "skipAnimation"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { area as d3Area } from 'd3-shape';
|
|
7
|
-
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
8
7
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
8
|
import { AreaElement } from './AreaElement';
|
|
10
9
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
11
10
|
import getCurveFactory from '../internals/getCurve';
|
|
12
11
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
13
12
|
import { useChartGradient } from '../internals/components/ChartsAxesGradients';
|
|
13
|
+
import { useLineSeries } from '../hooks/useSeries';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
const useAggregatedData = () => {
|
|
16
|
-
const seriesData =
|
|
16
|
+
const seriesData = useLineSeries();
|
|
17
17
|
const axisData = React.useContext(CartesianContext);
|
|
18
18
|
if (seriesData === undefined) {
|
|
19
19
|
return [];
|
|
@@ -348,7 +348,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
348
348
|
labelStyle: PropTypes.object,
|
|
349
349
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
350
350
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
351
|
-
position: PropTypes.oneOf(['bottom', '
|
|
351
|
+
position: PropTypes.oneOf(['bottom', 'top']),
|
|
352
352
|
reverse: PropTypes.bool,
|
|
353
353
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
354
354
|
slotProps: PropTypes.object,
|
|
@@ -401,7 +401,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
401
401
|
labelStyle: PropTypes.object,
|
|
402
402
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
403
403
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
404
|
-
position: PropTypes.oneOf(['
|
|
404
|
+
position: PropTypes.oneOf(['left', 'right']),
|
|
405
405
|
reverse: PropTypes.bool,
|
|
406
406
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
407
407
|
slotProps: PropTypes.object,
|
|
@@ -3,13 +3,13 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["slots", "slotProps"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
7
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
8
7
|
import { LineHighlightElement } from './LineHighlightElement';
|
|
9
8
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
10
9
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
11
10
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
12
11
|
import getColor from './getColor';
|
|
12
|
+
import { useLineSeries } from '../hooks/useSeries';
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
/**
|
|
15
15
|
* Demos:
|
|
@@ -27,7 +27,7 @@ function LineHighlightPlot(props) {
|
|
|
27
27
|
slotProps
|
|
28
28
|
} = props,
|
|
29
29
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
30
|
-
const seriesData =
|
|
30
|
+
const seriesData = useLineSeries();
|
|
31
31
|
const axisData = React.useContext(CartesianContext);
|
|
32
32
|
const {
|
|
33
33
|
axis
|
|
@@ -4,16 +4,16 @@ const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { line as d3Line } from 'd3-shape';
|
|
7
|
-
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
8
7
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
9
8
|
import { LineElement } from './LineElement';
|
|
10
9
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
11
10
|
import getCurveFactory from '../internals/getCurve';
|
|
12
11
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
13
12
|
import { useChartGradient } from '../internals/components/ChartsAxesGradients';
|
|
13
|
+
import { useLineSeries } from '../hooks/useSeries';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
const useAggregatedData = () => {
|
|
16
|
-
const seriesData =
|
|
16
|
+
const seriesData = useLineSeries();
|
|
17
17
|
const axisData = React.useContext(CartesianContext);
|
|
18
18
|
if (seriesData === undefined) {
|
|
19
19
|
return [];
|
|
@@ -3,7 +3,6 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
7
6
|
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
8
7
|
import { MarkElement } from './MarkElement';
|
|
9
8
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
@@ -11,6 +10,7 @@ import { useChartId } from '../hooks/useChartId';
|
|
|
11
10
|
import { DEFAULT_X_AXIS_KEY } from '../constants';
|
|
12
11
|
import { cleanId } from '../internals/utils';
|
|
13
12
|
import getColor from './getColor';
|
|
13
|
+
import { useLineSeries } from '../hooks/useSeries';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
/**
|
|
16
16
|
* Demos:
|
|
@@ -30,7 +30,7 @@ function MarkPlot(props) {
|
|
|
30
30
|
onItemClick
|
|
31
31
|
} = props,
|
|
32
32
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
33
|
-
const seriesData =
|
|
33
|
+
const seriesData = useLineSeries();
|
|
34
34
|
const axisData = React.useContext(CartesianContext);
|
|
35
35
|
const chartId = useChartId();
|
|
36
36
|
const Mark = slots?.mark ?? MarkElement;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { stack as d3Stack } from 'd3-shape';
|
|
3
3
|
import { getStackingGroups } from '../internals/stackSeries';
|
|
4
|
-
import defaultizeValueFormatter from '../internals/defaultizeValueFormatter';
|
|
4
|
+
import { defaultizeValueFormatter } from '../internals/defaultizeValueFormatter';
|
|
5
5
|
let warnedOnce = false;
|
|
6
6
|
|
|
7
7
|
// For now it's a copy past of bar charts formatter, but maybe will diverge later
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default function getColor(series, xAxis, yAxis) {
|
|
2
|
-
const yColorScale = yAxis
|
|
3
|
-
const xColorScale = xAxis
|
|
2
|
+
const yColorScale = yAxis?.colorScale;
|
|
3
|
+
const xColorScale = xAxis?.colorScale;
|
|
4
4
|
if (yColorScale) {
|
|
5
5
|
return dataIndex => {
|
|
6
6
|
const value = series.data[dataIndex];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getExtremumX, getExtremumY } from './extremums';
|
|
2
|
+
import formatter from './formatter';
|
|
3
|
+
import getColor from './getColor';
|
|
4
|
+
export const plugin = {
|
|
5
|
+
seriesType: 'line',
|
|
6
|
+
colorProcessor: getColor,
|
|
7
|
+
seriesFormatter: formatter,
|
|
8
|
+
xExtremumGetter: getExtremumX,
|
|
9
|
+
yExtremumGetter: getExtremumY
|
|
10
|
+
};
|
|
@@ -307,7 +307,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
307
307
|
labelStyle: PropTypes.object,
|
|
308
308
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
309
309
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
310
|
-
position: PropTypes.oneOf(['bottom', '
|
|
310
|
+
position: PropTypes.oneOf(['bottom', 'top']),
|
|
311
311
|
reverse: PropTypes.bool,
|
|
312
312
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
313
313
|
slotProps: PropTypes.object,
|
|
@@ -360,7 +360,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
360
360
|
labelStyle: PropTypes.object,
|
|
361
361
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
362
362
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
363
|
-
position: PropTypes.oneOf(['
|
|
363
|
+
position: PropTypes.oneOf(['left', 'right']),
|
|
364
364
|
reverse: PropTypes.bool,
|
|
365
365
|
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
366
366
|
slotProps: PropTypes.object,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
4
3
|
import { DrawingContext } from '../context/DrawingProvider';
|
|
5
4
|
import { PieArcPlot } from './PieArcPlot';
|
|
6
5
|
import { PieArcLabelPlot } from './PieArcLabelPlot';
|
|
7
6
|
import { getPercentageValue } from '../internals/utils';
|
|
8
7
|
import { getPieCoordinates } from './getPieCoordinates';
|
|
8
|
+
import { usePieSeries } from '../hooks/useSeries';
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
/**
|
|
11
11
|
* Demos:
|
|
@@ -24,7 +24,7 @@ function PiePlot(props) {
|
|
|
24
24
|
slotProps,
|
|
25
25
|
onItemClick
|
|
26
26
|
} = props;
|
|
27
|
-
const seriesData =
|
|
27
|
+
const seriesData = usePieSeries();
|
|
28
28
|
const {
|
|
29
29
|
left,
|
|
30
30
|
top,
|