@mui/x-charts 7.9.0 → 7.11.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.js +2 -2
- package/BarChart/formatter.js +1 -1
- package/BarChart/useBarChartProps.js +38 -33
- package/CHANGELOG.md +159 -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/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/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
- package/ChartsSurface.js +3 -1
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +26 -18
- 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/AreaPlot.js +7 -1
- package/LineChart/LineChart.js +2 -2
- package/LineChart/LineHighlightPlot.js +8 -0
- package/LineChart/MarkElement.js +2 -2
- package/LineChart/MarkPlot.js +4 -20
- package/LineChart/extremums.js +1 -1
- package/LineChart/formatter.js +1 -1
- package/LineChart/useLineChartProps.js +38 -33
- 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 +6 -2
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +20 -0
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +73 -0
- package/ScatterChart/Scatter.js +6 -9
- package/ScatterChart/useScatterChartProps.js +35 -30
- package/SparkLineChart/SparkLineChart.js +27 -22
- 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 +1 -1
- package/context/DrawingProvider.d.ts +11 -0
- package/context/DrawingProvider.js +9 -2
- package/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/esm/BarChart/BarChart.js +2 -2
- package/esm/BarChart/formatter.js +1 -1
- 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/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/ChartsSurface.js +3 -1
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +26 -18
- 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 +7 -1
- package/esm/LineChart/LineChart.js +2 -2
- package/esm/LineChart/LineHighlightPlot.js +8 -0
- package/esm/LineChart/MarkElement.js +1 -1
- package/esm/LineChart/MarkPlot.js +3 -19
- package/esm/LineChart/extremums.js +1 -1
- package/esm/LineChart/formatter.js +1 -1
- package/esm/LineChart/useLineChartProps.js +38 -33
- 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 +6 -2
- package/esm/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
- package/esm/ScatterChart/Scatter.js +6 -9
- 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 +1 -1
- package/esm/context/DrawingProvider.js +9 -2
- package/esm/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/esm/hooks/useAxisEvents.js +3 -10
- package/esm/hooks/useDrawingArea.js +5 -3
- package/esm/hooks/useReducedMotion.js +4 -2
- package/esm/internals/cleanId.js +6 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- 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/hooks/useAxisEvents.js +3 -10
- package/hooks/useDrawingArea.js +5 -3
- package/hooks/useReducedMotion.js +4 -2
- package/index.js +1 -1
- 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/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/models/axis.d.ts +5 -2
- package/models/helpers.d.ts +1 -0
- package/models/seriesType/config.d.ts +2 -16
- package/modern/BarChart/BarChart.js +2 -2
- package/modern/BarChart/formatter.js +1 -1
- 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/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/ChartsSurface.js +3 -1
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +26 -18
- 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 +7 -1
- package/modern/LineChart/LineChart.js +2 -2
- package/modern/LineChart/LineHighlightPlot.js +8 -0
- package/modern/LineChart/MarkElement.js +1 -1
- package/modern/LineChart/MarkPlot.js +3 -19
- package/modern/LineChart/extremums.js +1 -1
- package/modern/LineChart/formatter.js +1 -1
- package/modern/LineChart/useLineChartProps.js +38 -33
- 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 +6 -2
- package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
- package/modern/ScatterChart/Scatter.js +6 -9
- 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 +1 -1
- package/modern/context/DrawingProvider.js +9 -2
- package/modern/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/modern/hooks/useAxisEvents.js +3 -10
- package/modern/hooks/useDrawingArea.js +5 -3
- package/modern/hooks/useReducedMotion.js +4 -2
- package/modern/index.js +1 -1
- package/modern/internals/cleanId.js +6 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- 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/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[];
|
|
@@ -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 {
|
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
|
|
@@ -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
|
|
@@ -86,7 +82,20 @@ function ChartsVoronoiHandler(props) {
|
|
|
86
82
|
const seriesPoints = data.flatMap(({
|
|
87
83
|
x,
|
|
88
84
|
y
|
|
89
|
-
}) =>
|
|
85
|
+
}) => {
|
|
86
|
+
const pointX = getXPosition(x);
|
|
87
|
+
const pointY = getYPosition(y);
|
|
88
|
+
if (!drawingArea.isPointInside({
|
|
89
|
+
x: pointX,
|
|
90
|
+
y: pointY
|
|
91
|
+
})) {
|
|
92
|
+
// If the point is not displayed we move them to a trash coordinate.
|
|
93
|
+
// This avoids managing index mapping before/after filtering.
|
|
94
|
+
// The trash point is far enough such that any point in the drawing area will be closer to the mouse than the trash coordinate.
|
|
95
|
+
return [-drawingArea.width, -drawingArea.height];
|
|
96
|
+
}
|
|
97
|
+
return [pointX, pointY];
|
|
98
|
+
});
|
|
90
99
|
voronoiRef.current[seriesId] = {
|
|
91
100
|
seriesId,
|
|
92
101
|
startIndex: points.length,
|
|
@@ -95,29 +104,28 @@ function ChartsVoronoiHandler(props) {
|
|
|
95
104
|
points = points.concat(seriesPoints);
|
|
96
105
|
});
|
|
97
106
|
delauneyRef.current = new _d3Delaunay.Delaunay(points);
|
|
98
|
-
|
|
107
|
+
lastFind.current = undefined;
|
|
108
|
+
}, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis, drawingArea]);
|
|
99
109
|
React.useEffect(() => {
|
|
100
110
|
const element = svgRef.current;
|
|
101
111
|
if (element === null) {
|
|
102
112
|
return undefined;
|
|
103
113
|
}
|
|
104
|
-
|
|
105
|
-
// TODO: A perf optimisation of voronoi could be to use the last point as the initial point for the next search.
|
|
106
114
|
function getClosestPoint(event) {
|
|
107
115
|
// Get mouse coordinate in global SVG space
|
|
108
116
|
const svgPoint = (0, _getSVGPoint.getSVGPoint)(element, event);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (outsideX || outsideY) {
|
|
117
|
+
if (!drawingArea.isPointInside(svgPoint)) {
|
|
118
|
+
lastFind.current = undefined;
|
|
112
119
|
return 'outside-chart';
|
|
113
120
|
}
|
|
114
121
|
if (!delauneyRef.current) {
|
|
115
122
|
return 'no-point-found';
|
|
116
123
|
}
|
|
117
|
-
const closestPointIndex = delauneyRef.current.find(svgPoint.x, svgPoint.y);
|
|
124
|
+
const closestPointIndex = delauneyRef.current.find(svgPoint.x, svgPoint.y, lastFind.current);
|
|
118
125
|
if (closestPointIndex === undefined) {
|
|
119
126
|
return 'no-point-found';
|
|
120
127
|
}
|
|
128
|
+
lastFind.current = closestPointIndex;
|
|
121
129
|
const closestSeries = Object.values(voronoiRef.current).find(value => {
|
|
122
130
|
return 2 * closestPointIndex >= value.startIndex && 2 * closestPointIndex < value.endIndex;
|
|
123
131
|
});
|
|
@@ -139,7 +147,7 @@ function ChartsVoronoiHandler(props) {
|
|
|
139
147
|
dataIndex
|
|
140
148
|
};
|
|
141
149
|
}
|
|
142
|
-
const
|
|
150
|
+
const handleMouseLeave = () => {
|
|
143
151
|
dispatch({
|
|
144
152
|
type: 'exitChart'
|
|
145
153
|
});
|
|
@@ -200,15 +208,15 @@ function ChartsVoronoiHandler(props) {
|
|
|
200
208
|
dataIndex
|
|
201
209
|
});
|
|
202
210
|
};
|
|
203
|
-
element.addEventListener('
|
|
211
|
+
element.addEventListener('pointerleave', handleMouseLeave);
|
|
204
212
|
element.addEventListener('pointermove', handleMouseMove);
|
|
205
213
|
element.addEventListener('click', handleMouseClick);
|
|
206
214
|
return () => {
|
|
207
|
-
element.removeEventListener('
|
|
215
|
+
element.removeEventListener('pointerleave', handleMouseLeave);
|
|
208
216
|
element.removeEventListener('pointermove', handleMouseMove);
|
|
209
217
|
element.removeEventListener('click', handleMouseClick);
|
|
210
218
|
};
|
|
211
|
-
}, [svgRef, dispatch,
|
|
219
|
+
}, [svgRef, dispatch, yAxis, xAxis, voronoiMaxRadius, onItemClick, setHighlighted, clearHighlighted, drawingArea]);
|
|
212
220
|
|
|
213
221
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
214
222
|
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 |
|
package/Gauge/GaugeContainer.js
CHANGED
|
@@ -9,8 +9,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
|
-
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
13
12
|
var _styles = require("@mui/material/styles");
|
|
13
|
+
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
14
14
|
var _useChartContainerDimensions = require("../ResponsiveChartContainer/useChartContainerDimensions");
|
|
15
15
|
var _ChartsSurface = require("../ChartsSurface");
|
|
16
16
|
var _DrawingProvider = require("../context/DrawingProvider");
|
|
@@ -63,9 +63,13 @@ const GaugeContainer = exports.GaugeContainer = /*#__PURE__*/React.forwardRef(fu
|
|
|
63
63
|
children
|
|
64
64
|
} = props,
|
|
65
65
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
66
|
-
const
|
|
66
|
+
const {
|
|
67
|
+
containerRef,
|
|
68
|
+
width,
|
|
69
|
+
height
|
|
70
|
+
} = (0, _useChartContainerDimensions.useChartContainerDimensions)(inWidth, inHeight);
|
|
67
71
|
const svgRef = React.useRef(null);
|
|
68
|
-
const
|
|
72
|
+
const chartSurfaceRef = (0, _useForkRef.default)(ref, svgRef);
|
|
69
73
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ResizableContainer, (0, _extends2.default)({
|
|
70
74
|
ref: containerRef,
|
|
71
75
|
ownerState: {
|
|
@@ -101,7 +105,7 @@ const GaugeContainer = exports.GaugeContainer = /*#__PURE__*/React.forwardRef(fu
|
|
|
101
105
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsSurface.ChartsSurface, {
|
|
102
106
|
width: width,
|
|
103
107
|
height: height,
|
|
104
|
-
ref:
|
|
108
|
+
ref: chartSurfaceRef,
|
|
105
109
|
title: title,
|
|
106
110
|
desc: desc,
|
|
107
111
|
disableAxisListener: true,
|
package/Gauge/GaugeProvider.js
CHANGED
|
@@ -7,8 +7,8 @@ exports.GaugeContext = void 0;
|
|
|
7
7
|
exports.GaugeProvider = GaugeProvider;
|
|
8
8
|
exports.useGaugeState = useGaugeState;
|
|
9
9
|
var React = _interopRequireWildcard(require("react"));
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var _getPercentageValue = require("../internals/getPercentageValue");
|
|
11
|
+
var _utils = require("./utils");
|
|
12
12
|
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
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); }
|
|
@@ -52,12 +52,12 @@ function GaugeProvider(props) {
|
|
|
52
52
|
width,
|
|
53
53
|
height
|
|
54
54
|
} = (0, _useDrawingArea.useDrawingArea)();
|
|
55
|
-
const ratios = (0,
|
|
56
|
-
const innerCx = cxParam ? (0,
|
|
57
|
-
const innerCy = cyParam ? (0,
|
|
55
|
+
const ratios = (0, _utils.getArcRatios)(startAngle, endAngle);
|
|
56
|
+
const innerCx = cxParam ? (0, _getPercentageValue.getPercentageValue)(cxParam, width) : ratios.cx * width;
|
|
57
|
+
const innerCy = cyParam ? (0, _getPercentageValue.getPercentageValue)(cyParam, height) : ratios.cy * height;
|
|
58
58
|
let cx = left + innerCx;
|
|
59
59
|
let cy = top + innerCy;
|
|
60
|
-
const maxRadius = (0,
|
|
60
|
+
const maxRadius = (0, _utils.getAvailableRadius)(innerCx, innerCy, width, height, ratios);
|
|
61
61
|
|
|
62
62
|
// If the center is not defined, after computation of the available radius, update the center to use the remaining space.
|
|
63
63
|
if (cxParam === undefined) {
|
|
@@ -68,9 +68,9 @@ function GaugeProvider(props) {
|
|
|
68
68
|
const usedHeight = maxRadius * (ratios.maxY - ratios.minY);
|
|
69
69
|
cy = top + (height - usedHeight) / 2 + ratios.cy * usedHeight;
|
|
70
70
|
}
|
|
71
|
-
const outerRadius = (0,
|
|
72
|
-
const innerRadius = (0,
|
|
73
|
-
const cornerRadius = (0,
|
|
71
|
+
const outerRadius = (0, _getPercentageValue.getPercentageValue)(outerRadiusParam ?? maxRadius, maxRadius);
|
|
72
|
+
const innerRadius = (0, _getPercentageValue.getPercentageValue)(innerRadiusParam ?? '80%', maxRadius);
|
|
73
|
+
const cornerRadius = (0, _getPercentageValue.getPercentageValue)(cornerRadiusParam ?? 0, outerRadius - innerRadius);
|
|
74
74
|
const contextValue = React.useMemo(() => {
|
|
75
75
|
const startAngleRad = Math.PI * startAngle / 180;
|
|
76
76
|
const endAngleRad = Math.PI * endAngle / 180;
|
|
@@ -14,7 +14,7 @@ var _styles = require("@mui/material/styles");
|
|
|
14
14
|
var _d3Color = require("d3-color");
|
|
15
15
|
var _web = require("@react-spring/web");
|
|
16
16
|
var _useAnimatedPath = require("../internals/useAnimatedPath");
|
|
17
|
-
var
|
|
17
|
+
var _cleanId = require("../internals/cleanId");
|
|
18
18
|
var _hooks = require("../hooks");
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
20
|
const _excluded = ["d", "skipAnimation", "ownerState"];
|
|
@@ -71,7 +71,7 @@ function AnimatedArea(props) {
|
|
|
71
71
|
reset: false,
|
|
72
72
|
immediate: skipAnimation
|
|
73
73
|
});
|
|
74
|
-
const clipId = (0,
|
|
74
|
+
const clipId = (0, _cleanId.cleanId)(`${chartId}-${ownerState.id}-area-clip`);
|
|
75
75
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
76
76
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("clipPath", {
|
|
77
77
|
id: clipId,
|
|
@@ -14,7 +14,7 @@ var _web = require("@react-spring/web");
|
|
|
14
14
|
var _d3Color = require("d3-color");
|
|
15
15
|
var _styles = require("@mui/material/styles");
|
|
16
16
|
var _useAnimatedPath = require("../internals/useAnimatedPath");
|
|
17
|
-
var
|
|
17
|
+
var _cleanId = require("../internals/cleanId");
|
|
18
18
|
var _useChartId = require("../hooks/useChartId");
|
|
19
19
|
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
20
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -74,7 +74,7 @@ function AnimatedLine(props) {
|
|
|
74
74
|
reset: false,
|
|
75
75
|
immediate: skipAnimation
|
|
76
76
|
});
|
|
77
|
-
const clipId = (0,
|
|
77
|
+
const clipId = (0, _cleanId.cleanId)(`${chartId}-${ownerState.id}-line-clip`);
|
|
78
78
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(React.Fragment, {
|
|
79
79
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("clipPath", {
|
|
80
80
|
id: clipId,
|
package/LineChart/AreaPlot.js
CHANGED
|
@@ -63,7 +63,13 @@ const useAggregatedData = () => {
|
|
|
63
63
|
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).`);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
const areaPath = (0, _d3Shape.area)().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d =>
|
|
66
|
+
const areaPath = (0, _d3Shape.area)().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => {
|
|
67
|
+
const value = d.y && yScale(d.y[0]);
|
|
68
|
+
if (Number.isNaN(value)) {
|
|
69
|
+
return yScale.range()[0];
|
|
70
|
+
}
|
|
71
|
+
return value;
|
|
72
|
+
}).y1(d => d.y && yScale(d.y[1]));
|
|
67
73
|
const curve = (0, _getCurve.default)(series[seriesId].curve);
|
|
68
74
|
const formattedData = xData?.map((x, index) => ({
|
|
69
75
|
x,
|