@mui/x-charts 7.10.0 → 7.11.1
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.js +2 -2
- package/BarChart/BarElement.d.ts +2 -1
- package/BarChart/BarLabel/BarLabelItem.d.ts +2 -1
- package/BarChart/BarPlot.js +8 -8
- package/BarChart/checkScaleErrors.d.ts +4 -4
- package/BarChart/checkScaleErrors.js +11 -11
- package/BarChart/extremums.js +4 -1
- package/BarChart/formatter.js +2 -2
- package/BarChart/useBarChartProps.js +38 -33
- package/CHANGELOG.md +169 -0
- package/ChartContainer/ChartContainer.d.ts +28 -2
- package/ChartContainer/ChartContainer.js +25 -66
- package/ChartContainer/useChartContainerHooks.d.ts +1 -1
- package/ChartContainer/useChartContainerHooks.js +2 -2
- package/ChartContainer/useChartContainerProps.d.ts +86 -0
- package/ChartContainer/useChartContainerProps.js +95 -0
- package/ChartContainer/useDefaultizeAxis.d.ts +36 -0
- package/ChartContainer/useDefaultizeAxis.js +29 -0
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsLegend/ChartsLegend.d.ts +3 -12
- package/ChartsLegend/ContinuousColorLegend.d.ts +65 -0
- package/ChartsLegend/ContinuousColorLegend.js +398 -0
- package/ChartsLegend/DefaultChartsLegend.d.ts +7 -50
- package/ChartsLegend/DefaultChartsLegend.js +13 -198
- package/ChartsLegend/LegendPerItem.d.ts +61 -0
- package/ChartsLegend/LegendPerItem.js +151 -0
- package/ChartsLegend/PiecewiseColorLegend.d.ts +26 -0
- package/ChartsLegend/PiecewiseColorLegend.js +169 -0
- package/ChartsLegend/chartsLegend.types.d.ts +31 -0
- package/ChartsLegend/chartsLegend.types.js +5 -0
- package/ChartsLegend/index.d.ts +2 -0
- package/ChartsLegend/index.js +22 -0
- package/ChartsLegend/legend.types.d.ts +62 -0
- package/ChartsLegend/legend.types.js +5 -0
- package/ChartsLegend/legendItemsPlacement.d.ts +3 -0
- package/ChartsLegend/legendItemsPlacement.js +79 -0
- package/ChartsLegend/useAxis.d.ts +7 -0
- package/ChartsLegend/useAxis.js +47 -0
- package/ChartsLegend/utils.d.ts +1 -8
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
- package/ChartsOverlay/ChartsOverlay.d.ts +3 -2
- package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
- package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
- package/ChartsSurface.js +3 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
- package/ChartsXAxis/ChartsXAxis.js +1 -1
- package/ChartsYAxis/ChartsYAxis.js +15 -3
- package/Gauge/Gauge.d.ts +1 -4
- package/Gauge/Gauge.js +9 -6
- package/Gauge/GaugeContainer.js +8 -4
- package/Gauge/GaugeProvider.js +9 -9
- package/LineChart/AnimatedArea.js +2 -2
- package/LineChart/AnimatedLine.js +2 -2
- package/LineChart/AreaElement.d.ts +2 -1
- package/LineChart/AreaPlot.js +10 -6
- package/LineChart/LineChart.js +5 -2
- package/LineChart/LineElement.d.ts +2 -1
- package/LineChart/LineHighlightPlot.d.ts +2 -1
- package/LineChart/LineHighlightPlot.js +17 -5
- package/LineChart/LinePlot.js +10 -6
- package/LineChart/MarkElement.js +2 -2
- package/LineChart/MarkPlot.js +13 -25
- package/LineChart/extremums.js +4 -1
- package/LineChart/formatter.js +2 -2
- package/LineChart/useLineChartProps.js +38 -33
- package/PieChart/PieArc.js +1 -0
- package/PieChart/PieChart.d.ts +1 -4
- package/PieChart/PieChart.js +40 -34
- package/PieChart/PiePlot.js +6 -6
- package/PieChart/getPieCoordinates.js +3 -3
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +5 -1
- package/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +20 -0
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +73 -0
- package/ScatterChart/Scatter.js +6 -9
- package/ScatterChart/ScatterChart.js +4 -1
- package/ScatterChart/ScatterPlot.js +6 -3
- package/ScatterChart/extremums.js +8 -2
- package/ScatterChart/useScatterChartProps.js +35 -30
- package/SparkLineChart/SparkLineChart.js +27 -22
- package/context/CartesianProvider/CartesianContext.d.ts +1 -1
- package/context/CartesianProvider/CartesianProvider.d.ts +2 -3
- package/context/CartesianProvider/CartesianProvider.js +18 -7
- package/context/CartesianProvider/computeValue.d.ts +32 -9
- package/context/CartesianProvider/computeValue.js +20 -16
- package/context/CartesianProvider/defaultizeAxis.d.ts +36 -0
- package/context/CartesianProvider/defaultizeAxis.js +21 -0
- package/context/CartesianProvider/index.d.ts +0 -1
- package/context/CartesianProvider/index.js +1 -3
- package/context/CartesianProvider/normalizeAxis.d.ts +1 -1
- package/context/CartesianProvider/normalizeAxis.js +2 -2
- package/context/DrawingProvider.d.ts +12 -0
- package/context/DrawingProvider.js +15 -2
- package/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/context/SeriesContextProvider.js +1 -1
- package/context/ZAxisContextProvider.d.ts +1 -1
- package/context/ZAxisContextProvider.js +1 -1
- package/esm/BarChart/BarChart.js +2 -2
- package/esm/BarChart/BarPlot.js +8 -8
- package/esm/BarChart/checkScaleErrors.js +11 -11
- package/esm/BarChart/extremums.js +4 -1
- package/esm/BarChart/formatter.js +2 -2
- package/esm/BarChart/useBarChartProps.js +38 -33
- package/esm/ChartContainer/ChartContainer.js +25 -66
- package/esm/ChartContainer/useChartContainerHooks.js +2 -2
- package/esm/ChartContainer/useChartContainerProps.js +87 -0
- package/esm/ChartContainer/useDefaultizeAxis.js +19 -0
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/esm/ChartsLegend/ContinuousColorLegend.js +390 -0
- package/esm/ChartsLegend/DefaultChartsLegend.js +14 -198
- package/esm/ChartsLegend/LegendPerItem.js +141 -0
- package/esm/ChartsLegend/PiecewiseColorLegend.js +161 -0
- package/esm/ChartsLegend/chartsLegend.types.js +1 -0
- package/esm/ChartsLegend/index.js +2 -0
- package/esm/ChartsLegend/legend.types.js +1 -0
- package/esm/ChartsLegend/legendItemsPlacement.js +72 -0
- package/esm/ChartsLegend/useAxis.js +39 -0
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
- package/esm/ChartsSurface.js +3 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
- package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
- package/esm/ChartsYAxis/ChartsYAxis.js +15 -3
- package/esm/Gauge/Gauge.js +8 -5
- package/esm/Gauge/GaugeContainer.js +8 -4
- package/esm/Gauge/GaugeProvider.js +1 -1
- package/esm/LineChart/AnimatedArea.js +1 -1
- package/esm/LineChart/AnimatedLine.js +1 -1
- package/esm/LineChart/AreaPlot.js +10 -6
- package/esm/LineChart/LineChart.js +5 -2
- package/esm/LineChart/LineHighlightPlot.js +17 -5
- package/esm/LineChart/LinePlot.js +10 -6
- package/esm/LineChart/MarkElement.js +1 -1
- package/esm/LineChart/MarkPlot.js +12 -24
- package/esm/LineChart/extremums.js +4 -1
- package/esm/LineChart/formatter.js +2 -2
- package/esm/LineChart/useLineChartProps.js +38 -33
- package/esm/PieChart/PieArc.js +1 -0
- package/esm/PieChart/PieChart.js +39 -33
- package/esm/PieChart/PiePlot.js +1 -1
- package/esm/PieChart/getPieCoordinates.js +1 -1
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
- package/esm/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
- package/esm/ScatterChart/Scatter.js +6 -9
- package/esm/ScatterChart/ScatterChart.js +4 -1
- package/esm/ScatterChart/ScatterPlot.js +6 -3
- package/esm/ScatterChart/extremums.js +8 -2
- package/esm/ScatterChart/useScatterChartProps.js +35 -30
- package/esm/SparkLineChart/SparkLineChart.js +27 -22
- package/esm/context/CartesianProvider/CartesianProvider.js +18 -7
- package/esm/context/CartesianProvider/computeValue.js +20 -16
- package/esm/context/CartesianProvider/defaultizeAxis.js +13 -0
- package/esm/context/CartesianProvider/index.js +1 -3
- package/esm/context/CartesianProvider/normalizeAxis.js +2 -2
- package/esm/context/DrawingProvider.js +15 -2
- package/esm/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/esm/context/SeriesContextProvider.js +1 -1
- package/esm/context/ZAxisContextProvider.js +1 -1
- package/esm/hooks/useAxisEvents.js +14 -17
- package/esm/hooks/useDrawingArea.js +5 -3
- package/esm/hooks/useReducedMotion.js +4 -2
- package/esm/internals/SlotComponentPropsFromProps.js +1 -0
- package/esm/internals/cleanId.js +6 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/esm/internals/geometry.js +1 -1
- package/esm/internals/{utils.js → getPercentageValue.js} +1 -13
- package/esm/internals/getSymbol.js +5 -0
- package/esm/internals/index.js +3 -1
- package/esm/internals/isDefined.js +3 -0
- package/esm/internals/notNull.js +3 -0
- package/esm/internals/ts-generic.js +1 -0
- package/esm/internals/warning.js +19 -11
- package/hooks/useAxisEvents.js +14 -17
- package/hooks/useDrawingArea.js +5 -3
- package/hooks/useReducedMotion.js +4 -2
- package/index.js +1 -1
- package/internals/SlotComponentPropsFromProps.d.ts +1 -0
- package/internals/SlotComponentPropsFromProps.js +5 -0
- package/internals/cleanId.d.ts +4 -0
- package/internals/cleanId.js +12 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +6 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/internals/defaultizeColor.d.ts +7 -0
- package/internals/geometry.js +1 -1
- package/internals/getPercentageValue.d.ts +7 -0
- package/internals/{utils.js → getPercentageValue.js} +1 -15
- package/internals/getSymbol.d.ts +2 -0
- package/internals/getSymbol.js +11 -0
- package/internals/index.d.ts +3 -1
- package/internals/index.js +25 -5
- package/internals/isDefined.d.ts +1 -0
- package/internals/isDefined.js +9 -0
- package/internals/notNull.d.ts +1 -0
- package/internals/notNull.js +9 -0
- package/internals/ts-generic.d.ts +5 -0
- package/internals/ts-generic.js +5 -0
- package/internals/warning.d.ts +2 -1
- package/internals/warning.js +21 -12
- package/models/axis.d.ts +5 -2
- package/models/helpers.d.ts +1 -0
- package/models/seriesType/common.d.ts +10 -0
- package/models/seriesType/config.d.ts +2 -16
- package/models/seriesType/scatter.d.ts +5 -0
- package/modern/BarChart/BarChart.js +2 -2
- package/modern/BarChart/BarPlot.js +8 -8
- package/modern/BarChart/checkScaleErrors.js +11 -11
- package/modern/BarChart/extremums.js +4 -1
- package/modern/BarChart/formatter.js +2 -2
- package/modern/BarChart/useBarChartProps.js +38 -33
- package/modern/ChartContainer/ChartContainer.js +25 -66
- package/modern/ChartContainer/useChartContainerHooks.js +2 -2
- package/modern/ChartContainer/useChartContainerProps.js +87 -0
- package/modern/ChartContainer/useDefaultizeAxis.js +19 -0
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/modern/ChartsLegend/ContinuousColorLegend.js +390 -0
- package/modern/ChartsLegend/DefaultChartsLegend.js +14 -198
- package/modern/ChartsLegend/LegendPerItem.js +141 -0
- package/modern/ChartsLegend/PiecewiseColorLegend.js +161 -0
- package/modern/ChartsLegend/chartsLegend.types.js +1 -0
- package/modern/ChartsLegend/index.js +2 -0
- package/modern/ChartsLegend/legend.types.js +1 -0
- package/modern/ChartsLegend/legendItemsPlacement.js +72 -0
- package/modern/ChartsLegend/useAxis.js +39 -0
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
- package/modern/ChartsSurface.js +3 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
- package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
- package/modern/ChartsYAxis/ChartsYAxis.js +15 -3
- package/modern/Gauge/Gauge.js +8 -5
- package/modern/Gauge/GaugeContainer.js +8 -4
- package/modern/Gauge/GaugeProvider.js +1 -1
- package/modern/LineChart/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AreaPlot.js +10 -6
- package/modern/LineChart/LineChart.js +5 -2
- package/modern/LineChart/LineHighlightPlot.js +17 -5
- package/modern/LineChart/LinePlot.js +10 -6
- package/modern/LineChart/MarkElement.js +1 -1
- package/modern/LineChart/MarkPlot.js +12 -24
- package/modern/LineChart/extremums.js +4 -1
- package/modern/LineChart/formatter.js +2 -2
- package/modern/LineChart/useLineChartProps.js +38 -33
- package/modern/PieChart/PieArc.js +1 -0
- package/modern/PieChart/PieChart.js +39 -33
- package/modern/PieChart/PiePlot.js +1 -1
- package/modern/PieChart/getPieCoordinates.js +1 -1
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
- package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
- package/modern/ScatterChart/Scatter.js +6 -9
- package/modern/ScatterChart/ScatterChart.js +4 -1
- package/modern/ScatterChart/ScatterPlot.js +6 -3
- package/modern/ScatterChart/extremums.js +8 -2
- package/modern/ScatterChart/useScatterChartProps.js +35 -30
- package/modern/SparkLineChart/SparkLineChart.js +27 -22
- package/modern/context/CartesianProvider/CartesianProvider.js +18 -7
- package/modern/context/CartesianProvider/computeValue.js +20 -16
- package/modern/context/CartesianProvider/defaultizeAxis.js +13 -0
- package/modern/context/CartesianProvider/index.js +1 -3
- package/modern/context/CartesianProvider/normalizeAxis.js +2 -2
- package/modern/context/DrawingProvider.js +15 -2
- package/modern/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/modern/context/SeriesContextProvider.js +1 -1
- package/modern/context/ZAxisContextProvider.js +1 -1
- package/modern/hooks/useAxisEvents.js +14 -17
- package/modern/hooks/useDrawingArea.js +5 -3
- package/modern/hooks/useReducedMotion.js +4 -2
- package/modern/index.js +1 -1
- package/modern/internals/SlotComponentPropsFromProps.js +1 -0
- package/modern/internals/cleanId.js +6 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/modern/internals/geometry.js +1 -1
- package/modern/internals/{utils.js → getPercentageValue.js} +1 -13
- package/modern/internals/getSymbol.js +5 -0
- package/modern/internals/index.js +3 -1
- package/modern/internals/isDefined.js +3 -0
- package/modern/internals/notNull.js +3 -0
- package/modern/internals/ts-generic.js +1 -0
- package/modern/internals/warning.js +19 -11
- package/package.json +4 -4
- package/internals/utils.d.ts +0 -18
package/ChartsLegend/index.d.ts
CHANGED
package/ChartsLegend/index.js
CHANGED
|
@@ -25,6 +25,28 @@ Object.keys(_DefaultChartsLegend).forEach(function (key) {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
+
var _ContinuousColorLegend = require("./ContinuousColorLegend");
|
|
29
|
+
Object.keys(_ContinuousColorLegend).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _ContinuousColorLegend[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _ContinuousColorLegend[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _PiecewiseColorLegend = require("./PiecewiseColorLegend");
|
|
40
|
+
Object.keys(_PiecewiseColorLegend).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _PiecewiseColorLegend[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _PiecewiseColorLegend[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
28
50
|
var _chartsLegendClasses = require("./chartsLegendClasses");
|
|
29
51
|
Object.keys(_chartsLegendClasses).forEach(function (key) {
|
|
30
52
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ChartsTextBaseline, ChartsTextStyle } from '../internals/getWordsByLines';
|
|
2
|
+
import { AxisId } from '../models/axis';
|
|
3
|
+
export type AnchorX = 'left' | 'right' | 'middle';
|
|
4
|
+
export type AnchorY = 'top' | 'bottom' | 'middle';
|
|
5
|
+
export type AnchorPosition = {
|
|
6
|
+
horizontal: AnchorX;
|
|
7
|
+
vertical: AnchorY;
|
|
8
|
+
};
|
|
9
|
+
export type Direction = 'row' | 'column';
|
|
10
|
+
export interface ColorLegendSelector {
|
|
11
|
+
/**
|
|
12
|
+
* The axis direction containing the color configuration to represent.
|
|
13
|
+
* @default 'z'
|
|
14
|
+
*/
|
|
15
|
+
axisDirection?: 'x' | 'y' | 'z';
|
|
16
|
+
/**
|
|
17
|
+
* The id of the axis item with the color configuration to represent.
|
|
18
|
+
* @default The first axis item.
|
|
19
|
+
*/
|
|
20
|
+
axisId?: AxisId;
|
|
21
|
+
}
|
|
22
|
+
export interface LegendPlacement {
|
|
23
|
+
/**
|
|
24
|
+
* The position of the legend.
|
|
25
|
+
*/
|
|
26
|
+
position?: AnchorPosition;
|
|
27
|
+
/**
|
|
28
|
+
* The direction of the legend layout.
|
|
29
|
+
* The default depends on the chart.
|
|
30
|
+
*/
|
|
31
|
+
direction?: Direction;
|
|
32
|
+
}
|
|
33
|
+
export type BoundingBox = {
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
37
|
+
export interface Position {
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
}
|
|
41
|
+
export interface TextPosition extends Position {
|
|
42
|
+
dominantBaseline: ChartsTextBaseline;
|
|
43
|
+
textAnchor: ChartsTextStyle['textAnchor'];
|
|
44
|
+
}
|
|
45
|
+
export type PiecewiseLabelFormatterParams = {
|
|
46
|
+
/**
|
|
47
|
+
* The min value of the piece. `null` is infinite.
|
|
48
|
+
*/
|
|
49
|
+
min: number | Date | null;
|
|
50
|
+
/**
|
|
51
|
+
* The max value of the piece. `null` is infinite.
|
|
52
|
+
*/
|
|
53
|
+
max: number | Date | null;
|
|
54
|
+
/**
|
|
55
|
+
* The formatted min value of the piece. `null` is infinite.
|
|
56
|
+
*/
|
|
57
|
+
formattedMin: string | null;
|
|
58
|
+
/**
|
|
59
|
+
* The formatted max value of the piece. `null` is infinite.
|
|
60
|
+
*/
|
|
61
|
+
formattedMax: string | null;
|
|
62
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ChartsTextStyle } from '../ChartsText';
|
|
2
|
+
import { GetItemSpaceType, LegendItemParams, LegendItemWithPosition } from './chartsLegend.types';
|
|
3
|
+
export declare function legendItemPlacements(itemsToDisplay: LegendItemParams[], getItemSpace: GetItemSpaceType, labelStyle: ChartsTextStyle, direction: string, availableWidth: number, availableHeight: number, itemGap: number): [LegendItemWithPosition[], number, number];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.legendItemPlacements = legendItemPlacements;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
|
+
const _excluded = ["label"];
|
|
11
|
+
function legendItemPlacements(itemsToDisplay, getItemSpace, labelStyle, direction, availableWidth, availableHeight, itemGap) {
|
|
12
|
+
// Start at 0, 0. Will be modified later by padding and position.
|
|
13
|
+
let x = 0;
|
|
14
|
+
let y = 0;
|
|
15
|
+
|
|
16
|
+
// total values used to align legend later.
|
|
17
|
+
let totalWidthUsed = 0;
|
|
18
|
+
let totalHeightUsed = 0;
|
|
19
|
+
let rowIndex = 0;
|
|
20
|
+
const rowMaxHeight = [0];
|
|
21
|
+
const seriesWithRawPosition = itemsToDisplay.map(_ref => {
|
|
22
|
+
let {
|
|
23
|
+
label
|
|
24
|
+
} = _ref,
|
|
25
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
26
|
+
const itemSpace = getItemSpace(label, labelStyle);
|
|
27
|
+
const rep = (0, _extends2.default)({}, other, {
|
|
28
|
+
label,
|
|
29
|
+
positionX: x,
|
|
30
|
+
positionY: y,
|
|
31
|
+
innerHeight: itemSpace.innerHeight,
|
|
32
|
+
innerWidth: itemSpace.innerWidth,
|
|
33
|
+
outerHeight: itemSpace.outerHeight,
|
|
34
|
+
outerWidth: itemSpace.outerWidth,
|
|
35
|
+
rowIndex
|
|
36
|
+
});
|
|
37
|
+
if (direction === 'row') {
|
|
38
|
+
if (x + itemSpace.innerWidth > availableWidth) {
|
|
39
|
+
// This legend item would create overflow along the x-axis, so we start a new row.
|
|
40
|
+
x = 0;
|
|
41
|
+
y += rowMaxHeight[rowIndex];
|
|
42
|
+
rowIndex += 1;
|
|
43
|
+
if (rowMaxHeight.length <= rowIndex) {
|
|
44
|
+
rowMaxHeight.push(0);
|
|
45
|
+
}
|
|
46
|
+
rep.positionX = x;
|
|
47
|
+
rep.positionY = y;
|
|
48
|
+
rep.rowIndex = rowIndex;
|
|
49
|
+
}
|
|
50
|
+
totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
|
|
51
|
+
totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
|
|
52
|
+
rowMaxHeight[rowIndex] = Math.max(rowMaxHeight[rowIndex], itemSpace.outerHeight);
|
|
53
|
+
x += itemSpace.outerWidth;
|
|
54
|
+
}
|
|
55
|
+
if (direction === 'column') {
|
|
56
|
+
if (y + itemSpace.innerHeight > availableHeight) {
|
|
57
|
+
// This legend item would create overflow along the y-axis, so we start a new column.
|
|
58
|
+
x = totalWidthUsed + itemGap;
|
|
59
|
+
y = 0;
|
|
60
|
+
rowIndex = 0;
|
|
61
|
+
rep.positionX = x;
|
|
62
|
+
rep.positionY = y;
|
|
63
|
+
rep.rowIndex = rowIndex;
|
|
64
|
+
}
|
|
65
|
+
if (rowMaxHeight.length <= rowIndex) {
|
|
66
|
+
rowMaxHeight.push(0);
|
|
67
|
+
}
|
|
68
|
+
totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
|
|
69
|
+
totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
|
|
70
|
+
rowIndex += 1;
|
|
71
|
+
y += itemSpace.outerHeight;
|
|
72
|
+
}
|
|
73
|
+
return rep;
|
|
74
|
+
});
|
|
75
|
+
return [seriesWithRawPosition.map(item => (0, _extends2.default)({}, item, {
|
|
76
|
+
positionY: item.positionY + (direction === 'row' ? rowMaxHeight[item.rowIndex] / 2 // Get the center of the entire row
|
|
77
|
+
: item.outerHeight / 2) // Get the center of the item
|
|
78
|
+
})), totalWidthUsed, totalHeightUsed];
|
|
79
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AxisDefaultized } from '../models/axis';
|
|
2
|
+
import { ZAxisDefaultized } from '../models/z-axis';
|
|
3
|
+
import { ColorLegendSelector } from './legend.types';
|
|
4
|
+
/**
|
|
5
|
+
* Helper to select an axis definition according to its direction and id.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useAxis({ axisDirection, axisId, }: ColorLegendSelector): ZAxisDefaultized | AxisDefaultized;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAxis = useAxis;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _ZAxisContextProvider = require("../context/ZAxisContextProvider");
|
|
9
|
+
var _useCartesianContext = require("../context/CartesianProvider/useCartesianContext");
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
|
+
/**
|
|
13
|
+
* Helper to select an axis definition according to its direction and id.
|
|
14
|
+
*/
|
|
15
|
+
function useAxis({
|
|
16
|
+
axisDirection,
|
|
17
|
+
axisId
|
|
18
|
+
}) {
|
|
19
|
+
const {
|
|
20
|
+
xAxis,
|
|
21
|
+
xAxisIds,
|
|
22
|
+
yAxis,
|
|
23
|
+
yAxisIds
|
|
24
|
+
} = (0, _useCartesianContext.useCartesianContext)();
|
|
25
|
+
const {
|
|
26
|
+
zAxis,
|
|
27
|
+
zAxisIds
|
|
28
|
+
} = React.useContext(_ZAxisContextProvider.ZAxisContext);
|
|
29
|
+
switch (axisDirection) {
|
|
30
|
+
case 'x':
|
|
31
|
+
{
|
|
32
|
+
const id = typeof axisId === 'string' ? axisId : xAxisIds[axisId ?? 0];
|
|
33
|
+
return xAxis[id];
|
|
34
|
+
}
|
|
35
|
+
case 'y':
|
|
36
|
+
{
|
|
37
|
+
const id = typeof axisId === 'string' ? axisId : yAxisIds[axisId ?? 0];
|
|
38
|
+
return yAxis[id];
|
|
39
|
+
}
|
|
40
|
+
case 'z':
|
|
41
|
+
default:
|
|
42
|
+
{
|
|
43
|
+
const id = typeof axisId === 'string' ? axisId : zAxisIds[axisId ?? 0];
|
|
44
|
+
return zAxis[id];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
package/ChartsLegend/utils.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
1
|
import { FormattedSeries } from '../context/SeriesContextProvider';
|
|
2
|
-
export
|
|
3
|
-
export type AnchorY = 'top' | 'bottom' | 'middle';
|
|
4
|
-
export type AnchorPosition = {
|
|
5
|
-
horizontal: AnchorX;
|
|
6
|
-
vertical: AnchorY;
|
|
7
|
-
};
|
|
8
|
-
export type Direction = 'row' | 'column';
|
|
9
|
-
export declare function getSeriesToDisplay(series: FormattedSeries): import("../models/seriesType/config").LegendParams[];
|
|
2
|
+
export declare function getSeriesToDisplay(series: FormattedSeries): import("./chartsLegend.types").LegendItemParams[];
|
|
@@ -46,7 +46,9 @@ function ChartsOnAxisClickHandler(props) {
|
|
|
46
46
|
Object.keys(series).filter(seriesType => ['bar', 'line'].includes(seriesType)).forEach(seriesType => {
|
|
47
47
|
series[seriesType]?.seriesOrder.forEach(seriesId => {
|
|
48
48
|
const seriesItem = series[seriesType].series[seriesId];
|
|
49
|
-
const
|
|
49
|
+
const providedXAxisId = seriesItem.xAxisId ?? seriesItem.xAxisKey;
|
|
50
|
+
const providedYAxisId = seriesItem.yAxisId ?? seriesItem.yAxisKey;
|
|
51
|
+
const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
|
|
50
52
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
51
53
|
seriesValues[seriesId] = seriesItem.data[dataIndex];
|
|
52
54
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { SxProps, Theme } from '@mui/material/styles';
|
|
3
|
+
import { SlotComponentPropsFromProps } from '../internals/SlotComponentPropsFromProps';
|
|
3
4
|
export declare function useNoData(): boolean;
|
|
4
5
|
export type CommonOverlayProps = React.SVGAttributes<SVGTextElement> & {
|
|
5
6
|
/**
|
|
@@ -21,8 +22,8 @@ export interface ChartsOverlaySlots {
|
|
|
21
22
|
noDataOverlay?: React.ElementType<CommonOverlayProps>;
|
|
22
23
|
}
|
|
23
24
|
export interface ChartsOverlaySlotProps {
|
|
24
|
-
loadingOverlay?:
|
|
25
|
-
noDataOverlay?:
|
|
25
|
+
loadingOverlay?: SlotComponentPropsFromProps<CommonOverlayProps, {}, {}>;
|
|
26
|
+
noDataOverlay?: SlotComponentPropsFromProps<CommonOverlayProps, {}, {}>;
|
|
26
27
|
}
|
|
27
28
|
export interface ChartsOverlayProps {
|
|
28
29
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ChartsXReferenceLineProps } from './ChartsXReferenceLine';
|
|
3
3
|
import { ChartsYReferenceLineProps } from './ChartsYReferenceLine';
|
|
4
|
-
import { XOR } from '../internals/
|
|
4
|
+
import { XOR } from '../internals/ts-generic';
|
|
5
5
|
type ChartsReferenceLineProps<TValue extends string | number | Date = string | number | Date> = XOR<ChartsXReferenceLineProps<TValue>, ChartsYReferenceLineProps<TValue>>;
|
|
6
6
|
declare function ChartsReferenceLine(props: ChartsReferenceLineProps): React.JSX.Element;
|
|
7
7
|
declare namespace ChartsReferenceLine {
|
|
@@ -19,10 +19,10 @@ function ChartsReferenceLine(props) {
|
|
|
19
19
|
y
|
|
20
20
|
} = props;
|
|
21
21
|
if (x !== undefined && y !== undefined) {
|
|
22
|
-
throw new Error('MUI X
|
|
22
|
+
throw new Error('MUI X: The ChartsReferenceLine cannot have both `x` and `y` props set.');
|
|
23
23
|
}
|
|
24
24
|
if (x === undefined && y === undefined) {
|
|
25
|
-
throw new Error('MUI X
|
|
25
|
+
throw new Error('MUI X: The ChartsReferenceLine should have a value in `x` or `y` prop.');
|
|
26
26
|
}
|
|
27
27
|
if (x !== undefined) {
|
|
28
28
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsXReferenceLine.ChartsXReferenceLine, (0, _extends2.default)({}, props));
|
|
@@ -57,7 +57,6 @@ function getXReferenceLineClasses(classes) {
|
|
|
57
57
|
label: ['label']
|
|
58
58
|
}, _chartsReferenceLineClasses.getReferenceLineUtilityClass, classes);
|
|
59
59
|
}
|
|
60
|
-
const valueError = (0, _warning.buildWarning)((value, id) => `MUI X Charts: the value ${value} does not exist in the data of x axis with id ${id}.`, 'error');
|
|
61
60
|
function ChartsXReferenceLine(props) {
|
|
62
61
|
const {
|
|
63
62
|
x,
|
|
@@ -77,7 +76,7 @@ function ChartsXReferenceLine(props) {
|
|
|
77
76
|
const xPosition = xAxisScale(x);
|
|
78
77
|
if (xPosition === undefined) {
|
|
79
78
|
if (process.env.NODE_ENV !== 'production') {
|
|
80
|
-
|
|
79
|
+
(0, _warning.warnOnce)(`MUI X: the value ${x} does not exist in the data of x axis with id ${axisId}.`, 'error');
|
|
81
80
|
}
|
|
82
81
|
return null;
|
|
83
82
|
}
|
|
@@ -57,7 +57,6 @@ function getYReferenceLineClasses(classes) {
|
|
|
57
57
|
label: ['label']
|
|
58
58
|
}, _chartsReferenceLineClasses.getReferenceLineUtilityClass, classes);
|
|
59
59
|
}
|
|
60
|
-
const valueError = (0, _warning.buildWarning)((value, id) => `MUI X Charts: the value ${value} does not exist in the data of y axis with id ${id}.`, 'error');
|
|
61
60
|
function ChartsYReferenceLine(props) {
|
|
62
61
|
const {
|
|
63
62
|
y,
|
|
@@ -77,7 +76,7 @@ function ChartsYReferenceLine(props) {
|
|
|
77
76
|
const yPosition = yAxisScale(y);
|
|
78
77
|
if (yPosition === undefined) {
|
|
79
78
|
if (process.env.NODE_ENV !== 'production') {
|
|
80
|
-
|
|
79
|
+
(0, _warning.warnOnce)(`MUI X: the value ${y} does not exist in the data of y axis with id ${axisId}.`, 'error');
|
|
81
80
|
}
|
|
82
81
|
return null;
|
|
83
82
|
}
|
package/ChartsSurface.js
CHANGED
|
@@ -30,6 +30,7 @@ const ChartsSurface = exports.ChartsSurface = /*#__PURE__*/React.forwardRef(func
|
|
|
30
30
|
height,
|
|
31
31
|
viewBox,
|
|
32
32
|
disableAxisListener = false,
|
|
33
|
+
className,
|
|
33
34
|
title,
|
|
34
35
|
desc
|
|
35
36
|
} = props,
|
|
@@ -45,7 +46,8 @@ const ChartsSurface = exports.ChartsSurface = /*#__PURE__*/React.forwardRef(func
|
|
|
45
46
|
width: width,
|
|
46
47
|
height: height,
|
|
47
48
|
viewBox: `${svgView.x} ${svgView.y} ${svgView.width} ${svgView.height}`,
|
|
48
|
-
ref: ref
|
|
49
|
+
ref: ref,
|
|
50
|
+
className: className
|
|
49
51
|
}, other, {
|
|
50
52
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("title", {
|
|
51
53
|
children: title
|
|
@@ -49,11 +49,15 @@ function ChartsAxisTooltipContent(props) {
|
|
|
49
49
|
Object.keys(series).filter(_isCartesian.isCartesianSeriesType).forEach(seriesType => {
|
|
50
50
|
series[seriesType].seriesOrder.forEach(seriesId => {
|
|
51
51
|
const item = series[seriesType].series[seriesId];
|
|
52
|
-
const
|
|
52
|
+
const providedXAxisId = item.xAxisId ?? item.xAxisKey;
|
|
53
|
+
const providedYAxisId = item.yAxisId ?? item.yAxisKey;
|
|
54
|
+
const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
|
|
53
55
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
54
56
|
const seriesToAdd = series[seriesType].series[seriesId];
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
+
const xAxisId = providedXAxisId ?? xAxisIds[0];
|
|
58
|
+
const yAxisId = providedYAxisId ?? yAxisIds[0];
|
|
59
|
+
const zAxisId = seriesToAdd.zAxisId ?? seriesToAdd.zAxisKey ?? zAxisIds[0];
|
|
60
|
+
const getColor = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId && zAxis[zAxisId]) ?? (() => '');
|
|
57
61
|
rep.push((0, _extends2.default)({}, seriesToAdd, {
|
|
58
62
|
getColor
|
|
59
63
|
}));
|
|
@@ -39,10 +39,10 @@ function ChartsItemTooltipContent(props) {
|
|
|
39
39
|
zAxisIds
|
|
40
40
|
} = React.useContext(_ZAxisContextProvider.ZAxisContext);
|
|
41
41
|
const colorProcessors = (0, _useColor.useColorProcessor)();
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const getColor = colorProcessors[series.type]?.(series,
|
|
42
|
+
const xAxisId = series.xAxisId ?? series.xAxisKey ?? xAxisIds[0];
|
|
43
|
+
const yAxisId = series.yAxisId ?? series.yAxisKey ?? yAxisIds[0];
|
|
44
|
+
const zAxisId = series.zAxisId ?? series.zAxisKey ?? zAxisIds[0];
|
|
45
|
+
const getColor = colorProcessors[series.type]?.(series, xAxisId && xAxis[xAxisId], yAxisId && yAxis[yAxisId], zAxisId && zAxis[zAxisId]) ?? (() => '');
|
|
46
46
|
const Content = content ?? _DefaultChartsItemTooltipContent.DefaultChartsItemTooltipContent;
|
|
47
47
|
const chartTooltipContentProps = (0, _utils.useSlotProps)({
|
|
48
48
|
elementType: Content,
|
|
@@ -25,12 +25,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
25
25
|
onItemClick
|
|
26
26
|
} = props;
|
|
27
27
|
const svgRef = (0, _hooks.useSvgRef)();
|
|
28
|
-
const
|
|
29
|
-
left,
|
|
30
|
-
top,
|
|
31
|
-
width,
|
|
32
|
-
height
|
|
33
|
-
} = (0, _hooks.useDrawingArea)();
|
|
28
|
+
const drawingArea = (0, _hooks.useDrawingArea)();
|
|
34
29
|
const {
|
|
35
30
|
xAxis,
|
|
36
31
|
yAxis,
|
|
@@ -46,6 +41,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
46
41
|
} = (0, _useSeries.useScatterSeries)() ?? {};
|
|
47
42
|
const voronoiRef = React.useRef({});
|
|
48
43
|
const delauneyRef = React.useRef(undefined);
|
|
44
|
+
const lastFind = React.useRef(undefined);
|
|
49
45
|
const {
|
|
50
46
|
setHighlighted,
|
|
51
47
|
clearHighlighted
|
|
@@ -76,17 +72,32 @@ function ChartsVoronoiHandler(props) {
|
|
|
76
72
|
seriesOrder.forEach(seriesId => {
|
|
77
73
|
const {
|
|
78
74
|
data,
|
|
75
|
+
xAxisId,
|
|
76
|
+
yAxisId,
|
|
79
77
|
xAxisKey,
|
|
80
78
|
yAxisKey
|
|
81
79
|
} = series[seriesId];
|
|
82
|
-
const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
|
|
83
|
-
const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
|
|
80
|
+
const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
|
|
81
|
+
const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
|
|
84
82
|
const getXPosition = (0, _useScale.getValueToPositionMapper)(xScale);
|
|
85
83
|
const getYPosition = (0, _useScale.getValueToPositionMapper)(yScale);
|
|
86
84
|
const seriesPoints = data.flatMap(({
|
|
87
85
|
x,
|
|
88
86
|
y
|
|
89
|
-
}) =>
|
|
87
|
+
}) => {
|
|
88
|
+
const pointX = getXPosition(x);
|
|
89
|
+
const pointY = getYPosition(y);
|
|
90
|
+
if (!drawingArea.isPointInside({
|
|
91
|
+
x: pointX,
|
|
92
|
+
y: pointY
|
|
93
|
+
})) {
|
|
94
|
+
// If the point is not displayed we move them to a trash coordinate.
|
|
95
|
+
// This avoids managing index mapping before/after filtering.
|
|
96
|
+
// The trash point is far enough such that any point in the drawing area will be closer to the mouse than the trash coordinate.
|
|
97
|
+
return [-drawingArea.width, -drawingArea.height];
|
|
98
|
+
}
|
|
99
|
+
return [pointX, pointY];
|
|
100
|
+
});
|
|
90
101
|
voronoiRef.current[seriesId] = {
|
|
91
102
|
seriesId,
|
|
92
103
|
startIndex: points.length,
|
|
@@ -95,29 +106,28 @@ function ChartsVoronoiHandler(props) {
|
|
|
95
106
|
points = points.concat(seriesPoints);
|
|
96
107
|
});
|
|
97
108
|
delauneyRef.current = new _d3Delaunay.Delaunay(points);
|
|
98
|
-
|
|
109
|
+
lastFind.current = undefined;
|
|
110
|
+
}, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis, drawingArea]);
|
|
99
111
|
React.useEffect(() => {
|
|
100
112
|
const element = svgRef.current;
|
|
101
113
|
if (element === null) {
|
|
102
114
|
return undefined;
|
|
103
115
|
}
|
|
104
|
-
|
|
105
|
-
// TODO: A perf optimisation of voronoi could be to use the last point as the initial point for the next search.
|
|
106
116
|
function getClosestPoint(event) {
|
|
107
117
|
// Get mouse coordinate in global SVG space
|
|
108
118
|
const svgPoint = (0, _getSVGPoint.getSVGPoint)(element, event);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (outsideX || outsideY) {
|
|
119
|
+
if (!drawingArea.isPointInside(svgPoint)) {
|
|
120
|
+
lastFind.current = undefined;
|
|
112
121
|
return 'outside-chart';
|
|
113
122
|
}
|
|
114
123
|
if (!delauneyRef.current) {
|
|
115
124
|
return 'no-point-found';
|
|
116
125
|
}
|
|
117
|
-
const closestPointIndex = delauneyRef.current.find(svgPoint.x, svgPoint.y);
|
|
126
|
+
const closestPointIndex = delauneyRef.current.find(svgPoint.x, svgPoint.y, lastFind.current);
|
|
118
127
|
if (closestPointIndex === undefined) {
|
|
119
128
|
return 'no-point-found';
|
|
120
129
|
}
|
|
130
|
+
lastFind.current = closestPointIndex;
|
|
121
131
|
const closestSeries = Object.values(voronoiRef.current).find(value => {
|
|
122
132
|
return 2 * closestPointIndex >= value.startIndex && 2 * closestPointIndex < value.endIndex;
|
|
123
133
|
});
|
|
@@ -139,7 +149,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
139
149
|
dataIndex
|
|
140
150
|
};
|
|
141
151
|
}
|
|
142
|
-
const
|
|
152
|
+
const handleMouseLeave = () => {
|
|
143
153
|
dispatch({
|
|
144
154
|
type: 'exitChart'
|
|
145
155
|
});
|
|
@@ -200,15 +210,15 @@ function ChartsVoronoiHandler(props) {
|
|
|
200
210
|
dataIndex
|
|
201
211
|
});
|
|
202
212
|
};
|
|
203
|
-
element.addEventListener('
|
|
213
|
+
element.addEventListener('pointerleave', handleMouseLeave);
|
|
204
214
|
element.addEventListener('pointermove', handleMouseMove);
|
|
205
215
|
element.addEventListener('click', handleMouseClick);
|
|
206
216
|
return () => {
|
|
207
|
-
element.removeEventListener('
|
|
217
|
+
element.removeEventListener('pointerleave', handleMouseLeave);
|
|
208
218
|
element.removeEventListener('pointermove', handleMouseMove);
|
|
209
219
|
element.removeEventListener('click', handleMouseClick);
|
|
210
220
|
};
|
|
211
|
-
}, [svgRef, dispatch,
|
|
221
|
+
}, [svgRef, dispatch, yAxis, xAxis, voronoiMaxRadius, onItemClick, setHighlighted, clearHighlighted, drawingArea]);
|
|
212
222
|
|
|
213
223
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
214
224
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {});
|
|
@@ -221,7 +221,7 @@ function ChartsXAxis(inProps) {
|
|
|
221
221
|
x1: left,
|
|
222
222
|
x2: left + width,
|
|
223
223
|
className: classes.line
|
|
224
|
-
}, slotProps?.axisLine)), xTicksWithDimension.
|
|
224
|
+
}, slotProps?.axisLine)), xTicksWithDimension.map(({
|
|
225
225
|
formattedValue,
|
|
226
226
|
offset,
|
|
227
227
|
labelOffset,
|
|
@@ -145,6 +145,14 @@ function ChartsYAxis(inProps) {
|
|
|
145
145
|
},
|
|
146
146
|
ownerState: {}
|
|
147
147
|
});
|
|
148
|
+
const lineSlotProps = (0, _utils.useSlotProps)({
|
|
149
|
+
elementType: Line,
|
|
150
|
+
externalSlotProps: slotProps?.axisLine,
|
|
151
|
+
additionalProps: {
|
|
152
|
+
strokeLinecap: 'square'
|
|
153
|
+
},
|
|
154
|
+
ownerState: {}
|
|
155
|
+
});
|
|
148
156
|
const domain = yScale.domain();
|
|
149
157
|
if (domain.length === 0 || domain[0] === domain[1]) {
|
|
150
158
|
// Skip axis rendering if
|
|
@@ -156,10 +164,10 @@ function ChartsYAxis(inProps) {
|
|
|
156
164
|
transform: `translate(${position === 'right' ? left + width : left}, 0)`,
|
|
157
165
|
className: classes.root,
|
|
158
166
|
children: [!disableLine && /*#__PURE__*/(0, _jsxRuntime.jsx)(Line, (0, _extends2.default)({
|
|
159
|
-
y1:
|
|
160
|
-
y2:
|
|
167
|
+
y1: top,
|
|
168
|
+
y2: top + height,
|
|
161
169
|
className: classes.line
|
|
162
|
-
},
|
|
170
|
+
}, lineSlotProps)), yTicks.map(({
|
|
163
171
|
formattedValue,
|
|
164
172
|
offset,
|
|
165
173
|
labelOffset,
|
|
@@ -168,6 +176,10 @@ function ChartsYAxis(inProps) {
|
|
|
168
176
|
const xTickLabel = positionSign * (tickSize + 2);
|
|
169
177
|
const yTickLabel = labelOffset;
|
|
170
178
|
const skipLabel = typeof tickLabelInterval === 'function' && !tickLabelInterval?.(value, index);
|
|
179
|
+
const showLabel = offset >= top - 1 && offset <= height + top + 1;
|
|
180
|
+
if (!showLabel) {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
171
183
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
172
184
|
transform: `translate(0, ${offset})`,
|
|
173
185
|
className: classes.tickContainer,
|
package/Gauge/Gauge.d.ts
CHANGED
|
@@ -6,8 +6,5 @@ export interface GaugeProps extends GaugeContainerProps, Pick<GaugeValueTextProp
|
|
|
6
6
|
classes?: Partial<GaugeClasses>;
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
}
|
|
9
|
-
declare
|
|
10
|
-
declare namespace Gauge {
|
|
11
|
-
var propTypes: any;
|
|
12
|
-
}
|
|
9
|
+
declare const Gauge: React.ForwardRefExoticComponent<GaugeProps & React.RefAttributes<unknown>>;
|
|
13
10
|
export { Gauge };
|
package/Gauge/Gauge.js
CHANGED
|
@@ -4,19 +4,20 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.Gauge =
|
|
7
|
+
exports.Gauge = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
12
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
13
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
13
14
|
var _GaugeContainer = require("./GaugeContainer");
|
|
14
15
|
var _GaugeValueArc = require("./GaugeValueArc");
|
|
15
16
|
var _GaugeReferenceArc = require("./GaugeReferenceArc");
|
|
16
17
|
var _gaugeClasses = require("./gaugeClasses");
|
|
17
18
|
var _GaugeValueText = require("./GaugeValueText");
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
const _excluded = ["text", "children", "classes"];
|
|
20
|
+
const _excluded = ["text", "children", "classes", "className"];
|
|
20
21
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
22
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
23
|
const useUtilityClasses = props => {
|
|
@@ -31,15 +32,17 @@ const useUtilityClasses = props => {
|
|
|
31
32
|
};
|
|
32
33
|
return (0, _composeClasses.default)(slots, _gaugeClasses.getGaugeUtilityClass, classes);
|
|
33
34
|
};
|
|
34
|
-
function Gauge(props) {
|
|
35
|
+
const Gauge = exports.Gauge = /*#__PURE__*/React.forwardRef(function Gauge(props, ref) {
|
|
35
36
|
const {
|
|
36
37
|
text,
|
|
37
|
-
children
|
|
38
|
+
children,
|
|
39
|
+
className
|
|
38
40
|
} = props,
|
|
39
41
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
40
42
|
const classes = useUtilityClasses(props);
|
|
41
43
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_GaugeContainer.GaugeContainer, (0, _extends2.default)({}, other, {
|
|
42
|
-
className: classes.root,
|
|
44
|
+
className: (0, _clsx.default)(classes.root, className),
|
|
45
|
+
ref: ref,
|
|
43
46
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_GaugeReferenceArc.GaugeReferenceArc, {
|
|
44
47
|
className: classes.referenceArc
|
|
45
48
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_GaugeValueArc.GaugeValueArc, {
|
|
@@ -49,7 +52,7 @@ function Gauge(props) {
|
|
|
49
52
|
text: text
|
|
50
53
|
}), children]
|
|
51
54
|
}));
|
|
52
|
-
}
|
|
55
|
+
});
|
|
53
56
|
process.env.NODE_ENV !== "production" ? Gauge.propTypes = {
|
|
54
57
|
// ----------------------------- Warning --------------------------------
|
|
55
58
|
// | These PropTypes are generated from the TypeScript type definitions |
|