@mui/x-charts 8.7.0 → 8.9.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 +4 -3
- package/BarChart/BarChart.js +17 -1
- package/BarChart/barClasses.d.ts +1 -1
- package/BarChart/seriesConfig/seriesProcessor.js +5 -3
- package/BarChart/useBarPlotData.js +32 -5
- package/CHANGELOG.md +199 -24
- package/ChartContainer/ChartContainer.js +22 -0
- 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/ChartsLabel/ChartsLabelMark.d.ts +2 -1
- package/ChartsLabel/index.d.ts +1 -0
- package/ChartsLabel/index.js +18 -0
- package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
- package/Gauge/GaugeContainer.d.ts +1 -1
- package/LineChart/LineChart.d.ts +3 -2
- package/LineChart/LineChart.js +23 -1
- package/LineChart/LineHighlightPlot.js +10 -4
- package/LineChart/MarkPlot.js +17 -3
- package/LineChart/useAreaPlotData.js +3 -2
- package/PieChart/PieArcLabelPlot.js +3 -0
- package/PieChart/PieArcPlot.js +3 -0
- package/PieChart/PieChart.d.ts +4 -3
- package/PieChart/PieChart.js +1 -1
- package/PieChart/pieClasses.d.ts +1 -1
- package/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
- package/RadarChart/RadarChart.d.ts +2 -1
- package/RadarChart/RadarChart.js +23 -2
- package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +4 -3
- package/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
- package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
- package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
- package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +38 -0
- package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/RadarChart/index.d.ts +1 -1
- package/RadarChart/useRadarChartProps.d.ts +3 -0
- package/RadarChart/useRadarChartProps.js +15 -3
- package/ScatterChart/ScatterChart.d.ts +4 -3
- package/ScatterChart/ScatterChart.js +1 -1
- package/ScatterChart/ScatterPlot.js +2 -2
- package/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
- package/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/SparkLineChart/SparkLineChart.js +16 -0
- package/esm/BarChart/BarChart.d.ts +4 -3
- package/esm/BarChart/BarChart.js +17 -1
- package/esm/BarChart/barClasses.d.ts +1 -1
- package/esm/BarChart/seriesConfig/seriesProcessor.js +5 -3
- package/esm/BarChart/useBarPlotData.js +32 -5
- package/esm/ChartContainer/ChartContainer.js +22 -0
- 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/ChartsLabel/ChartsLabelMark.d.ts +2 -1
- package/esm/ChartsLabel/index.d.ts +1 -0
- package/esm/ChartsLabel/index.js +1 -0
- package/esm/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/esm/ChartsLegend/piecewiseColorLegendClasses.d.ts +1 -1
- package/esm/Gauge/GaugeContainer.d.ts +1 -1
- package/esm/LineChart/LineChart.d.ts +3 -2
- package/esm/LineChart/LineChart.js +23 -1
- package/esm/LineChart/LineHighlightPlot.js +11 -5
- package/esm/LineChart/MarkPlot.js +17 -3
- package/esm/LineChart/useAreaPlotData.js +3 -2
- package/esm/PieChart/PieArcLabelPlot.js +3 -0
- package/esm/PieChart/PieArcPlot.js +3 -0
- package/esm/PieChart/PieChart.d.ts +4 -3
- package/esm/PieChart/PieChart.js +1 -1
- package/esm/PieChart/pieClasses.d.ts +1 -1
- package/esm/RadarChart/RadarAxisHighlight/RadarAxisHighlight.js +3 -5
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.d.ts +2 -13
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +8 -45
- package/esm/RadarChart/RadarChart.d.ts +2 -1
- package/esm/RadarChart/RadarChart.js +23 -2
- package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +4 -3
- package/esm/RadarChart/RadarMetricLabels/useRadarMetricData.js +4 -2
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +19 -3
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +20 -4
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.js +38 -4
- package/esm/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +32 -3
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.d.ts +8 -0
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +32 -0
- package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +2 -2
- package/esm/RadarChart/index.d.ts +1 -1
- package/esm/RadarChart/useRadarChartProps.d.ts +3 -0
- package/esm/RadarChart/useRadarChartProps.js +15 -3
- package/esm/ScatterChart/ScatterChart.d.ts +4 -3
- package/esm/ScatterChart/ScatterChart.js +1 -1
- package/esm/ScatterChart/ScatterPlot.js +2 -2
- package/esm/ScatterChart/seriesConfig/seriesProcessor.js +3 -0
- package/esm/SparkLineChart/SparkLineChart.d.ts +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +16 -0
- package/esm/hooks/useAxis.d.ts +2 -2
- package/esm/hooks/useTicks.d.ts +6 -1
- package/esm/hooks/useTicks.js +94 -58
- package/esm/index.js +1 -1
- 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 +1 -0
- package/esm/internals/index.js +1 -0
- package/esm/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
- package/esm/internals/plugins/corePlugins/corePlugins.js +2 -1
- package/esm/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- 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.selectors.d.ts +1 -1
- 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 +46 -3
- 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/createIsFaded.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +19 -11
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
- package/esm/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +19 -11
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
- package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
- 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/models/axis.d.ts +42 -1
- package/esm/models/axis.js +4 -0
- package/esm/models/index.d.ts +1 -1
- package/esm/models/seriesType/bar.d.ts +11 -1
- package/esm/models/seriesType/common.d.ts +9 -3
- package/esm/models/seriesType/line.d.ts +3 -1
- package/esm/models/seriesType/scatter.d.ts +14 -2
- package/esm/tests/web-components.js +49 -0
- 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/useTicks.d.ts +6 -1
- package/hooks/useTicks.js +95 -58
- package/index.js +1 -1
- 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 +1 -0
- package/internals/index.js +8 -0
- package/internals/plugins/corePlugins/corePlugins.d.ts +3 -2
- package/internals/plugins/corePlugins/corePlugins.js +2 -1
- package/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.selectors.d.ts +1 -1
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- 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.selectors.d.ts +1 -1
- 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 +46 -3
- 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/createIsFaded.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsFaded.js +20 -13
- package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.d.ts +1 -1
- package/internals/plugins/featurePlugins/useChartHighlight/createIsHighlighted.js +20 -13
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +10 -4
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +4 -4
- package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -6
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +44 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +8 -1
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +7 -8
- 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/models/axis.d.ts +42 -1
- package/models/axis.js +4 -0
- package/models/index.d.ts +1 -1
- package/models/seriesType/bar.d.ts +11 -1
- package/models/seriesType/common.d.ts +9 -3
- package/models/seriesType/line.d.ts +3 -1
- package/models/seriesType/scatter.d.ts +14 -2
- package/package.json +5 -5
- package/tests/web-components.js +55 -0
- package/themeAugmentation/components.d.ts +3 -0
- package/themeAugmentation/props.d.ts +2 -0
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { stack as d3Stack } from '@mui/x-charts-vendor/d3-shape';
|
|
3
3
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
4
4
|
import { getStackingGroups } from "../../internals/stackSeries.js";
|
|
5
|
-
|
|
5
|
+
const barValueFormatter = v => v == null ? '' : v.toLocaleString();
|
|
6
6
|
const seriesProcessor = (params, dataset) => {
|
|
7
7
|
const {
|
|
8
8
|
seriesOrder,
|
|
@@ -46,7 +46,9 @@ const seriesProcessor = (params, dataset) => {
|
|
|
46
46
|
const dataKey = series[id].dataKey;
|
|
47
47
|
completedSeries[id] = _extends({
|
|
48
48
|
layout: 'vertical',
|
|
49
|
-
labelMarkType: 'square'
|
|
49
|
+
labelMarkType: 'square',
|
|
50
|
+
minBarSize: 0,
|
|
51
|
+
valueFormatter: series[id].valueFormatter ?? barValueFormatter
|
|
50
52
|
}, series[id], {
|
|
51
53
|
data: dataKey ? dataset.map(data => {
|
|
52
54
|
const value = data[dataKey];
|
|
@@ -67,7 +69,7 @@ const seriesProcessor = (params, dataset) => {
|
|
|
67
69
|
return {
|
|
68
70
|
seriesOrder,
|
|
69
71
|
stackingGroups,
|
|
70
|
-
series:
|
|
72
|
+
series: completedSeries
|
|
71
73
|
};
|
|
72
74
|
};
|
|
73
75
|
export default seriesProcessor;
|
|
@@ -47,7 +47,8 @@ export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
47
47
|
const {
|
|
48
48
|
stackedData,
|
|
49
49
|
data: currentSeriesData,
|
|
50
|
-
layout
|
|
50
|
+
layout,
|
|
51
|
+
minBarSize
|
|
51
52
|
} = series[seriesId];
|
|
52
53
|
const seriesDataPoints = baseScaleConfig.data.map((baseValue, dataIndex) => {
|
|
53
54
|
if (currentSeriesData[dataIndex] == null) {
|
|
@@ -58,16 +59,20 @@ export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
58
59
|
const minValueCoord = Math.round(Math.min(...valueCoordinates));
|
|
59
60
|
const maxValueCoord = Math.round(Math.max(...valueCoordinates));
|
|
60
61
|
const stackId = series[seriesId].stack;
|
|
62
|
+
const {
|
|
63
|
+
barSize,
|
|
64
|
+
startCoordinate
|
|
65
|
+
} = getValueCoordinate(verticalLayout, minValueCoord, maxValueCoord, currentSeriesData[dataIndex], minBarSize);
|
|
61
66
|
const result = {
|
|
62
67
|
seriesId,
|
|
63
68
|
dataIndex,
|
|
64
69
|
layout,
|
|
65
|
-
x: verticalLayout ? xScale(baseValue) + barOffset :
|
|
66
|
-
y: verticalLayout ?
|
|
70
|
+
x: verticalLayout ? xScale(baseValue) + barOffset : startCoordinate,
|
|
71
|
+
y: verticalLayout ? startCoordinate : yScale(baseValue) + barOffset,
|
|
67
72
|
xOrigin: xScale(0) ?? 0,
|
|
68
73
|
yOrigin: yScale(0) ?? 0,
|
|
69
|
-
height: verticalLayout ?
|
|
70
|
-
width: verticalLayout ? barWidth :
|
|
74
|
+
height: verticalLayout ? barSize : barWidth,
|
|
75
|
+
width: verticalLayout ? barWidth : barSize,
|
|
71
76
|
color: colorGetter(dataIndex),
|
|
72
77
|
value: currentSeriesData[dataIndex],
|
|
73
78
|
maskId: `${chartId}_${stackId || seriesId}_${groupIndex}_${dataIndex}`
|
|
@@ -136,4 +141,26 @@ function getBandSize({
|
|
|
136
141
|
barWidth,
|
|
137
142
|
offset
|
|
138
143
|
};
|
|
144
|
+
}
|
|
145
|
+
function getValueCoordinate(isVertical, minValueCoord, maxValueCoord, baseValue, minBarSize) {
|
|
146
|
+
if (baseValue === 0 || baseValue == null) {
|
|
147
|
+
return {
|
|
148
|
+
barSize: 0,
|
|
149
|
+
startCoordinate: minValueCoord
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const isSizeLessThanMin = maxValueCoord - minValueCoord < minBarSize;
|
|
153
|
+
const barSize = isSizeLessThanMin ? minBarSize : maxValueCoord - minValueCoord;
|
|
154
|
+
const isVerticalAndPositive = isVertical && baseValue >= 0;
|
|
155
|
+
const isHorizontalAndNegative = !isVertical && baseValue < 0;
|
|
156
|
+
if (isSizeLessThanMin && (isVerticalAndPositive || isHorizontalAndNegative)) {
|
|
157
|
+
return {
|
|
158
|
+
barSize,
|
|
159
|
+
startCoordinate: maxValueCoord - barSize
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
barSize,
|
|
164
|
+
startCoordinate: minValueCoord
|
|
165
|
+
};
|
|
139
166
|
}
|
|
@@ -76,10 +76,24 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
76
76
|
* If true, the voronoi interaction are ignored.
|
|
77
77
|
*/
|
|
78
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
|
+
}),
|
|
79
85
|
/**
|
|
80
86
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
81
87
|
*/
|
|
82
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
|
+
})),
|
|
83
97
|
/**
|
|
84
98
|
* The highlighted item.
|
|
85
99
|
* Used when the highlight is controlled.
|
|
@@ -122,6 +136,14 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
122
136
|
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
123
137
|
*/
|
|
124
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,
|
|
125
147
|
/**
|
|
126
148
|
* Callback fired when clicking close to an item.
|
|
127
149
|
* This is only available for scatter plot for now.
|
|
@@ -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
|
}
|
|
@@ -6,12 +6,13 @@ export interface ChartsLabelCustomMarkProps {
|
|
|
6
6
|
/** Color of the series this mark refers to. */
|
|
7
7
|
color?: string;
|
|
8
8
|
}
|
|
9
|
+
export type ChartsLabelMarkType = 'square' | 'circle' | 'line' | React.ComponentType<ChartsLabelCustomMarkProps>;
|
|
9
10
|
export interface ChartsLabelMarkProps {
|
|
10
11
|
/**
|
|
11
12
|
* The type of the mark.
|
|
12
13
|
* @default 'square'
|
|
13
14
|
*/
|
|
14
|
-
type?:
|
|
15
|
+
type?: ChartsLabelMarkType;
|
|
15
16
|
/**
|
|
16
17
|
* The color of the mark.
|
|
17
18
|
*/
|
package/esm/ChartsLabel/index.js
CHANGED
|
@@ -16,5 +16,5 @@ export interface ChartsLegendClasses {
|
|
|
16
16
|
/** Styles applied to the legend in row layout. */
|
|
17
17
|
horizontal: string;
|
|
18
18
|
}
|
|
19
|
-
export declare const useUtilityClasses: (props: ChartsLegendProps & ChartsLegendSlotExtension) => Record<"
|
|
19
|
+
export declare const useUtilityClasses: (props: ChartsLegendProps & ChartsLegendSlotExtension) => Record<"item" | "series" | "root" | "label" | "mark", string>;
|
|
20
20
|
export declare const legendClasses: ChartsLegendClasses;
|
|
@@ -24,5 +24,5 @@ export interface PiecewiseColorLegendClasses {
|
|
|
24
24
|
/** Styles applied to the series label. */
|
|
25
25
|
label: string;
|
|
26
26
|
}
|
|
27
|
-
export declare const useUtilityClasses: (props: PiecewiseColorLegendProps & ChartsLegendSlotExtension) => Record<"
|
|
27
|
+
export declare const useUtilityClasses: (props: PiecewiseColorLegendProps & ChartsLegendSlotExtension) => Record<"item" | "root" | "label" | "mark" | "minLabel" | "maxLabel", string>;
|
|
28
28
|
export declare const piecewiseColorLegendClasses: PiecewiseColorLegendClasses;
|
|
@@ -3,7 +3,7 @@ import { ChartsSurfaceProps } from "../ChartsSurface/index.js";
|
|
|
3
3
|
import { GaugeProviderProps } from "./GaugeProvider.js";
|
|
4
4
|
import { MergeSignaturesProperty } from "../internals/plugins/models/index.js";
|
|
5
5
|
import { ChartCorePluginSignatures } from "../internals/plugins/corePlugins/index.js";
|
|
6
|
-
export interface GaugeContainerProps extends Omit<ChartsSurfaceProps, 'children'>, Omit<MergeSignaturesProperty<ChartCorePluginSignatures, 'params'>, 'series' | 'dataset' | 'colors' | 'theme'>, Omit<GaugeProviderProps, 'children'>, Omit<React.SVGProps<SVGSVGElement>, 'width' | 'height'> {
|
|
6
|
+
export interface GaugeContainerProps extends Omit<ChartsSurfaceProps, 'children'>, Omit<MergeSignaturesProperty<ChartCorePluginSignatures, 'params'>, 'series' | 'dataset' | 'colors' | 'theme' | 'experimentalFeatures'>, Omit<GaugeProviderProps, 'children'>, Omit<React.SVGProps<SVGSVGElement>, 'width' | 'height'> {
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
}
|
|
9
9
|
declare const GaugeContainer: React.ForwardRefExoticComponent<Omit<GaugeContainerProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
@@ -18,12 +18,13 @@ import { LineChartPluginsSignatures } from "./LineChart.plugins.js";
|
|
|
18
18
|
import { ChartsToolbarSlots, ChartsToolbarSlotProps } from "../Toolbar/index.js";
|
|
19
19
|
export interface LineChartSlots extends ChartsAxisSlots, AreaPlotSlots, LinePlotSlots, MarkPlotSlots, LineHighlightPlotSlots, ChartsLegendSlots, ChartsOverlaySlots, ChartsTooltipSlots, ChartsToolbarSlots, Partial<ChartsSlots> {}
|
|
20
20
|
export interface LineChartSlotProps extends ChartsAxisSlotProps, AreaPlotSlotProps, LinePlotSlotProps, MarkPlotSlotProps, LineHighlightPlotSlotProps, ChartsLegendSlotProps, ChartsOverlaySlotProps, ChartsTooltipSlotProps, ChartsToolbarSlotProps, Partial<ChartsSlotProps> {}
|
|
21
|
+
export type LineSeries = MakeOptional<LineSeriesType, 'type'>;
|
|
21
22
|
export interface LineChartProps extends Omit<ChartContainerProps<'line', LineChartPluginsSignatures>, 'series' | 'plugins' | 'zAxis'>, Omit<ChartsAxisProps, 'slots' | 'slotProps'>, Omit<ChartsOverlayProps, 'slots' | 'slotProps'> {
|
|
22
23
|
/**
|
|
23
24
|
* The series to display in the line chart.
|
|
24
|
-
* An array of [[
|
|
25
|
+
* An array of [[LineSeries]] objects.
|
|
25
26
|
*/
|
|
26
|
-
series: Readonly<
|
|
27
|
+
series: Readonly<LineSeries[]>;
|
|
27
28
|
/**
|
|
28
29
|
* Option to display a cartesian grid in the background.
|
|
29
30
|
*/
|
|
@@ -111,6 +111,12 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
111
111
|
* If `true`, render the line highlight item.
|
|
112
112
|
*/
|
|
113
113
|
disableLineItemHighlight: PropTypes.bool,
|
|
114
|
+
/**
|
|
115
|
+
* Options to enable features planned for the next major.
|
|
116
|
+
*/
|
|
117
|
+
experimentalFeatures: PropTypes.shape({
|
|
118
|
+
preferStrictDomainInLineCharts: PropTypes.bool
|
|
119
|
+
}),
|
|
114
120
|
/**
|
|
115
121
|
* Option to display a cartesian grid in the background.
|
|
116
122
|
*/
|
|
@@ -126,6 +132,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
126
132
|
* If `true`, the legend is not rendered.
|
|
127
133
|
*/
|
|
128
134
|
hideLegend: PropTypes.bool,
|
|
135
|
+
/**
|
|
136
|
+
* The controlled axis highlight.
|
|
137
|
+
* Identified by the axis id, and data index.
|
|
138
|
+
*/
|
|
139
|
+
highlightedAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
140
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
141
|
+
dataIndex: PropTypes.number.isRequired
|
|
142
|
+
})),
|
|
129
143
|
/**
|
|
130
144
|
* The highlighted item.
|
|
131
145
|
* Used when the highlight is controlled.
|
|
@@ -177,6 +191,14 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
177
191
|
* @param {HighlightItemData | null} highlightedItem The newly highlighted item.
|
|
178
192
|
*/
|
|
179
193
|
onHighlightChange: PropTypes.func,
|
|
194
|
+
/**
|
|
195
|
+
* The function called when the pointer position corresponds to a new axis data item.
|
|
196
|
+
* This update can either be caused by a pointer movement, or an axis update.
|
|
197
|
+
* In case of multiple axes, the function is called if at least one axis is updated.
|
|
198
|
+
* The argument contains the identifier for all axes with a `data` property.
|
|
199
|
+
* @param {AxisItemIdentifier[]} axisItems The array of axes item identifiers.
|
|
200
|
+
*/
|
|
201
|
+
onHighlightedAxisChange: PropTypes.func,
|
|
180
202
|
/**
|
|
181
203
|
* Callback fired when a line element is clicked.
|
|
182
204
|
*/
|
|
@@ -187,7 +209,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
187
209
|
onMarkClick: PropTypes.func,
|
|
188
210
|
/**
|
|
189
211
|
* The series to display in the line chart.
|
|
190
|
-
* An array of [[
|
|
212
|
+
* An array of [[LineSeries]] objects.
|
|
191
213
|
*/
|
|
192
214
|
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
193
215
|
/**
|
|
@@ -13,7 +13,7 @@ import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
|
|
|
13
13
|
import { useLineSeriesContext } from "../hooks/useLineSeries.js";
|
|
14
14
|
import getColor from "./seriesConfig/getColor.js";
|
|
15
15
|
import { useChartContext } from "../context/ChartProvider/index.js";
|
|
16
|
-
import {
|
|
16
|
+
import { selectorChartsHighlightXAxisIndex } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
17
17
|
import { useXAxes, useYAxes } from "../hooks/useAxis.js";
|
|
18
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
19
|
/**
|
|
@@ -45,8 +45,8 @@ function LineHighlightPlot(props) {
|
|
|
45
45
|
instance
|
|
46
46
|
} = useChartContext();
|
|
47
47
|
const store = useStore();
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
48
|
+
const highlightedIndexes = useSelector(store, selectorChartsHighlightXAxisIndex);
|
|
49
|
+
if (highlightedIndexes.length === 0) {
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
52
|
if (seriesData === undefined) {
|
|
@@ -60,7 +60,10 @@ function LineHighlightPlot(props) {
|
|
|
60
60
|
const defaultYAxisId = yAxisIds[0];
|
|
61
61
|
const Element = slots?.lineHighlight ?? LineHighlightElement;
|
|
62
62
|
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
63
|
-
children:
|
|
63
|
+
children: highlightedIndexes.flatMap(({
|
|
64
|
+
dataIndex: highlightedIndex,
|
|
65
|
+
axisId: highlightedAxisId
|
|
66
|
+
}) => stackingGroups.flatMap(({
|
|
64
67
|
ids: groupIds
|
|
65
68
|
}) => {
|
|
66
69
|
return groupIds.flatMap(seriesId => {
|
|
@@ -75,6 +78,9 @@ function LineHighlightPlot(props) {
|
|
|
75
78
|
if (disableHighlight || data[highlightedIndex] == null) {
|
|
76
79
|
return null;
|
|
77
80
|
}
|
|
81
|
+
if (highlightedAxisId !== xAxisId) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
78
84
|
const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
|
|
79
85
|
const yScale = yAxis[yAxisId].scale;
|
|
80
86
|
const xData = xAxis[xAxisId].data;
|
|
@@ -96,7 +102,7 @@ function LineHighlightPlot(props) {
|
|
|
96
102
|
shape: shape
|
|
97
103
|
}, slotProps?.lineHighlight), `${seriesId}`);
|
|
98
104
|
});
|
|
99
|
-
})
|
|
105
|
+
}))
|
|
100
106
|
}));
|
|
101
107
|
}
|
|
102
108
|
process.env.NODE_ENV !== "production" ? LineHighlightPlot.propTypes = {
|
|
@@ -5,7 +5,6 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
5
5
|
const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import * as React from 'react';
|
|
8
|
-
import { selectorChartsInteractionXAxisIndex } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.js";
|
|
9
8
|
import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
|
|
10
9
|
import { useSkipAnimation } from "../hooks/useSkipAnimation.js";
|
|
11
10
|
import { useChartId } from "../hooks/useChartId.js";
|
|
@@ -18,6 +17,7 @@ import { MarkElement } from "./MarkElement.js";
|
|
|
18
17
|
import { useChartContext } from "../context/ChartProvider/index.js";
|
|
19
18
|
import { useItemHighlightedGetter, useXAxes, useYAxes } from "../hooks/index.js";
|
|
20
19
|
import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js";
|
|
20
|
+
import { selectorChartsHighlightXAxisIndex } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
21
21
|
import { useSelector } from "../internals/store/useSelector.js";
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
23
|
/**
|
|
@@ -58,7 +58,21 @@ function MarkPlot(props) {
|
|
|
58
58
|
isFaded,
|
|
59
59
|
isHighlighted
|
|
60
60
|
} = useItemHighlightedGetter();
|
|
61
|
-
const
|
|
61
|
+
const xAxisHighlightIndexes = useSelector(store, selectorChartsHighlightXAxisIndex);
|
|
62
|
+
const highlightedItems = React.useMemo(() => {
|
|
63
|
+
const rep = {};
|
|
64
|
+
for (const {
|
|
65
|
+
dataIndex,
|
|
66
|
+
axisId
|
|
67
|
+
} of xAxisHighlightIndexes) {
|
|
68
|
+
if (rep[axisId] === undefined) {
|
|
69
|
+
rep[axisId] = new Set([dataIndex]);
|
|
70
|
+
} else {
|
|
71
|
+
rep[axisId].add(dataIndex);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return rep;
|
|
75
|
+
}, [xAxisHighlightIndexes]);
|
|
62
76
|
if (seriesData === undefined) {
|
|
63
77
|
return null;
|
|
64
78
|
}
|
|
@@ -156,7 +170,7 @@ function MarkPlot(props) {
|
|
|
156
170
|
seriesId,
|
|
157
171
|
dataIndex: index
|
|
158
172
|
})),
|
|
159
|
-
isHighlighted:
|
|
173
|
+
isHighlighted: highlightedItems[xAxisId]?.has(index) || isSeriesHighlighted,
|
|
160
174
|
isFaded: isSeriesFaded
|
|
161
175
|
}, slotProps?.mark), `${seriesId}-${index}`);
|
|
162
176
|
})
|
|
@@ -33,9 +33,10 @@ export function useAreaPlotData(xAxes, yAxes) {
|
|
|
33
33
|
connectNulls,
|
|
34
34
|
baseline,
|
|
35
35
|
curve,
|
|
36
|
-
strictStepCurve
|
|
36
|
+
strictStepCurve,
|
|
37
|
+
area
|
|
37
38
|
} = series[seriesId];
|
|
38
|
-
if (!(xAxisId in xAxes) || !(yAxisId in yAxes)) {
|
|
39
|
+
if (!area || !(xAxisId in xAxes) || !(yAxisId in yAxes)) {
|
|
39
40
|
continue;
|
|
40
41
|
}
|
|
41
42
|
const xScale = xAxes[xAxisId].scale;
|