@mui/x-charts 8.6.0 → 8.8.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 +1 -1
- package/BarChart/BarChart.js +16 -0
- package/BarChart/BarPlot.js +11 -150
- package/BarChart/useBarPlotData.d.ts +8 -0
- package/BarChart/useBarPlotData.js +146 -0
- package/CHANGELOG.md +202 -1
- package/ChartContainer/ChartContainer.d.ts +1 -21
- package/ChartContainer/ChartContainer.js +22 -8
- package/ChartContainer/index.d.ts +8 -1
- package/ChartContainer/useChartContainerProps.js +8 -2
- package/ChartDataProvider/ChartDataProvider.js +6 -0
- package/ChartDataProvider/useChartDataProviderProps.d.ts +1 -1
- package/ChartDataProvider/useChartDataProviderProps.js +6 -1
- package/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +34 -24
- package/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +34 -24
- package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
- package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +3 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.js +48 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +3 -0
- package/ChartsReferenceLine/ChartsYReferenceLine.js +48 -1
- package/ChartsReferenceLine/index.d.ts +3 -1
- package/ChartsSurface/ChartsSurface.js +2 -1
- package/ChartsTooltip/ChartsTooltipContainer.js +6 -3
- package/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
- package/ChartsTooltip/utils.js +18 -29
- package/Gauge/GaugeContainer.d.ts +1 -1
- package/LineChart/AreaPlot.js +5 -115
- package/LineChart/LineChart.js +22 -0
- package/LineChart/LineHighlightPlot.js +10 -4
- package/LineChart/LinePlot.js +5 -99
- package/LineChart/MarkPlot.js +17 -3
- package/LineChart/useAreaPlotData.d.ts +12 -0
- package/LineChart/useAreaPlotData.js +126 -0
- package/LineChart/useLinePlotData.d.ts +11 -0
- package/LineChart/useLinePlotData.js +108 -0
- package/PieChart/PieChart.d.ts +1 -1
- package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +1 -1
- package/ScatterChart/Scatter.js +22 -48
- package/ScatterChart/ScatterChart.d.ts +1 -1
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
- package/ScatterChart/useScatterPlotData.d.ts +8 -0
- package/ScatterChart/useScatterPlotData.js +33 -0
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +16 -0
- package/context/ChartApi.d.ts +22 -0
- package/context/ChartApi.js +5 -0
- package/context/ChartProvider/ChartContext.js +1 -0
- package/context/index.d.ts +2 -1
- package/context/useChartApiContext.d.ts +1 -1
- package/esm/BarChart/BarChart.d.ts +1 -1
- package/esm/BarChart/BarChart.js +16 -0
- package/esm/BarChart/BarPlot.js +12 -152
- package/esm/BarChart/useBarPlotData.d.ts +8 -0
- package/esm/BarChart/useBarPlotData.js +139 -0
- package/esm/ChartContainer/ChartContainer.d.ts +1 -21
- package/esm/ChartContainer/ChartContainer.js +22 -8
- package/esm/ChartContainer/index.d.ts +8 -1
- package/esm/ChartContainer/index.js +6 -1
- package/esm/ChartContainer/useChartContainerProps.js +8 -2
- package/esm/ChartDataProvider/ChartDataProvider.js +6 -0
- package/esm/ChartDataProvider/useChartDataProviderProps.d.ts +1 -1
- package/esm/ChartDataProvider/useChartDataProviderProps.js +7 -2
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +1 -1
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +36 -26
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +1 -1
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +36 -26
- package/esm/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.d.ts +3 -0
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +47 -0
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.d.ts +3 -0
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +47 -0
- package/esm/ChartsReferenceLine/index.d.ts +3 -1
- package/esm/ChartsReferenceLine/index.js +2 -1
- package/esm/ChartsSurface/ChartsSurface.js +2 -1
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +6 -3
- package/esm/ChartsTooltip/ChartsTooltipTable.d.ts +1 -1
- package/esm/ChartsTooltip/utils.js +18 -29
- package/esm/Gauge/GaugeContainer.d.ts +1 -1
- package/esm/LineChart/AreaPlot.js +5 -115
- package/esm/LineChart/LineChart.js +22 -0
- package/esm/LineChart/LineHighlightPlot.js +11 -5
- package/esm/LineChart/LinePlot.js +5 -99
- package/esm/LineChart/MarkPlot.js +17 -3
- package/esm/LineChart/useAreaPlotData.d.ts +12 -0
- package/esm/LineChart/useAreaPlotData.js +119 -0
- package/esm/LineChart/useLinePlotData.d.ts +11 -0
- package/esm/LineChart/useLinePlotData.js +101 -0
- package/esm/PieChart/PieChart.d.ts +1 -1
- package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +1 -1
- package/esm/ScatterChart/Scatter.js +23 -49
- package/esm/ScatterChart/ScatterChart.d.ts +1 -1
- package/esm/ScatterChart/ScatterPlot.js +2 -2
- package/esm/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
- package/esm/ScatterChart/useScatterPlotData.d.ts +8 -0
- package/esm/ScatterChart/useScatterPlotData.js +26 -0
- package/esm/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +16 -0
- package/esm/context/ChartApi.d.ts +22 -0
- package/esm/context/ChartApi.js +1 -0
- package/esm/context/ChartProvider/ChartContext.js +2 -0
- package/esm/context/index.d.ts +2 -1
- package/esm/context/useChartApiContext.d.ts +1 -1
- package/esm/hooks/useAxis.d.ts +2 -2
- package/esm/hooks/useInteractionItemProps.d.ts +14 -9
- package/esm/hooks/useInteractionItemProps.js +28 -28
- package/esm/index.d.ts +2 -1
- package/esm/index.js +2 -2
- package/esm/internals/constants.d.ts +3 -0
- package/esm/internals/constants.js +4 -0
- package/esm/internals/getLabel.d.ts +1 -1
- package/esm/internals/index.d.ts +6 -0
- package/esm/internals/index.js +6 -0
- package/esm/internals/plugins/corePlugins/corePlugins.d.ts +4 -2
- package/esm/internals/plugins/corePlugins/corePlugins.js +3 -1
- package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -29
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +0 -6
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/index.d.ts +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/index.js +2 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.js +27 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +8 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +3 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +21 -0
- package/esm/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js +1 -0
- package/esm/internals/plugins/corePlugins/useChartId/useChartId.js +2 -0
- package/esm/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/index.d.ts +2 -0
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/index.js +1 -0
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.d.ts +3 -0
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +77 -0
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +31 -0
- package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.js +1 -0
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +5 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +1 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +5 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +7 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.js +14 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +2 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +2 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +90 -36
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +18 -1
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +76 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +8 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +47 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +48 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +18 -12
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +16 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +6 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +34 -34
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +47 -30
- package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
- package/esm/internals/plugins/utils/useLazySelectorEffect.d.ts +7 -0
- package/esm/internals/plugins/utils/useLazySelectorEffect.js +70 -0
- package/esm/internals/store/useCharts.d.ts +1 -1
- package/esm/locales/elGR.d.ts +19 -0
- package/esm/locales/elGR.js +15 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +1 -0
- package/esm/models/axis.d.ts +15 -0
- package/esm/models/axis.js +4 -0
- package/esm/models/index.d.ts +1 -1
- package/esm/models/seriesType/scatter.d.ts +11 -2
- package/esm/themeAugmentation/components.d.ts +3 -0
- package/esm/themeAugmentation/props.d.ts +2 -0
- package/hooks/useAxis.d.ts +2 -2
- package/hooks/useInteractionItemProps.d.ts +14 -9
- package/hooks/useInteractionItemProps.js +29 -28
- package/index.d.ts +2 -1
- package/index.js +37 -11
- package/internals/constants.d.ts +3 -0
- package/internals/constants.js +5 -1
- package/internals/getLabel.d.ts +1 -1
- package/internals/index.d.ts +6 -0
- package/internals/index.js +52 -0
- package/internals/plugins/corePlugins/corePlugins.d.ts +4 -2
- package/internals/plugins/corePlugins/corePlugins.js +3 -1
- package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -29
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +0 -6
- package/internals/plugins/corePlugins/useChartExperimentalFeature/index.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/index.js +27 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.js +34 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.d.ts +8 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.selectors.js +10 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +21 -0
- package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js +5 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.js +1 -0
- package/internals/plugins/corePlugins/useChartId/useChartId.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartInteractionListener/index.d.ts +2 -0
- package/internals/plugins/corePlugins/useChartInteractionListener/index.js +12 -0
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.d.ts +3 -0
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +84 -0
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +31 -0
- package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.js +5 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +5 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +4 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +1 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +4 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +7 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.js +21 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.d.ts +2 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/index.js +24 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartAxisSize.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +90 -36
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +18 -1
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +82 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +9 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +47 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +55 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +18 -12
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js +18 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/zoom.types.d.ts +6 -1
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +34 -34
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.js +46 -30
- package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartZAxis/useChartZAxis.selectors.d.ts +1 -1
- package/internals/plugins/utils/useLazySelectorEffect.d.ts +7 -0
- package/internals/plugins/utils/useLazySelectorEffect.js +77 -0
- package/internals/store/useCharts.d.ts +1 -1
- package/locales/elGR.d.ts +19 -0
- package/locales/elGR.js +21 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +11 -0
- package/models/axis.d.ts +15 -0
- package/models/axis.js +4 -0
- package/models/index.d.ts +1 -1
- package/models/seriesType/scatter.d.ts +11 -2
- package/package.json +4 -3
- package/themeAugmentation/components.d.ts +3 -0
- package/themeAugmentation/props.d.ts +2 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import getColor from "./seriesConfig/getColor.js";
|
|
2
|
+
import { useChartId, useXAxes, useYAxes } from "../hooks/index.js";
|
|
3
|
+
import { checkScaleErrors } from "./checkScaleErrors.js";
|
|
4
|
+
import { useBarSeriesContext } from "../hooks/useBarSeries.js";
|
|
5
|
+
export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
6
|
+
const seriesData = useBarSeriesContext() ?? {
|
|
7
|
+
series: {},
|
|
8
|
+
stackingGroups: [],
|
|
9
|
+
seriesOrder: []
|
|
10
|
+
};
|
|
11
|
+
const defaultXAxisId = useXAxes().xAxisIds[0];
|
|
12
|
+
const defaultYAxisId = useYAxes().yAxisIds[0];
|
|
13
|
+
const chartId = useChartId();
|
|
14
|
+
const {
|
|
15
|
+
series,
|
|
16
|
+
stackingGroups
|
|
17
|
+
} = seriesData;
|
|
18
|
+
const masks = {};
|
|
19
|
+
const data = stackingGroups.flatMap(({
|
|
20
|
+
ids: seriesIds
|
|
21
|
+
}, groupIndex) => {
|
|
22
|
+
const xMin = drawingArea.left;
|
|
23
|
+
const xMax = drawingArea.left + drawingArea.width;
|
|
24
|
+
const yMin = drawingArea.top;
|
|
25
|
+
const yMax = drawingArea.top + drawingArea.height;
|
|
26
|
+
return seriesIds.map(seriesId => {
|
|
27
|
+
const xAxisId = series[seriesId].xAxisId ?? defaultXAxisId;
|
|
28
|
+
const yAxisId = series[seriesId].yAxisId ?? defaultYAxisId;
|
|
29
|
+
const xAxisConfig = xAxes[xAxisId];
|
|
30
|
+
const yAxisConfig = yAxes[yAxisId];
|
|
31
|
+
const verticalLayout = series[seriesId].layout === 'vertical';
|
|
32
|
+
checkScaleErrors(verticalLayout, seriesId, series[seriesId], xAxisId, xAxes, yAxisId, yAxes);
|
|
33
|
+
const baseScaleConfig = verticalLayout ? xAxisConfig : yAxisConfig;
|
|
34
|
+
const xScale = xAxisConfig.scale;
|
|
35
|
+
const yScale = yAxisConfig.scale;
|
|
36
|
+
const colorGetter = getColor(series[seriesId], xAxes[xAxisId], yAxes[yAxisId]);
|
|
37
|
+
const bandWidth = baseScaleConfig.scale.bandwidth();
|
|
38
|
+
const {
|
|
39
|
+
barWidth,
|
|
40
|
+
offset
|
|
41
|
+
} = getBandSize({
|
|
42
|
+
bandWidth,
|
|
43
|
+
numberOfGroups: stackingGroups.length,
|
|
44
|
+
gapRatio: baseScaleConfig.barGapRatio
|
|
45
|
+
});
|
|
46
|
+
const barOffset = groupIndex * (barWidth + offset);
|
|
47
|
+
const {
|
|
48
|
+
stackedData,
|
|
49
|
+
data: currentSeriesData,
|
|
50
|
+
layout
|
|
51
|
+
} = series[seriesId];
|
|
52
|
+
const seriesDataPoints = baseScaleConfig.data.map((baseValue, dataIndex) => {
|
|
53
|
+
if (currentSeriesData[dataIndex] == null) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const values = stackedData[dataIndex];
|
|
57
|
+
const valueCoordinates = values.map(v => verticalLayout ? yScale(v) : xScale(v));
|
|
58
|
+
const minValueCoord = Math.round(Math.min(...valueCoordinates));
|
|
59
|
+
const maxValueCoord = Math.round(Math.max(...valueCoordinates));
|
|
60
|
+
const stackId = series[seriesId].stack;
|
|
61
|
+
const result = {
|
|
62
|
+
seriesId,
|
|
63
|
+
dataIndex,
|
|
64
|
+
layout,
|
|
65
|
+
x: verticalLayout ? xScale(baseValue) + barOffset : minValueCoord,
|
|
66
|
+
y: verticalLayout ? minValueCoord : yScale(baseValue) + barOffset,
|
|
67
|
+
xOrigin: xScale(0) ?? 0,
|
|
68
|
+
yOrigin: yScale(0) ?? 0,
|
|
69
|
+
height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
|
|
70
|
+
width: verticalLayout ? barWidth : maxValueCoord - minValueCoord,
|
|
71
|
+
color: colorGetter(dataIndex),
|
|
72
|
+
value: currentSeriesData[dataIndex],
|
|
73
|
+
maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
|
|
74
|
+
};
|
|
75
|
+
if (result.x > xMax || result.x + result.width < xMin || result.y > yMax || result.y + result.height < yMin) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
if (!masks[result.maskId]) {
|
|
79
|
+
masks[result.maskId] = {
|
|
80
|
+
id: result.maskId,
|
|
81
|
+
width: 0,
|
|
82
|
+
height: 0,
|
|
83
|
+
hasNegative: false,
|
|
84
|
+
hasPositive: false,
|
|
85
|
+
layout: result.layout,
|
|
86
|
+
xOrigin: xScale(0),
|
|
87
|
+
yOrigin: yScale(0),
|
|
88
|
+
x: 0,
|
|
89
|
+
y: 0
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const mask = masks[result.maskId];
|
|
93
|
+
mask.width = result.layout === 'vertical' ? result.width : mask.width + result.width;
|
|
94
|
+
mask.height = result.layout === 'vertical' ? mask.height + result.height : result.height;
|
|
95
|
+
mask.x = Math.min(mask.x === 0 ? Infinity : mask.x, result.x);
|
|
96
|
+
mask.y = Math.min(mask.y === 0 ? Infinity : mask.y, result.y);
|
|
97
|
+
mask.hasNegative = mask.hasNegative || (result.value ?? 0) < 0;
|
|
98
|
+
mask.hasPositive = mask.hasPositive || (result.value ?? 0) > 0;
|
|
99
|
+
return result;
|
|
100
|
+
}).filter(rectangle => rectangle !== null);
|
|
101
|
+
return {
|
|
102
|
+
seriesId,
|
|
103
|
+
data: seriesDataPoints
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
completedData: data,
|
|
109
|
+
masksData: Object.values(masks)
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Solution of the equations
|
|
115
|
+
* W = barWidth * N + offset * (N-1)
|
|
116
|
+
* offset / (offset + barWidth) = r
|
|
117
|
+
* @param bandWidth The width available to place bars.
|
|
118
|
+
* @param numberOfGroups The number of bars to place in that space.
|
|
119
|
+
* @param gapRatio The ratio of the gap between bars over the bar width.
|
|
120
|
+
* @returns The bar width and the offset between bars.
|
|
121
|
+
*/
|
|
122
|
+
function getBandSize({
|
|
123
|
+
bandWidth: W,
|
|
124
|
+
numberOfGroups: N,
|
|
125
|
+
gapRatio: r
|
|
126
|
+
}) {
|
|
127
|
+
if (r === 0) {
|
|
128
|
+
return {
|
|
129
|
+
barWidth: W / N,
|
|
130
|
+
offset: 0
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
const barWidth = W / (N + (N - 1) * r);
|
|
134
|
+
const offset = r * barWidth;
|
|
135
|
+
return {
|
|
136
|
+
barWidth,
|
|
137
|
+
offset
|
|
138
|
+
};
|
|
139
|
+
}
|
|
@@ -1,30 +1,10 @@
|
|
|
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";
|
|
6
2
|
import { ChartSeriesType } from "../models/seriesType/config.js";
|
|
7
3
|
import { ChartDataProviderProps } from "../ChartDataProvider/index.js";
|
|
8
4
|
import { ChartsSurfaceProps } from "../ChartsSurface/index.js";
|
|
9
|
-
import { AllPluginSignatures
|
|
5
|
+
import { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
10
6
|
import { ChartAnyPluginSignature } from "../internals/plugins/models/plugin.js";
|
|
11
|
-
import { ChartPublicAPI } from "../internals/plugins/models/index.js";
|
|
12
7
|
export type ChartContainerProps<SeriesType extends ChartSeriesType = ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[] = AllPluginSignatures<SeriesType>> = Omit<ChartDataProviderProps<SeriesType, TSignatures>, 'children'> & ChartsSurfaceProps;
|
|
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>;
|
|
28
8
|
/**
|
|
29
9
|
* It sets up the data providers as well as the `<svg>` for the chart.
|
|
30
10
|
*
|
|
@@ -6,14 +6,6 @@ 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
|
-
*/
|
|
17
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
10
|
/**
|
|
19
11
|
* It sets up the data providers as well as the `<svg>` for the chart.
|
|
@@ -84,10 +76,24 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
84
76
|
* If true, the voronoi interaction are ignored.
|
|
85
77
|
*/
|
|
86
78
|
disableVoronoi: PropTypes.bool,
|
|
79
|
+
/**
|
|
80
|
+
* Options to enable features planned for the next major.
|
|
81
|
+
*/
|
|
82
|
+
experimentalFeatures: PropTypes.shape({
|
|
83
|
+
preferStrictDomainInLineCharts: PropTypes.bool
|
|
84
|
+
}),
|
|
87
85
|
/**
|
|
88
86
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
89
87
|
*/
|
|
90
88
|
height: PropTypes.number,
|
|
89
|
+
/**
|
|
90
|
+
* The controlled axis highlight.
|
|
91
|
+
* Identified by the axis id, and data index.
|
|
92
|
+
*/
|
|
93
|
+
highlightedAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
94
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
95
|
+
dataIndex: PropTypes.number.isRequired
|
|
96
|
+
})),
|
|
91
97
|
/**
|
|
92
98
|
* The highlighted item.
|
|
93
99
|
* Used when the highlight is controlled.
|
|
@@ -130,6 +136,14 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
130
136
|
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
131
137
|
*/
|
|
132
138
|
onHighlightChange: PropTypes.func,
|
|
139
|
+
/**
|
|
140
|
+
* The function called when the pointer position corresponds to a new axis data item.
|
|
141
|
+
* This update can either be caused by a pointer movement, or an axis update.
|
|
142
|
+
* In case of multiple axes, the function is called if at least one axis is updated.
|
|
143
|
+
* The argument contains the identifier for all axes with a `data` property.
|
|
144
|
+
* @param {AxisItemIdentifier[]} axisItems The array of axes item identifiers.
|
|
145
|
+
*/
|
|
146
|
+
onHighlightedAxisChange: PropTypes.func,
|
|
133
147
|
/**
|
|
134
148
|
* Callback fired when clicking close to an item.
|
|
135
149
|
* This is only available for scatter plot for now.
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { ChartApi as ChartApiOriginal, PluginsPerSeriesType } from "../context/ChartApi.js";
|
|
2
|
+
import type { ChartAnyPluginSignature } from "../internals/plugins/models/plugin.js";
|
|
3
|
+
import type { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
4
|
+
export * from "./ChartContainer.js";
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use `ChartApi` from `@mui/x-charts/context` instead.
|
|
7
|
+
*/
|
|
8
|
+
export type ChartApi<TSeries extends keyof PluginsPerSeriesType | undefined = undefined, TSignatures extends readonly ChartAnyPluginSignature[] = (TSeries extends keyof PluginsPerSeriesType ? PluginsPerSeriesType[TSeries] : AllPluginSignatures)> = ChartApiOriginal<TSeries, TSignatures>;
|
|
@@ -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", "slots", "slotProps"];
|
|
5
|
+
const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "onAxisClick", "highlightedAxis", "onHighlightedAxisChange", "disableVoronoi", "voronoiMaxRadius", "onItemClick", "disableAxisListener", "highlightedItem", "onHighlightChange", "sx", "title", "xAxis", "yAxis", "zAxis", "rotationAxis", "radiusAxis", "skipAnimation", "seriesConfig", "plugins", "localeText", "slots", "slotProps", "experimentalFeatures"];
|
|
6
6
|
import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
|
|
7
7
|
export const useChartContainerProps = (props, ref) => {
|
|
8
8
|
const _ref = props,
|
|
@@ -16,6 +16,8 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
16
16
|
dataset,
|
|
17
17
|
desc,
|
|
18
18
|
onAxisClick,
|
|
19
|
+
highlightedAxis,
|
|
20
|
+
onHighlightedAxisChange,
|
|
19
21
|
disableVoronoi,
|
|
20
22
|
voronoiMaxRadius,
|
|
21
23
|
onItemClick,
|
|
@@ -34,7 +36,8 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
34
36
|
plugins,
|
|
35
37
|
localeText,
|
|
36
38
|
slots,
|
|
37
|
-
slotProps
|
|
39
|
+
slotProps,
|
|
40
|
+
experimentalFeatures
|
|
38
41
|
} = _ref,
|
|
39
42
|
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
40
43
|
const chartsSurfaceProps = _extends({
|
|
@@ -52,6 +55,8 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
52
55
|
highlightedItem,
|
|
53
56
|
onHighlightChange,
|
|
54
57
|
onAxisClick,
|
|
58
|
+
highlightedAxis,
|
|
59
|
+
onHighlightedAxisChange,
|
|
55
60
|
disableVoronoi,
|
|
56
61
|
voronoiMaxRadius,
|
|
57
62
|
onItemClick,
|
|
@@ -65,6 +70,7 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
65
70
|
height,
|
|
66
71
|
localeText,
|
|
67
72
|
seriesConfig,
|
|
73
|
+
experimentalFeatures,
|
|
68
74
|
plugins: plugins ?? DEFAULT_PLUGINS,
|
|
69
75
|
slots,
|
|
70
76
|
slotProps
|
|
@@ -73,6 +73,12 @@ process.env.NODE_ENV !== "production" ? ChartDataProvider.propTypes = {
|
|
|
73
73
|
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
74
74
|
*/
|
|
75
75
|
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
76
|
+
/**
|
|
77
|
+
* Options to enable features planned for the next major.
|
|
78
|
+
*/
|
|
79
|
+
experimentalFeatures: PropTypes.shape({
|
|
80
|
+
preferStrictDomainInLineCharts: PropTypes.bool
|
|
81
|
+
}),
|
|
76
82
|
/**
|
|
77
83
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
78
84
|
*/
|
|
@@ -4,7 +4,7 @@ import { ChartAnyPluginSignature } from "../internals/plugins/models/index.js";
|
|
|
4
4
|
import { ChartSeriesType } from "../models/seriesType/config.js";
|
|
5
5
|
import { AllPluginSignatures } from "../internals/plugins/allPlugins.js";
|
|
6
6
|
import { ChartsLocalizationProviderProps } from "../ChartsLocalizationProvider/index.js";
|
|
7
|
-
export declare const useChartDataProviderProps: <TSeries extends ChartSeriesType = ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[] = AllPluginSignatures<TSeries>>(
|
|
7
|
+
export declare const useChartDataProviderProps: <TSeries extends ChartSeriesType = ChartSeriesType, TSignatures extends readonly ChartAnyPluginSignature[] = AllPluginSignatures<TSeries>>(inProps: ChartDataProviderProps<TSeries, TSignatures> & ChartsLocalizationProviderProps) => {
|
|
8
8
|
children: import("react").ReactNode;
|
|
9
9
|
localeText: Partial<import("../locales/index.js").ChartsLocaleText> | undefined;
|
|
10
10
|
chartProviderProps: ChartProviderProps<TSeries, TSignatures>;
|
|
@@ -3,9 +3,14 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
5
|
const _excluded = ["children", "localeText", "plugins", "seriesConfig", "slots", "slotProps"];
|
|
6
|
-
import { useTheme } from '@mui/material/styles';
|
|
6
|
+
import { useTheme, useThemeProps } from '@mui/material/styles';
|
|
7
7
|
import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
|
|
8
|
-
export const useChartDataProviderProps =
|
|
8
|
+
export const useChartDataProviderProps = inProps => {
|
|
9
|
+
// eslint-disable-next-line material-ui/mui-name-matches-component-name
|
|
10
|
+
const props = useThemeProps({
|
|
11
|
+
props: inProps,
|
|
12
|
+
name: 'MuiChartDataProvider'
|
|
13
|
+
});
|
|
9
14
|
const {
|
|
10
15
|
children,
|
|
11
16
|
localeText,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { getValueToPositionMapper
|
|
4
|
+
import { getValueToPositionMapper } from "../hooks/useScale.js";
|
|
5
5
|
import { isBandScale } from "../internals/isBandScale.js";
|
|
6
6
|
import { useSelector } from "../internals/store/useSelector.js";
|
|
7
7
|
import { useStore } from "../internals/store/useStore.js";
|
|
8
|
-
import {
|
|
8
|
+
import { selectorChartsHighlightXAxisValue, selectorChartXAxis } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
9
9
|
import { useDrawingArea } from "../hooks/index.js";
|
|
10
10
|
import { ChartsAxisHighlightPath } from "./ChartsAxisHighlightPath.js";
|
|
11
11
|
|
|
@@ -22,32 +22,42 @@ export default function ChartsXHighlight(props) {
|
|
|
22
22
|
top,
|
|
23
23
|
height
|
|
24
24
|
} = useDrawingArea();
|
|
25
|
-
const xScale = useXScale();
|
|
26
25
|
const store = useStore();
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const isError = isBandScaleX && xScale(axisXValue) === undefined;
|
|
32
|
-
if (isError) {
|
|
33
|
-
console.error([`MUI X Charts: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
|
|
34
|
-
}
|
|
26
|
+
const axisXValues = useSelector(store, selectorChartsHighlightXAxisValue);
|
|
27
|
+
const xAxes = useSelector(store, selectorChartXAxis);
|
|
28
|
+
if (axisXValues.length === 0) {
|
|
29
|
+
return null;
|
|
35
30
|
}
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
ownerState: {
|
|
49
|
-
axisHighlight: 'line'
|
|
31
|
+
return axisXValues.map(({
|
|
32
|
+
axisId,
|
|
33
|
+
value
|
|
34
|
+
}) => {
|
|
35
|
+
const xAxis = xAxes.axis[axisId];
|
|
36
|
+
const xScale = xAxis.scale;
|
|
37
|
+
const getXPosition = getValueToPositionMapper(xScale);
|
|
38
|
+
const isBandScaleX = type === 'band' && value !== null && isBandScale(xScale);
|
|
39
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
40
|
+
const isError = isBandScaleX && xScale(value) === undefined;
|
|
41
|
+
if (isError) {
|
|
42
|
+
console.error([`MUI X Charts: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
|
|
50
43
|
}
|
|
51
|
-
}
|
|
44
|
+
}
|
|
45
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
46
|
+
children: [isBandScaleX && xScale(value) !== undefined && /*#__PURE__*/_jsx(ChartsAxisHighlightPath
|
|
47
|
+
// @ts-expect-error, xScale value is checked in the statement above
|
|
48
|
+
, {
|
|
49
|
+
d: `M ${xScale(value) - (xScale.step() - xScale.bandwidth()) / 2} ${top} l ${xScale.step()} 0 l 0 ${height} l ${-xScale.step()} 0 Z`,
|
|
50
|
+
className: classes.root,
|
|
51
|
+
ownerState: {
|
|
52
|
+
axisHighlight: 'band'
|
|
53
|
+
}
|
|
54
|
+
}), type === 'line' && value !== null && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
|
|
55
|
+
d: `M ${getXPosition(value)} ${top} L ${getXPosition(value)} ${top + height}`,
|
|
56
|
+
className: classes.root,
|
|
57
|
+
ownerState: {
|
|
58
|
+
axisHighlight: 'line'
|
|
59
|
+
}
|
|
60
|
+
})]
|
|
61
|
+
}, `${axisId}-${value}`);
|
|
52
62
|
});
|
|
53
63
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import { getValueToPositionMapper
|
|
4
|
+
import { getValueToPositionMapper } from "../hooks/useScale.js";
|
|
5
5
|
import { isBandScale } from "../internals/isBandScale.js";
|
|
6
6
|
import { useSelector } from "../internals/store/useSelector.js";
|
|
7
7
|
import { useStore } from "../internals/store/useStore.js";
|
|
8
|
-
import {
|
|
8
|
+
import { selectorChartsHighlightYAxisValue, selectorChartYAxis } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
9
9
|
import { useDrawingArea } from "../hooks/index.js";
|
|
10
10
|
import { ChartsAxisHighlightPath } from "./ChartsAxisHighlightPath.js";
|
|
11
11
|
|
|
@@ -22,32 +22,42 @@ export default function ChartsYHighlight(props) {
|
|
|
22
22
|
left,
|
|
23
23
|
width
|
|
24
24
|
} = useDrawingArea();
|
|
25
|
-
const yScale = useYScale();
|
|
26
25
|
const store = useStore();
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const isError = isBandScaleY && yScale(axisYValue) === undefined;
|
|
32
|
-
if (isError) {
|
|
33
|
-
console.error([`MUI X Charts: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
|
|
34
|
-
}
|
|
26
|
+
const axisYValues = useSelector(store, selectorChartsHighlightYAxisValue);
|
|
27
|
+
const yAxes = useSelector(store, selectorChartYAxis);
|
|
28
|
+
if (axisYValues.length === 0) {
|
|
29
|
+
return null;
|
|
35
30
|
}
|
|
36
|
-
return
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
ownerState: {
|
|
49
|
-
axisHighlight: 'line'
|
|
31
|
+
return axisYValues.map(({
|
|
32
|
+
axisId,
|
|
33
|
+
value
|
|
34
|
+
}) => {
|
|
35
|
+
const yAxis = yAxes.axis[axisId];
|
|
36
|
+
const yScale = yAxis.scale;
|
|
37
|
+
const getYPosition = getValueToPositionMapper(yScale);
|
|
38
|
+
const isBandScaleY = type === 'band' && value !== null && isBandScale(yScale);
|
|
39
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
40
|
+
const isError = isBandScaleY && yScale(value) === undefined;
|
|
41
|
+
if (isError) {
|
|
42
|
+
console.error([`MUI X Charts: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
|
|
50
43
|
}
|
|
51
|
-
}
|
|
44
|
+
}
|
|
45
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
46
|
+
children: [isBandScaleY && yScale(value) !== undefined && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
|
|
47
|
+
d: `M ${left} ${
|
|
48
|
+
// @ts-expect-error, yScale value is checked in the statement above
|
|
49
|
+
yScale(value) - (yScale.step() - yScale.bandwidth()) / 2} l 0 ${yScale.step()} l ${width} 0 l 0 ${-yScale.step()} Z`,
|
|
50
|
+
className: classes.root,
|
|
51
|
+
ownerState: {
|
|
52
|
+
axisHighlight: 'band'
|
|
53
|
+
}
|
|
54
|
+
}), type === 'line' && value !== null && /*#__PURE__*/_jsx(ChartsAxisHighlightPath, {
|
|
55
|
+
d: `M ${left} ${getYPosition(value)} L ${left + width} ${getYPosition(value)}`,
|
|
56
|
+
className: classes.root,
|
|
57
|
+
ownerState: {
|
|
58
|
+
axisHighlight: 'line'
|
|
59
|
+
}
|
|
60
|
+
})]
|
|
61
|
+
}, `${axisId}-${value}`);
|
|
52
62
|
});
|
|
53
63
|
}
|
|
@@ -10,4 +10,7 @@ export type ChartsXReferenceLineProps<TValue extends string | number | Date = st
|
|
|
10
10
|
};
|
|
11
11
|
export declare function getXReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
|
|
12
12
|
declare function ChartsXReferenceLine(props: ChartsXReferenceLineProps): React.JSX.Element | null;
|
|
13
|
+
declare namespace ChartsXReferenceLine {
|
|
14
|
+
var propTypes: any;
|
|
15
|
+
}
|
|
13
16
|
export { ChartsXReferenceLine };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
5
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
7
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
7
8
|
import { useDrawingArea, useXScale } from "../hooks/index.js";
|
|
@@ -99,4 +100,50 @@ function ChartsXReferenceLine(props) {
|
|
|
99
100
|
}))]
|
|
100
101
|
});
|
|
101
102
|
}
|
|
103
|
+
process.env.NODE_ENV !== "production" ? ChartsXReferenceLine.propTypes = {
|
|
104
|
+
// ----------------------------- Warning --------------------------------
|
|
105
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
106
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
107
|
+
// ----------------------------------------------------------------------
|
|
108
|
+
/**
|
|
109
|
+
* The id of the axis used for the reference value.
|
|
110
|
+
* @default The `id` of the first defined axis.
|
|
111
|
+
*/
|
|
112
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
113
|
+
/**
|
|
114
|
+
* Override or extend the styles applied to the component.
|
|
115
|
+
*/
|
|
116
|
+
classes: PropTypes.object,
|
|
117
|
+
/**
|
|
118
|
+
* The label to display along the reference line.
|
|
119
|
+
*/
|
|
120
|
+
label: PropTypes.string,
|
|
121
|
+
/**
|
|
122
|
+
* The alignment if the label is in the chart drawing area.
|
|
123
|
+
* @default 'middle'
|
|
124
|
+
*/
|
|
125
|
+
labelAlign: PropTypes.oneOf(['end', 'middle', 'start']),
|
|
126
|
+
/**
|
|
127
|
+
* The style applied to the label.
|
|
128
|
+
*/
|
|
129
|
+
labelStyle: PropTypes.object,
|
|
130
|
+
/**
|
|
131
|
+
* The style applied to the line.
|
|
132
|
+
*/
|
|
133
|
+
lineStyle: PropTypes.object,
|
|
134
|
+
/**
|
|
135
|
+
* Additional space around the label in px.
|
|
136
|
+
* Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
|
|
137
|
+
* @default 5
|
|
138
|
+
*/
|
|
139
|
+
spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
140
|
+
x: PropTypes.number,
|
|
141
|
+
y: PropTypes.number
|
|
142
|
+
})]),
|
|
143
|
+
/**
|
|
144
|
+
* The x value associated with the reference line.
|
|
145
|
+
* If defined the reference line will be vertical.
|
|
146
|
+
*/
|
|
147
|
+
x: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
148
|
+
} : void 0;
|
|
102
149
|
export { ChartsXReferenceLine };
|
|
@@ -10,4 +10,7 @@ export type ChartsYReferenceLineProps<TValue extends string | number | Date = st
|
|
|
10
10
|
};
|
|
11
11
|
export declare function getYReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"root" | "line" | "label", string>;
|
|
12
12
|
declare function ChartsYReferenceLine(props: ChartsYReferenceLineProps): React.JSX.Element | null;
|
|
13
|
+
declare namespace ChartsYReferenceLine {
|
|
14
|
+
var propTypes: any;
|
|
15
|
+
}
|
|
13
16
|
export { ChartsYReferenceLine };
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
5
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
6
7
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
7
8
|
import { useDrawingArea, useYScale } from "../hooks/index.js";
|
|
@@ -99,4 +100,50 @@ function ChartsYReferenceLine(props) {
|
|
|
99
100
|
}))]
|
|
100
101
|
});
|
|
101
102
|
}
|
|
103
|
+
process.env.NODE_ENV !== "production" ? ChartsYReferenceLine.propTypes = {
|
|
104
|
+
// ----------------------------- Warning --------------------------------
|
|
105
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
106
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
107
|
+
// ----------------------------------------------------------------------
|
|
108
|
+
/**
|
|
109
|
+
* The id of the axis used for the reference value.
|
|
110
|
+
* @default The `id` of the first defined axis.
|
|
111
|
+
*/
|
|
112
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
113
|
+
/**
|
|
114
|
+
* Override or extend the styles applied to the component.
|
|
115
|
+
*/
|
|
116
|
+
classes: PropTypes.object,
|
|
117
|
+
/**
|
|
118
|
+
* The label to display along the reference line.
|
|
119
|
+
*/
|
|
120
|
+
label: PropTypes.string,
|
|
121
|
+
/**
|
|
122
|
+
* The alignment if the label is in the chart drawing area.
|
|
123
|
+
* @default 'middle'
|
|
124
|
+
*/
|
|
125
|
+
labelAlign: PropTypes.oneOf(['end', 'middle', 'start']),
|
|
126
|
+
/**
|
|
127
|
+
* The style applied to the label.
|
|
128
|
+
*/
|
|
129
|
+
labelStyle: PropTypes.object,
|
|
130
|
+
/**
|
|
131
|
+
* The style applied to the line.
|
|
132
|
+
*/
|
|
133
|
+
lineStyle: PropTypes.object,
|
|
134
|
+
/**
|
|
135
|
+
* Additional space around the label in px.
|
|
136
|
+
* Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
|
|
137
|
+
* @default 5
|
|
138
|
+
*/
|
|
139
|
+
spacing: PropTypes.oneOfType([PropTypes.number, PropTypes.shape({
|
|
140
|
+
x: PropTypes.number,
|
|
141
|
+
y: PropTypes.number
|
|
142
|
+
})]),
|
|
143
|
+
/**
|
|
144
|
+
* The y value associated with the reference line.
|
|
145
|
+
* If defined the reference line will be horizontal.
|
|
146
|
+
*/
|
|
147
|
+
y: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number, PropTypes.string]).isRequired
|
|
148
|
+
} : void 0;
|
|
102
149
|
export { ChartsYReferenceLine };
|