@mui/x-charts 8.5.3 → 8.7.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/AnimatedBarElement.js +3 -1
- package/BarChart/BarLabel/BarLabelPlot.d.ts +2 -2
- package/BarChart/BarLabel/BarLabelPlot.js +33 -25
- package/BarChart/BarPlot.js +59 -183
- package/BarChart/barClasses.d.ts +12 -0
- package/BarChart/barClasses.js +25 -0
- package/BarChart/index.d.ts +3 -1
- package/BarChart/index.js +23 -1
- package/BarChart/types.d.ts +5 -1
- package/BarChart/useBarPlotData.d.ts +8 -0
- package/BarChart/useBarPlotData.js +146 -0
- package/CHANGELOG.md +210 -0
- package/ChartContainer/ChartContainer.d.ts +1 -21
- package/ChartContainer/ChartContainer.js +0 -8
- package/ChartContainer/index.d.ts +8 -1
- package/ChartsLegend/ChartsLegend.js +1 -0
- 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/ChartsXAxis/ChartsXAxis.js +4 -108
- package/ChartsXAxis/getVisibleLabels.d.ts +14 -0
- package/ChartsXAxis/getVisibleLabels.js +71 -0
- package/ChartsXAxis/shortenLabels.d.ts +4 -0
- package/ChartsXAxis/shortenLabels.js +48 -0
- package/ChartsYAxis/ChartsYAxis.js +2 -39
- package/ChartsYAxis/shortenLabels.d.ts +4 -0
- package/ChartsYAxis/shortenLabels.js +46 -0
- package/LineChart/AnimatedArea.js +4 -1
- package/LineChart/AnimatedLine.js +4 -1
- package/LineChart/AreaPlot.js +5 -115
- package/LineChart/CircleMarkElement.js +4 -1
- package/LineChart/LinePlot.js +5 -99
- package/LineChart/MarkElement.js +4 -1
- package/LineChart/MarkPlot.js +1 -0
- package/LineChart/useAreaPlotData.d.ts +12 -0
- package/LineChart/useAreaPlotData.js +125 -0
- package/LineChart/useLinePlotData.d.ts +11 -0
- package/LineChart/useLinePlotData.js +108 -0
- package/PieChart/PieArc.js +3 -1
- package/PieChart/PiePlot.js +6 -0
- package/PieChart/index.d.ts +3 -1
- package/PieChart/index.js +18 -1
- package/PieChart/pieClasses.d.ts +12 -0
- package/PieChart/pieClasses.js +24 -0
- package/ScatterChart/Scatter.js +22 -48
- package/ScatterChart/useScatterPlotData.d.ts +8 -0
- package/ScatterChart/useScatterPlotData.js +33 -0
- package/Toolbar/ToolbarButton.js +2 -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/AnimatedBarElement.js +3 -1
- package/esm/BarChart/BarLabel/BarLabelPlot.d.ts +2 -2
- package/esm/BarChart/BarLabel/BarLabelPlot.js +33 -25
- package/esm/BarChart/BarPlot.js +60 -185
- package/esm/BarChart/barClasses.d.ts +12 -0
- package/esm/BarChart/barClasses.js +15 -0
- package/esm/BarChart/index.d.ts +3 -1
- package/esm/BarChart/index.js +2 -1
- package/esm/BarChart/types.d.ts +5 -1
- 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 +0 -8
- package/esm/ChartContainer/index.d.ts +8 -1
- package/esm/ChartContainer/index.js +6 -1
- package/esm/ChartsLegend/ChartsLegend.js +1 -0
- 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/ChartsXAxis/ChartsXAxis.js +2 -106
- package/esm/ChartsXAxis/getVisibleLabels.d.ts +14 -0
- package/esm/ChartsXAxis/getVisibleLabels.js +67 -0
- package/esm/ChartsXAxis/shortenLabels.d.ts +4 -0
- package/esm/ChartsXAxis/shortenLabels.js +42 -0
- package/esm/ChartsYAxis/ChartsYAxis.js +1 -38
- package/esm/ChartsYAxis/shortenLabels.d.ts +4 -0
- package/esm/ChartsYAxis/shortenLabels.js +41 -0
- package/esm/LineChart/AnimatedArea.js +4 -1
- package/esm/LineChart/AnimatedLine.js +4 -1
- package/esm/LineChart/AreaPlot.js +5 -115
- package/esm/LineChart/CircleMarkElement.js +4 -1
- package/esm/LineChart/LinePlot.js +5 -99
- package/esm/LineChart/MarkElement.js +4 -1
- package/esm/LineChart/MarkPlot.js +1 -0
- package/esm/LineChart/useAreaPlotData.d.ts +12 -0
- package/esm/LineChart/useAreaPlotData.js +118 -0
- package/esm/LineChart/useLinePlotData.d.ts +11 -0
- package/esm/LineChart/useLinePlotData.js +101 -0
- package/esm/PieChart/PieArc.js +3 -1
- package/esm/PieChart/PiePlot.js +6 -0
- package/esm/PieChart/index.d.ts +3 -1
- package/esm/PieChart/index.js +2 -1
- package/esm/PieChart/pieClasses.d.ts +12 -0
- package/esm/PieChart/pieClasses.js +15 -0
- package/esm/ScatterChart/Scatter.js +23 -49
- package/esm/ScatterChart/useScatterPlotData.d.ts +8 -0
- package/esm/ScatterChart/useScatterPlotData.js +26 -0
- package/esm/Toolbar/ToolbarButton.js +2 -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/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/components/NotRendered.d.ts +9 -0
- package/esm/internals/components/NotRendered.js +10 -0
- package/esm/internals/index.d.ts +6 -0
- package/esm/internals/index.js +6 -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.js +1 -1
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +2 -2
- 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/useChartAxisSize.selectors.d.ts +4 -4
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +44 -33
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +7 -7
- 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 +52 -36
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +6 -6
- 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/store/useCharts.d.ts +1 -1
- package/esm/locales/elGR.d.ts +19 -0
- package/esm/locales/elGR.js +15 -0
- package/esm/locales/enUS.d.ts +3 -0
- package/esm/locales/enUS.js +8 -2
- package/esm/locales/frFR.d.ts +3 -0
- package/esm/locales/frFR.js +7 -0
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +1 -0
- package/esm/locales/ptBR.d.ts +3 -0
- package/esm/locales/ptBR.js +7 -1
- package/esm/locales/ptPT.d.ts +3 -0
- package/esm/locales/ptPT.js +7 -1
- package/esm/locales/utils/chartsLocaleTextApi.d.ts +17 -0
- package/esm/locales/utils/getChartsLocalization.d.ts +3 -0
- package/esm/locales/utils/imageMimeTypes.d.ts +2 -0
- package/esm/locales/utils/imageMimeTypes.js +5 -0
- package/esm/models/slots/chartsBaseSlotProps.d.ts +4 -0
- 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/components/NotRendered.d.ts +9 -0
- package/internals/components/NotRendered.js +16 -0
- package/internals/index.d.ts +6 -0
- package/internals/index.js +56 -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.js +1 -1
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.d.ts +3 -3
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types.d.ts +2 -2
- 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/useChartAxisSize.selectors.d.ts +4 -4
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +44 -33
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianInteraction.selectors.d.ts +7 -7
- 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 +52 -36
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +5 -5
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarInteraction.selectors.d.ts +6 -6
- 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/store/useCharts.d.ts +1 -1
- package/locales/elGR.d.ts +19 -0
- package/locales/elGR.js +21 -0
- package/locales/enUS.d.ts +3 -0
- package/locales/enUS.js +8 -2
- package/locales/frFR.d.ts +3 -0
- package/locales/frFR.js +7 -0
- package/locales/index.d.ts +1 -0
- package/locales/index.js +11 -0
- package/locales/ptBR.d.ts +3 -0
- package/locales/ptBR.js +7 -1
- package/locales/ptPT.d.ts +3 -0
- package/locales/ptPT.js +7 -1
- package/locales/utils/chartsLocaleTextApi.d.ts +17 -0
- package/locales/utils/getChartsLocalization.d.ts +3 -0
- package/locales/utils/imageMimeTypes.d.ts +2 -0
- package/locales/utils/imageMimeTypes.js +11 -0
- package/models/slots/chartsBaseSlotProps.d.ts +4 -0
- package/package.json +3 -2
|
@@ -9,24 +9,22 @@ import useSlotProps from '@mui/utils/useSlotProps';
|
|
|
9
9
|
import composeClasses from '@mui/utils/composeClasses';
|
|
10
10
|
import { useThemeProps, useTheme, styled } from '@mui/material/styles';
|
|
11
11
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
12
|
-
import { clampAngle } from "../internals/clampAngle.js";
|
|
13
12
|
import { useIsHydrated } from "../hooks/useIsHydrated.js";
|
|
14
|
-
import { doesTextFitInRect, ellipsize } from "../internals/ellipsize.js";
|
|
15
13
|
import { getStringSize } from "../internals/domUtils.js";
|
|
16
14
|
import { useTicks } from "../hooks/useTicks.js";
|
|
17
15
|
import { getAxisUtilityClass } from "../ChartsAxis/axisClasses.js";
|
|
18
16
|
import { AxisRoot } from "../internals/components/AxisSharedComponents.js";
|
|
19
17
|
import { ChartsText } from "../ChartsText/index.js";
|
|
20
|
-
import { getMinXTranslation } from "../internals/geometry.js";
|
|
21
18
|
import { useMounted } from "../hooks/useMounted.js";
|
|
22
19
|
import { useDrawingArea } from "../hooks/useDrawingArea.js";
|
|
23
|
-
import { getWordsByLines } from "../internals/getWordsByLines.js";
|
|
24
20
|
import { isInfinity } from "../internals/isInfinity.js";
|
|
25
21
|
import { isBandScale } from "../internals/isBandScale.js";
|
|
26
22
|
import { useChartContext } from "../context/ChartProvider/useChartContext.js";
|
|
27
23
|
import { useXAxes } from "../hooks/useAxis.js";
|
|
28
24
|
import { getDefaultBaseline, getDefaultTextAnchor } from "../ChartsText/defaultTextPlacement.js";
|
|
29
25
|
import { invertTextAnchor } from "../internals/invertTextAnchor.js";
|
|
26
|
+
import { shortenLabels } from "./shortenLabels.js";
|
|
27
|
+
import { getVisibleLabels } from "./getVisibleLabels.js";
|
|
30
28
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
31
29
|
const useUtilityClasses = ownerState => {
|
|
32
30
|
const {
|
|
@@ -49,108 +47,6 @@ const useUtilityClasses = ownerState => {
|
|
|
49
47
|
const TICK_LABEL_GAP = 3;
|
|
50
48
|
/* Gap between the axis label and tick labels. */
|
|
51
49
|
const AXIS_LABEL_TICK_LABEL_GAP = 4;
|
|
52
|
-
|
|
53
|
-
/* Returns a set of indices of the tick labels that should be visible. */
|
|
54
|
-
function getVisibleLabels(xTicks, {
|
|
55
|
-
tickLabelStyle: style,
|
|
56
|
-
tickLabelInterval,
|
|
57
|
-
tickLabelMinGap,
|
|
58
|
-
reverse,
|
|
59
|
-
isMounted,
|
|
60
|
-
isXInside
|
|
61
|
-
}) {
|
|
62
|
-
const getTickLabelSize = tick => {
|
|
63
|
-
if (!isMounted || tick.formattedValue === undefined) {
|
|
64
|
-
return {
|
|
65
|
-
width: 0,
|
|
66
|
-
height: 0
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const tickSizes = getWordsByLines({
|
|
70
|
-
style,
|
|
71
|
-
needsComputation: true,
|
|
72
|
-
text: tick.formattedValue
|
|
73
|
-
});
|
|
74
|
-
return {
|
|
75
|
-
width: Math.max(...tickSizes.map(size => size.width)),
|
|
76
|
-
height: Math.max(tickSizes.length * tickSizes[0].height)
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
if (typeof tickLabelInterval === 'function') {
|
|
80
|
-
return new Set(xTicks.filter((item, index) => tickLabelInterval(item.value, index)));
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Filter label to avoid overlap
|
|
84
|
-
let previousTextLimit = 0;
|
|
85
|
-
const direction = reverse ? -1 : 1;
|
|
86
|
-
return new Set(xTicks.filter((item, labelIndex) => {
|
|
87
|
-
const {
|
|
88
|
-
offset,
|
|
89
|
-
labelOffset
|
|
90
|
-
} = item;
|
|
91
|
-
const textPosition = offset + labelOffset;
|
|
92
|
-
if (labelIndex > 0 && direction * textPosition < direction * (previousTextLimit + tickLabelMinGap)) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
if (!isXInside(textPosition)) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/* Measuring text width is expensive, so we need to delay it as much as possible to improve performance. */
|
|
100
|
-
const {
|
|
101
|
-
width,
|
|
102
|
-
height
|
|
103
|
-
} = getTickLabelSize(item);
|
|
104
|
-
const distance = getMinXTranslation(width, height, style?.angle);
|
|
105
|
-
const currentTextLimit = textPosition - direction * distance / 2;
|
|
106
|
-
if (labelIndex > 0 && direction * currentTextLimit < direction * (previousTextLimit + tickLabelMinGap)) {
|
|
107
|
-
// Except for the first label, we skip all label that overlap with the last accepted.
|
|
108
|
-
// Notice that the early return prevents `previousTextLimit` from being updated.
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
previousTextLimit = textPosition + direction * distance / 2;
|
|
112
|
-
return true;
|
|
113
|
-
}));
|
|
114
|
-
}
|
|
115
|
-
function shortenLabels(visibleLabels, drawingArea, maxHeight, isRtl, tickLabelStyle) {
|
|
116
|
-
const shortenedLabels = new Map();
|
|
117
|
-
const angle = clampAngle(tickLabelStyle?.angle ?? 0);
|
|
118
|
-
|
|
119
|
-
// Multiplying the space available to the left of the text position by leftBoundFactor returns the max width of the text.
|
|
120
|
-
// Same for rightBoundFactor
|
|
121
|
-
let leftBoundFactor = 1;
|
|
122
|
-
let rightBoundFactor = 1;
|
|
123
|
-
if (tickLabelStyle?.textAnchor === 'start') {
|
|
124
|
-
leftBoundFactor = Infinity;
|
|
125
|
-
rightBoundFactor = 1;
|
|
126
|
-
} else if (tickLabelStyle?.textAnchor === 'end') {
|
|
127
|
-
leftBoundFactor = 1;
|
|
128
|
-
rightBoundFactor = Infinity;
|
|
129
|
-
} else {
|
|
130
|
-
leftBoundFactor = 2;
|
|
131
|
-
rightBoundFactor = 2;
|
|
132
|
-
}
|
|
133
|
-
if (angle > 90 && angle < 270) {
|
|
134
|
-
[leftBoundFactor, rightBoundFactor] = [rightBoundFactor, leftBoundFactor];
|
|
135
|
-
}
|
|
136
|
-
if (isRtl) {
|
|
137
|
-
[leftBoundFactor, rightBoundFactor] = [rightBoundFactor, leftBoundFactor];
|
|
138
|
-
}
|
|
139
|
-
for (const item of visibleLabels) {
|
|
140
|
-
if (item.formattedValue) {
|
|
141
|
-
// That maximum width of the tick depends on its proximity to the axis bounds.
|
|
142
|
-
const width = Math.min((item.offset + item.labelOffset) * leftBoundFactor, (drawingArea.left + drawingArea.width + drawingArea.right - item.offset - item.labelOffset) * rightBoundFactor);
|
|
143
|
-
const doesTextFit = text => doesTextFitInRect(text, {
|
|
144
|
-
width,
|
|
145
|
-
height: maxHeight,
|
|
146
|
-
angle,
|
|
147
|
-
measureText: string => getStringSize(string, tickLabelStyle)
|
|
148
|
-
});
|
|
149
|
-
shortenedLabels.set(item, ellipsize(item.formattedValue.toString(), doesTextFit));
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return shortenedLabels;
|
|
153
|
-
}
|
|
154
50
|
const XAxisRoot = styled(AxisRoot, {
|
|
155
51
|
name: 'MuiChartsXAxis',
|
|
156
52
|
slot: 'Root'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TickItemType } from "../hooks/useTicks.js";
|
|
2
|
+
import { ChartsXAxisProps, ComputedXAxis } from "../models/axis.js";
|
|
3
|
+
export declare function getVisibleLabels(xTicks: TickItemType[], {
|
|
4
|
+
tickLabelStyle: style,
|
|
5
|
+
tickLabelInterval,
|
|
6
|
+
tickLabelMinGap,
|
|
7
|
+
reverse,
|
|
8
|
+
isMounted,
|
|
9
|
+
isXInside
|
|
10
|
+
}: Pick<ChartsXAxisProps, 'tickLabelInterval' | 'tickLabelStyle'> & Pick<ComputedXAxis, 'reverse'> & {
|
|
11
|
+
isMounted: boolean;
|
|
12
|
+
tickLabelMinGap: NonNullable<ChartsXAxisProps['tickLabelMinGap']>;
|
|
13
|
+
isXInside: (x: number) => boolean;
|
|
14
|
+
}): Set<TickItemType>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { getMinXTranslation } from "../internals/geometry.js";
|
|
4
|
+
import { getWordsByLines } from "../internals/getWordsByLines.js";
|
|
5
|
+
|
|
6
|
+
/* Returns a set of indices of the tick labels that should be visible. */
|
|
7
|
+
export function getVisibleLabels(xTicks, {
|
|
8
|
+
tickLabelStyle: style,
|
|
9
|
+
tickLabelInterval,
|
|
10
|
+
tickLabelMinGap,
|
|
11
|
+
reverse,
|
|
12
|
+
isMounted,
|
|
13
|
+
isXInside
|
|
14
|
+
}) {
|
|
15
|
+
const getTickLabelSize = tick => {
|
|
16
|
+
if (!isMounted || tick.formattedValue === undefined) {
|
|
17
|
+
return {
|
|
18
|
+
width: 0,
|
|
19
|
+
height: 0
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const tickSizes = getWordsByLines({
|
|
23
|
+
style,
|
|
24
|
+
needsComputation: true,
|
|
25
|
+
text: tick.formattedValue
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
width: Math.max(...tickSizes.map(size => size.width)),
|
|
29
|
+
height: Math.max(tickSizes.length * tickSizes[0].height)
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
if (typeof tickLabelInterval === 'function') {
|
|
33
|
+
return new Set(xTicks.filter((item, index) => tickLabelInterval(item.value, index)));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Filter label to avoid overlap
|
|
37
|
+
let previousTextLimit = 0;
|
|
38
|
+
const direction = reverse ? -1 : 1;
|
|
39
|
+
return new Set(xTicks.filter((item, labelIndex) => {
|
|
40
|
+
const {
|
|
41
|
+
offset,
|
|
42
|
+
labelOffset
|
|
43
|
+
} = item;
|
|
44
|
+
const textPosition = offset + labelOffset;
|
|
45
|
+
if (labelIndex > 0 && direction * textPosition < direction * (previousTextLimit + tickLabelMinGap)) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
if (!isXInside(textPosition)) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Measuring text width is expensive, so we need to delay it as much as possible to improve performance. */
|
|
53
|
+
const {
|
|
54
|
+
width,
|
|
55
|
+
height
|
|
56
|
+
} = getTickLabelSize(item);
|
|
57
|
+
const distance = getMinXTranslation(width, height, style?.angle);
|
|
58
|
+
const currentTextLimit = textPosition - direction * distance / 2;
|
|
59
|
+
if (labelIndex > 0 && direction * currentTextLimit < direction * (previousTextLimit + tickLabelMinGap)) {
|
|
60
|
+
// Except for the first label, we skip all label that overlap with the last accepted.
|
|
61
|
+
// Notice that the early return prevents `previousTextLimit` from being updated.
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
previousTextLimit = textPosition + direction * distance / 2;
|
|
65
|
+
return true;
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TickItemType } from "../hooks/useTicks.js";
|
|
2
|
+
import { ChartsXAxisProps } from "../models/axis.js";
|
|
3
|
+
import { ChartDrawingArea } from "../hooks/useDrawingArea.js";
|
|
4
|
+
export declare function shortenLabels(visibleLabels: Set<TickItemType>, drawingArea: Pick<ChartDrawingArea, 'left' | 'width' | 'right'>, maxHeight: number, isRtl: boolean, tickLabelStyle: ChartsXAxisProps['tickLabelStyle']): Map<TickItemType, string>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { clampAngle } from "../internals/clampAngle.js";
|
|
2
|
+
import { doesTextFitInRect, ellipsize } from "../internals/ellipsize.js";
|
|
3
|
+
import { getStringSize } from "../internals/domUtils.js";
|
|
4
|
+
export function shortenLabels(visibleLabels, drawingArea, maxHeight, isRtl, tickLabelStyle) {
|
|
5
|
+
const shortenedLabels = new Map();
|
|
6
|
+
const angle = clampAngle(tickLabelStyle?.angle ?? 0);
|
|
7
|
+
|
|
8
|
+
// Multiplying the space available to the left of the text position by leftBoundFactor returns the max width of the text.
|
|
9
|
+
// Same for rightBoundFactor
|
|
10
|
+
let leftBoundFactor = 1;
|
|
11
|
+
let rightBoundFactor = 1;
|
|
12
|
+
if (tickLabelStyle?.textAnchor === 'start') {
|
|
13
|
+
leftBoundFactor = Infinity;
|
|
14
|
+
rightBoundFactor = 1;
|
|
15
|
+
} else if (tickLabelStyle?.textAnchor === 'end') {
|
|
16
|
+
leftBoundFactor = 1;
|
|
17
|
+
rightBoundFactor = Infinity;
|
|
18
|
+
} else {
|
|
19
|
+
leftBoundFactor = 2;
|
|
20
|
+
rightBoundFactor = 2;
|
|
21
|
+
}
|
|
22
|
+
if (angle > 90 && angle < 270) {
|
|
23
|
+
[leftBoundFactor, rightBoundFactor] = [rightBoundFactor, leftBoundFactor];
|
|
24
|
+
}
|
|
25
|
+
if (isRtl) {
|
|
26
|
+
[leftBoundFactor, rightBoundFactor] = [rightBoundFactor, leftBoundFactor];
|
|
27
|
+
}
|
|
28
|
+
for (const item of visibleLabels) {
|
|
29
|
+
if (item.formattedValue) {
|
|
30
|
+
// That maximum width of the tick depends on its proximity to the axis bounds.
|
|
31
|
+
const width = Math.min((item.offset + item.labelOffset) * leftBoundFactor, (drawingArea.left + drawingArea.width + drawingArea.right - item.offset - item.labelOffset) * rightBoundFactor);
|
|
32
|
+
const doesTextFit = text => doesTextFitInRect(text, {
|
|
33
|
+
width,
|
|
34
|
+
height: maxHeight,
|
|
35
|
+
angle,
|
|
36
|
+
measureText: string => getStringSize(string, tickLabelStyle)
|
|
37
|
+
});
|
|
38
|
+
shortenedLabels.set(item, ellipsize(item.formattedValue.toString(), doesTextFit));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return shortenedLabels;
|
|
42
|
+
}
|
|
@@ -11,7 +11,6 @@ import { useThemeProps, styled, useTheme } from '@mui/material/styles';
|
|
|
11
11
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
12
12
|
import { useIsHydrated } from "../hooks/useIsHydrated.js";
|
|
13
13
|
import { getDefaultBaseline, getDefaultTextAnchor } from "../ChartsText/defaultTextPlacement.js";
|
|
14
|
-
import { doesTextFitInRect, ellipsize } from "../internals/ellipsize.js";
|
|
15
14
|
import { getStringSize } from "../internals/domUtils.js";
|
|
16
15
|
import { useTicks } from "../hooks/useTicks.js";
|
|
17
16
|
import { useDrawingArea } from "../hooks/useDrawingArea.js";
|
|
@@ -22,8 +21,8 @@ import { isInfinity } from "../internals/isInfinity.js";
|
|
|
22
21
|
import { isBandScale } from "../internals/isBandScale.js";
|
|
23
22
|
import { useChartContext } from "../context/ChartProvider/index.js";
|
|
24
23
|
import { useYAxes } from "../hooks/index.js";
|
|
25
|
-
import { clampAngle } from "../internals/clampAngle.js";
|
|
26
24
|
import { invertTextAnchor } from "../internals/invertTextAnchor.js";
|
|
25
|
+
import { shortenLabels } from "./shortenLabels.js";
|
|
27
26
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
27
|
const useUtilityClasses = ownerState => {
|
|
29
28
|
const {
|
|
@@ -46,42 +45,6 @@ const useUtilityClasses = ownerState => {
|
|
|
46
45
|
const TICK_LABEL_GAP = 2;
|
|
47
46
|
/* Gap between the axis label and tick labels. */
|
|
48
47
|
const AXIS_LABEL_TICK_LABEL_GAP = 2;
|
|
49
|
-
function shortenLabels(visibleLabels, drawingArea, maxWidth, isRtl, tickLabelStyle) {
|
|
50
|
-
const shortenedLabels = new Map();
|
|
51
|
-
const angle = clampAngle(tickLabelStyle?.angle ?? 0);
|
|
52
|
-
let topBoundFactor = 1;
|
|
53
|
-
let bottomBoundFactor = 1;
|
|
54
|
-
if (tickLabelStyle?.textAnchor === 'start') {
|
|
55
|
-
topBoundFactor = Infinity;
|
|
56
|
-
bottomBoundFactor = 1;
|
|
57
|
-
} else if (tickLabelStyle?.textAnchor === 'end') {
|
|
58
|
-
topBoundFactor = 1;
|
|
59
|
-
bottomBoundFactor = Infinity;
|
|
60
|
-
} else {
|
|
61
|
-
topBoundFactor = 2;
|
|
62
|
-
bottomBoundFactor = 2;
|
|
63
|
-
}
|
|
64
|
-
if (angle > 180) {
|
|
65
|
-
[topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
|
|
66
|
-
}
|
|
67
|
-
if (isRtl) {
|
|
68
|
-
[topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
|
|
69
|
-
}
|
|
70
|
-
for (const item of visibleLabels) {
|
|
71
|
-
if (item.formattedValue) {
|
|
72
|
-
// That maximum height of the tick depends on its proximity to the axis bounds.
|
|
73
|
-
const height = Math.min((item.offset + item.labelOffset) * topBoundFactor, (drawingArea.top + drawingArea.height + drawingArea.bottom - item.offset - item.labelOffset) * bottomBoundFactor);
|
|
74
|
-
const doesTextFit = text => doesTextFitInRect(text, {
|
|
75
|
-
width: maxWidth,
|
|
76
|
-
height,
|
|
77
|
-
angle,
|
|
78
|
-
measureText: string => getStringSize(string, tickLabelStyle)
|
|
79
|
-
});
|
|
80
|
-
shortenedLabels.set(item, ellipsize(item.formattedValue.toString(), doesTextFit));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return shortenedLabels;
|
|
84
|
-
}
|
|
85
48
|
const YAxisRoot = styled(AxisRoot, {
|
|
86
49
|
name: 'MuiChartsYAxis',
|
|
87
50
|
slot: 'Root'
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ChartDrawingArea } from "../hooks/index.js";
|
|
2
|
+
import { TickItemType } from "../hooks/useTicks.js";
|
|
3
|
+
import { ChartsYAxisProps } from "../models/index.js";
|
|
4
|
+
export declare function shortenLabels(visibleLabels: TickItemType[], drawingArea: Pick<ChartDrawingArea, 'top' | 'height' | 'bottom'>, maxWidth: number, isRtl: boolean, tickLabelStyle: ChartsYAxisProps['tickLabelStyle']): Map<TickItemType, string>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { clampAngle } from "../internals/clampAngle.js";
|
|
4
|
+
import { doesTextFitInRect, ellipsize } from "../internals/ellipsize.js";
|
|
5
|
+
import { getStringSize } from "../internals/domUtils.js";
|
|
6
|
+
export function shortenLabels(visibleLabels, drawingArea, maxWidth, isRtl, tickLabelStyle) {
|
|
7
|
+
const shortenedLabels = new Map();
|
|
8
|
+
const angle = clampAngle(tickLabelStyle?.angle ?? 0);
|
|
9
|
+
let topBoundFactor = 1;
|
|
10
|
+
let bottomBoundFactor = 1;
|
|
11
|
+
if (tickLabelStyle?.textAnchor === 'start') {
|
|
12
|
+
topBoundFactor = Infinity;
|
|
13
|
+
bottomBoundFactor = 1;
|
|
14
|
+
} else if (tickLabelStyle?.textAnchor === 'end') {
|
|
15
|
+
topBoundFactor = 1;
|
|
16
|
+
bottomBoundFactor = Infinity;
|
|
17
|
+
} else {
|
|
18
|
+
topBoundFactor = 2;
|
|
19
|
+
bottomBoundFactor = 2;
|
|
20
|
+
}
|
|
21
|
+
if (angle > 180) {
|
|
22
|
+
[topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
|
|
23
|
+
}
|
|
24
|
+
if (isRtl) {
|
|
25
|
+
[topBoundFactor, bottomBoundFactor] = [bottomBoundFactor, topBoundFactor];
|
|
26
|
+
}
|
|
27
|
+
for (const item of visibleLabels) {
|
|
28
|
+
if (item.formattedValue) {
|
|
29
|
+
// That maximum height of the tick depends on its proximity to the axis bounds.
|
|
30
|
+
const height = Math.min((item.offset + item.labelOffset) * topBoundFactor, (drawingArea.top + drawingArea.height + drawingArea.bottom - item.offset - item.labelOffset) * bottomBoundFactor);
|
|
31
|
+
const doesTextFit = text => doesTextFitInRect(text, {
|
|
32
|
+
width: maxWidth,
|
|
33
|
+
height,
|
|
34
|
+
angle,
|
|
35
|
+
measureText: string => getStringSize(string, tickLabelStyle)
|
|
36
|
+
});
|
|
37
|
+
shortenedLabels.set(item, ellipsize(item.formattedValue.toString(), doesTextFit));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return shortenedLabels;
|
|
41
|
+
}
|
|
@@ -34,7 +34,10 @@ function AnimatedArea(props) {
|
|
|
34
34
|
// eslint-disable-next-line no-nested-ternary
|
|
35
35
|
ownerState.isHighlighted ? 'brightness(140%)' : ownerState.gradientId ? undefined : 'brightness(120%)',
|
|
36
36
|
opacity: ownerState.isFaded ? 0.3 : 1,
|
|
37
|
-
stroke: "none"
|
|
37
|
+
stroke: "none",
|
|
38
|
+
"data-series": ownerState.id,
|
|
39
|
+
"data-highlighted": ownerState.isHighlighted || undefined,
|
|
40
|
+
"data-faded": ownerState.isFaded || undefined
|
|
38
41
|
}, other, animatedProps))
|
|
39
42
|
});
|
|
40
43
|
}
|
|
@@ -36,7 +36,10 @@ const AnimatedLine = /*#__PURE__*/React.forwardRef(function AnimatedLine(props,
|
|
|
36
36
|
strokeLinejoin: "round",
|
|
37
37
|
fill: "none",
|
|
38
38
|
filter: ownerState.isHighlighted ? 'brightness(120%)' : undefined,
|
|
39
|
-
opacity: ownerState.isFaded ? 0.3 : 1
|
|
39
|
+
opacity: ownerState.isFaded ? 0.3 : 1,
|
|
40
|
+
"data-series": ownerState.id,
|
|
41
|
+
"data-highlighted": ownerState.isHighlighted || undefined,
|
|
42
|
+
"data-faded": ownerState.isFaded || undefined
|
|
40
43
|
}, other, animateProps))
|
|
41
44
|
});
|
|
42
45
|
});
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
4
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
5
|
const _excluded = ["slots", "slotProps", "onItemClick", "skipAnimation"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { styled } from '@mui/material/styles';
|
|
9
|
-
import { area as d3Area } from '@mui/x-charts-vendor/d3-shape';
|
|
10
9
|
import { AreaElement, areaElementClasses } from "./AreaElement.js";
|
|
11
|
-
import { getValueToPositionMapper } from "../hooks/useScale.js";
|
|
12
|
-
import { getCurveFactory } from "../internals/getCurve.js";
|
|
13
|
-
import { isBandScale } from "../internals/isBandScale.js";
|
|
14
|
-
import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
|
|
15
|
-
import { useLineSeriesContext } from "../hooks/useLineSeries.js";
|
|
16
10
|
import { useSkipAnimation } from "../hooks/useSkipAnimation.js";
|
|
17
|
-
import { useChartGradientIdBuilder } from "../hooks/useChartGradientId.js";
|
|
18
11
|
import { useXAxes, useYAxes } from "../hooks/useAxis.js";
|
|
19
12
|
import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js";
|
|
13
|
+
import { useAreaPlotData } from "./useAreaPlotData.js";
|
|
20
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
15
|
const AreaPlotRoot = styled('g', {
|
|
22
16
|
name: 'MuiAreaPlot',
|
|
@@ -27,117 +21,13 @@ const AreaPlotRoot = styled('g', {
|
|
|
27
21
|
}
|
|
28
22
|
});
|
|
29
23
|
const useAggregatedData = () => {
|
|
30
|
-
const seriesData = useLineSeriesContext();
|
|
31
24
|
const {
|
|
32
|
-
xAxis
|
|
33
|
-
xAxisIds
|
|
25
|
+
xAxis: xAxes
|
|
34
26
|
} = useXAxes();
|
|
35
27
|
const {
|
|
36
|
-
yAxis
|
|
37
|
-
yAxisIds
|
|
28
|
+
yAxis: yAxes
|
|
38
29
|
} = useYAxes();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// This memo prevents odd line chart behavior when hydrating.
|
|
42
|
-
const allData = React.useMemo(() => {
|
|
43
|
-
if (seriesData === undefined) {
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
const {
|
|
47
|
-
series,
|
|
48
|
-
stackingGroups
|
|
49
|
-
} = seriesData;
|
|
50
|
-
const defaultXAxisId = xAxisIds[0];
|
|
51
|
-
const defaultYAxisId = yAxisIds[0];
|
|
52
|
-
return stackingGroups.flatMap(({
|
|
53
|
-
ids: groupIds
|
|
54
|
-
}) => {
|
|
55
|
-
return [...groupIds].reverse() // Revert stacked area for a more pleasant animation
|
|
56
|
-
.map(seriesId => {
|
|
57
|
-
const {
|
|
58
|
-
xAxisId = defaultXAxisId,
|
|
59
|
-
yAxisId = defaultYAxisId,
|
|
60
|
-
stackedData,
|
|
61
|
-
data,
|
|
62
|
-
connectNulls,
|
|
63
|
-
baseline,
|
|
64
|
-
curve,
|
|
65
|
-
strictStepCurve
|
|
66
|
-
} = series[seriesId];
|
|
67
|
-
const xScale = xAxis[xAxisId].scale;
|
|
68
|
-
const xPosition = getValueToPositionMapper(xScale);
|
|
69
|
-
const yScale = yAxis[yAxisId].scale;
|
|
70
|
-
const xData = xAxis[xAxisId].data;
|
|
71
|
-
const gradientId = yAxis[yAxisId].colorScale && getGradientId(yAxisId) || xAxis[xAxisId].colorScale && getGradientId(xAxisId) || undefined;
|
|
72
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
73
|
-
if (xData === undefined) {
|
|
74
|
-
throw new Error(`MUI X Charts: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
75
|
-
}
|
|
76
|
-
if (xData.length < stackedData.length) {
|
|
77
|
-
throw new Error(`MUI X Charts: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const shouldExpand = curve?.includes('step') && !strictStepCurve && isBandScale(xScale);
|
|
81
|
-
const formattedData = xData?.flatMap((x, index) => {
|
|
82
|
-
const nullData = data[index] == null;
|
|
83
|
-
if (shouldExpand) {
|
|
84
|
-
const rep = [{
|
|
85
|
-
x,
|
|
86
|
-
y: stackedData[index],
|
|
87
|
-
nullData,
|
|
88
|
-
isExtension: false
|
|
89
|
-
}];
|
|
90
|
-
if (!nullData && (index === 0 || data[index - 1] == null)) {
|
|
91
|
-
rep.unshift({
|
|
92
|
-
x: (xScale(x) ?? 0) - (xScale.step() - xScale.bandwidth()) / 2,
|
|
93
|
-
y: stackedData[index],
|
|
94
|
-
nullData,
|
|
95
|
-
isExtension: true
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
if (!nullData && (index === data.length - 1 || data[index + 1] == null)) {
|
|
99
|
-
rep.push({
|
|
100
|
-
x: (xScale(x) ?? 0) + (xScale.step() + xScale.bandwidth()) / 2,
|
|
101
|
-
y: stackedData[index],
|
|
102
|
-
nullData,
|
|
103
|
-
isExtension: true
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
return rep;
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
x,
|
|
110
|
-
y: stackedData[index],
|
|
111
|
-
nullData
|
|
112
|
-
};
|
|
113
|
-
}) ?? [];
|
|
114
|
-
const d3Data = connectNulls ? formattedData.filter(d => !d.nullData) : formattedData;
|
|
115
|
-
const areaPath = d3Area().x(d => d.isExtension ? d.x : xPosition(d.x)).defined(d => connectNulls || !d.nullData || !!d.isExtension).y0(d => {
|
|
116
|
-
if (typeof baseline === 'number') {
|
|
117
|
-
return yScale(baseline);
|
|
118
|
-
}
|
|
119
|
-
if (baseline === 'max') {
|
|
120
|
-
return yScale.range()[1];
|
|
121
|
-
}
|
|
122
|
-
if (baseline === 'min') {
|
|
123
|
-
return yScale.range()[0];
|
|
124
|
-
}
|
|
125
|
-
const value = d.y && yScale(d.y[0]);
|
|
126
|
-
if (Number.isNaN(value)) {
|
|
127
|
-
return yScale.range()[0];
|
|
128
|
-
}
|
|
129
|
-
return value;
|
|
130
|
-
}).y1(d => d.y && yScale(d.y[1]));
|
|
131
|
-
const d = areaPath.curve(getCurveFactory(curve))(d3Data) || '';
|
|
132
|
-
return _extends({}, series[seriesId], {
|
|
133
|
-
gradientId,
|
|
134
|
-
d,
|
|
135
|
-
seriesId
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
}, [seriesData, xAxisIds, yAxisIds, xAxis, yAxis, getGradientId]);
|
|
140
|
-
return allData;
|
|
30
|
+
return useAreaPlotData(xAxes, yAxes);
|
|
141
31
|
};
|
|
142
32
|
|
|
143
33
|
/**
|
|
@@ -69,7 +69,10 @@ function CircleMarkElement(props) {
|
|
|
69
69
|
className: classes.root,
|
|
70
70
|
onClick: onClick,
|
|
71
71
|
cursor: onClick ? 'pointer' : 'unset'
|
|
72
|
-
}, interactionProps
|
|
72
|
+
}, interactionProps, {
|
|
73
|
+
"data-highlighted": isHighlighted || undefined,
|
|
74
|
+
"data-faded": isFaded || undefined
|
|
75
|
+
}));
|
|
73
76
|
}
|
|
74
77
|
process.env.NODE_ENV !== "production" ? CircleMarkElement.propTypes = {
|
|
75
78
|
// ----------------------------- Warning --------------------------------
|