@mui/x-charts 6.0.0-alpha.9 → 6.18.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.d.ts +26 -5
- package/BarChart/BarChart.js +93 -17
- package/BarChart/BarElement.d.ts +1319 -4
- package/BarChart/BarElement.js +10 -10
- package/BarChart/BarPlot.d.ts +17 -1
- package/BarChart/BarPlot.js +152 -66
- package/BarChart/formatter.js +2 -3
- package/BarChart/legend.js +1 -2
- package/CHANGELOG.md +797 -59
- package/ChartContainer/index.js +7 -5
- package/ChartsAxis/ChartsAxis.d.ts +9 -0
- package/ChartsAxis/ChartsAxis.js +33 -7
- package/ChartsAxis/axisClasses.d.ts +3 -3
- package/ChartsAxis/axisClasses.js +1 -2
- package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +21 -0
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +61 -22
- package/ChartsClipPath/ChartsClipPath.d.ts +5 -0
- package/ChartsClipPath/ChartsClipPath.js +7 -2
- package/ChartsLegend/ChartsLegend.d.ts +45 -24
- package/ChartsLegend/ChartsLegend.js +193 -151
- package/ChartsLegend/chartsLegendClasses.d.ts +1 -1
- package/ChartsLegend/chartsLegendClasses.js +3 -4
- package/ChartsLegend/utils.d.ts +1 -6
- package/ChartsReferenceLine/ChartsReferenceLine.d.ts +10 -0
- package/ChartsReferenceLine/ChartsReferenceLine.js +78 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.d.ts +13 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.js +112 -0
- package/ChartsReferenceLine/ChartsYReferenceLine.d.ts +13 -0
- package/ChartsReferenceLine/ChartsYReferenceLine.js +112 -0
- package/ChartsReferenceLine/chartsReferenceLineClasses.d.ts +15 -0
- package/ChartsReferenceLine/chartsReferenceLineClasses.js +14 -0
- package/ChartsReferenceLine/common.d.ts +41 -0
- package/ChartsReferenceLine/common.js +27 -0
- package/ChartsReferenceLine/index.d.ts +2 -0
- package/ChartsReferenceLine/index.js +27 -0
- package/ChartsReferenceLine/package.json +6 -0
- package/ChartsSurface.d.ts +12 -1
- package/ChartsSurface.js +9 -18
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +1 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.js +46 -32
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +3 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +18 -9
- package/ChartsTooltip/ChartsTooltip.d.ts +32 -0
- package/ChartsTooltip/ChartsTooltip.js +62 -18
- package/ChartsTooltip/ChartsTooltipTable.d.ts +3 -10
- package/ChartsTooltip/ChartsTooltipTable.js +22 -20
- package/ChartsTooltip/tooltipClasses.js +1 -2
- package/ChartsTooltip/utils.js +2 -2
- package/ChartsXAxis/ChartsXAxis.d.ts +9 -0
- package/ChartsXAxis/ChartsXAxis.js +170 -45
- package/ChartsYAxis/ChartsYAxis.d.ts +9 -0
- package/ChartsYAxis/ChartsYAxis.js +95 -38
- package/LineChart/AreaElement.d.ts +11 -1
- package/LineChart/AreaElement.js +14 -6
- package/LineChart/AreaPlot.d.ts +11 -0
- package/LineChart/AreaPlot.js +27 -8
- package/LineChart/LineChart.d.ts +23 -3
- package/LineChart/LineChart.js +89 -17
- package/LineChart/LineElement.d.ts +11 -1
- package/LineChart/LineElement.js +14 -6
- package/LineChart/LineHighlightElement.d.ts +10 -0
- package/LineChart/LineHighlightElement.js +13 -4
- package/LineChart/LineHighlightPlot.d.ts +10 -0
- package/LineChart/LineHighlightPlot.js +15 -4
- package/LineChart/LinePlot.d.ts +10 -0
- package/LineChart/LinePlot.js +25 -12
- package/LineChart/MarkElement.d.ts +10 -0
- package/LineChart/MarkElement.js +14 -5
- package/LineChart/MarkPlot.d.ts +10 -0
- package/LineChart/MarkPlot.js +42 -10
- package/LineChart/formatter.js +5 -5
- package/LineChart/legend.js +1 -2
- package/PieChart/PieArc.d.ts +11 -13
- package/PieChart/PieArc.js +28 -60
- package/PieChart/PieArcLabel.d.ts +8 -9
- package/PieChart/PieArcLabel.js +46 -38
- package/PieChart/PieArcLabelPlot.d.ts +28 -0
- package/PieChart/PieArcLabelPlot.js +99 -0
- package/PieChart/PieArcPlot.d.ts +35 -0
- package/PieChart/PieArcPlot.js +92 -0
- package/PieChart/PieChart.d.ts +19 -5
- package/PieChart/PieChart.js +95 -18
- package/PieChart/PiePlot.d.ts +15 -9
- package/PieChart/PiePlot.js +77 -55
- package/PieChart/dataTransform/transition.d.ts +4 -0
- package/PieChart/dataTransform/transition.js +136 -0
- package/PieChart/dataTransform/useTransformData.d.ts +15 -0
- package/PieChart/dataTransform/useTransformData.js +67 -0
- package/PieChart/formatter.js +1 -2
- package/PieChart/legend.js +1 -2
- package/README.md +8 -14
- package/ResponsiveChartContainer/index.d.ts +13 -3
- package/ResponsiveChartContainer/index.js +7 -8
- package/ScatterChart/Scatter.d.ts +10 -0
- package/ScatterChart/Scatter.js +12 -2
- package/ScatterChart/ScatterChart.d.ts +16 -3
- package/ScatterChart/ScatterChart.js +77 -16
- package/ScatterChart/ScatterPlot.d.ts +10 -0
- package/ScatterChart/ScatterPlot.js +12 -2
- package/ScatterChart/formatter.js +1 -2
- package/ScatterChart/legend.js +1 -2
- package/SparkLineChart/SparkLineChart.d.ts +12 -3
- package/SparkLineChart/SparkLineChart.js +50 -7
- package/colorPalettes/colorPalettes.js +6 -12
- package/constants.js +5 -8
- package/context/CartesianContextProvider.d.ts +26 -1
- package/context/CartesianContextProvider.js +42 -16
- package/context/DrawingProvider.d.ts +25 -0
- package/context/DrawingProvider.js +18 -6
- package/context/HighlightProvider.d.ts +17 -0
- package/context/HighlightProvider.js +3 -4
- package/context/InteractionProvider.d.ts +6 -0
- package/context/InteractionProvider.js +3 -4
- package/context/SeriesContextProvider.d.ts +5 -0
- package/context/SeriesContextProvider.js +3 -4
- package/esm/BarChart/BarChart.js +90 -13
- package/esm/BarChart/BarElement.js +7 -4
- package/esm/BarChart/BarPlot.js +152 -67
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartContainer/index.js +3 -0
- package/esm/ChartsAxis/ChartsAxis.js +32 -5
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
- package/esm/ChartsClipPath/ChartsClipPath.js +5 -0
- package/esm/ChartsLegend/ChartsLegend.js +190 -144
- package/esm/ChartsLegend/chartsLegendClasses.js +1 -1
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
- package/esm/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
- package/esm/ChartsReferenceLine/common.js +20 -0
- package/esm/ChartsReferenceLine/index.js +2 -0
- package/esm/ChartsSurface.js +4 -12
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/esm/ChartsTooltip/ChartsTooltip.js +59 -14
- package/esm/ChartsTooltip/ChartsTooltipTable.js +17 -10
- package/esm/ChartsXAxis/ChartsXAxis.js +168 -43
- package/esm/ChartsYAxis/ChartsYAxis.js +93 -36
- package/esm/LineChart/AreaElement.js +10 -0
- package/esm/LineChart/AreaPlot.js +26 -6
- package/esm/LineChart/LineChart.js +86 -13
- package/esm/LineChart/LineElement.js +10 -0
- package/esm/LineChart/LineHighlightElement.js +10 -0
- package/esm/LineChart/LineHighlightPlot.js +13 -2
- package/esm/LineChart/LinePlot.js +25 -14
- package/esm/LineChart/MarkElement.js +11 -1
- package/esm/LineChart/MarkPlot.js +40 -8
- package/esm/LineChart/formatter.js +7 -3
- package/esm/PieChart/PieArc.js +26 -58
- package/esm/PieChart/PieArcLabel.js +43 -34
- package/esm/PieChart/PieArcLabelPlot.js +92 -0
- package/esm/PieChart/PieArcPlot.js +84 -0
- package/esm/PieChart/PieChart.js +93 -16
- package/esm/PieChart/PiePlot.js +76 -57
- package/esm/PieChart/dataTransform/transition.js +130 -0
- package/esm/PieChart/dataTransform/useTransformData.js +59 -0
- package/esm/ResponsiveChartContainer/index.js +3 -3
- package/esm/ScatterChart/Scatter.js +10 -0
- package/esm/ScatterChart/ScatterChart.js +74 -12
- package/esm/ScatterChart/ScatterPlot.js +10 -0
- package/esm/SparkLineChart/SparkLineChart.js +47 -3
- package/esm/constants.js +1 -1
- package/esm/context/CartesianContextProvider.js +41 -14
- package/esm/context/DrawingProvider.js +14 -0
- package/esm/hooks/useChartDimensions.js +2 -0
- package/esm/hooks/useMounted.js +16 -0
- package/esm/hooks/useReducedMotion.js +27 -0
- package/esm/hooks/useTicks.js +15 -9
- package/esm/index.js +1 -0
- package/esm/internals/components/AxisSharedComponents.js +15 -70
- package/esm/internals/components/ChartsText.js +77 -0
- package/esm/internals/domUtils.js +113 -0
- package/esm/internals/geometry.js +36 -0
- package/hooks/useAxisEvents.js +2 -2
- package/hooks/useChartDimensions.d.ts +2 -0
- package/hooks/useChartDimensions.js +5 -4
- package/hooks/useDrawingArea.js +2 -2
- package/hooks/useInteractionItemProps.js +2 -2
- package/hooks/useMounted.d.ts +1 -0
- package/hooks/useMounted.js +25 -0
- package/hooks/useReducedMotion.d.ts +8 -0
- package/hooks/useReducedMotion.js +33 -0
- package/hooks/useScale.d.ts +2 -2
- package/hooks/useScale.js +2 -2
- package/hooks/useTicks.d.ts +19 -11
- package/hooks/useTicks.js +19 -14
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/components/AxisSharedComponents.d.ts +0 -4
- package/internals/components/AxisSharedComponents.js +18 -78
- package/internals/components/ChartsText.d.ts +35 -0
- package/internals/components/ChartsText.js +87 -0
- package/internals/defaultizeColor.d.ts +7 -2
- package/internals/defaultizeValueFormatter.js +1 -2
- package/internals/domUtils.d.ts +13 -0
- package/internals/domUtils.js +122 -0
- package/internals/geometry.d.ts +9 -0
- package/internals/geometry.js +42 -0
- package/internals/isBandScale.d.ts +3 -1
- package/internals/stackSeries.js +2 -4
- package/internals/utils.d.ts +5 -0
- package/legacy/BarChart/BarChart.js +90 -13
- package/legacy/BarChart/BarElement.js +6 -3
- package/legacy/BarChart/BarPlot.js +151 -63
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartContainer/index.js +3 -0
- package/legacy/ChartsAxis/ChartsAxis.js +32 -5
- package/legacy/ChartsAxisHighlight/ChartsAxisHighlight.js +60 -20
- package/legacy/ChartsClipPath/ChartsClipPath.js +5 -0
- package/legacy/ChartsLegend/ChartsLegend.js +205 -142
- package/legacy/ChartsLegend/chartsLegendClasses.js +1 -1
- package/legacy/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
- package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +105 -0
- package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +105 -0
- package/legacy/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
- package/legacy/ChartsReferenceLine/common.js +20 -0
- package/legacy/ChartsReferenceLine/index.js +2 -0
- package/legacy/ChartsSurface.js +3 -12
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +22 -10
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/legacy/ChartsTooltip/ChartsTooltip.js +62 -14
- package/legacy/ChartsTooltip/ChartsTooltipTable.js +34 -26
- package/legacy/ChartsXAxis/ChartsXAxis.js +176 -50
- package/legacy/ChartsYAxis/ChartsYAxis.js +97 -41
- package/legacy/LineChart/AreaElement.js +10 -0
- package/legacy/LineChart/AreaPlot.js +31 -7
- package/legacy/LineChart/LineChart.js +86 -13
- package/legacy/LineChart/LineElement.js +10 -0
- package/legacy/LineChart/LineHighlightElement.js +10 -0
- package/legacy/LineChart/LineHighlightPlot.js +13 -2
- package/legacy/LineChart/LinePlot.js +29 -12
- package/legacy/LineChart/MarkElement.js +11 -1
- package/legacy/LineChart/MarkPlot.js +39 -8
- package/legacy/LineChart/formatter.js +7 -3
- package/legacy/PieChart/PieArc.js +30 -62
- package/legacy/PieChart/PieArcLabel.js +48 -34
- package/legacy/PieChart/PieArcLabelPlot.js +93 -0
- package/legacy/PieChart/PieArcPlot.js +84 -0
- package/legacy/PieChart/PieChart.js +93 -16
- package/legacy/PieChart/PiePlot.js +76 -59
- package/legacy/PieChart/dataTransform/transition.js +142 -0
- package/legacy/PieChart/dataTransform/useTransformData.js +60 -0
- package/legacy/ResponsiveChartContainer/index.js +3 -3
- package/legacy/ScatterChart/Scatter.js +10 -0
- package/legacy/ScatterChart/ScatterChart.js +74 -12
- package/legacy/ScatterChart/ScatterPlot.js +10 -0
- package/legacy/SparkLineChart/SparkLineChart.js +47 -3
- package/legacy/constants.js +1 -1
- package/legacy/context/CartesianContextProvider.js +41 -14
- package/legacy/context/DrawingProvider.js +14 -0
- package/legacy/hooks/useChartDimensions.js +2 -0
- package/legacy/hooks/useMounted.js +21 -0
- package/legacy/hooks/useReducedMotion.js +27 -0
- package/legacy/hooks/useTicks.js +16 -9
- package/legacy/index.js +2 -1
- package/legacy/internals/components/AxisSharedComponents.js +11 -65
- package/legacy/internals/components/ChartsText.js +79 -0
- package/legacy/internals/domUtils.js +121 -0
- package/legacy/internals/geometry.js +37 -0
- package/models/axis.d.ts +58 -20
- package/models/layout.d.ts +13 -6
- package/models/seriesType/common.d.ts +16 -0
- package/models/seriesType/line.d.ts +8 -3
- package/models/seriesType/pie.d.ts +5 -1
- package/modern/BarChart/BarChart.js +90 -13
- package/modern/BarChart/BarElement.js +7 -4
- package/modern/BarChart/BarPlot.js +149 -65
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartContainer/index.js +3 -0
- package/modern/ChartsAxis/ChartsAxis.js +31 -5
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +57 -20
- package/modern/ChartsClipPath/ChartsClipPath.js +5 -0
- package/modern/ChartsLegend/ChartsLegend.js +190 -144
- package/modern/ChartsLegend/chartsLegendClasses.js +1 -1
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +70 -0
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +104 -0
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +104 -0
- package/modern/ChartsReferenceLine/chartsReferenceLineClasses.js +6 -0
- package/modern/ChartsReferenceLine/common.js +20 -0
- package/modern/ChartsReferenceLine/index.js +2 -0
- package/modern/ChartsSurface.js +4 -12
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +44 -30
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +15 -7
- package/modern/ChartsTooltip/ChartsTooltip.js +58 -14
- package/modern/ChartsTooltip/ChartsTooltipTable.js +17 -10
- package/modern/ChartsXAxis/ChartsXAxis.js +167 -42
- package/modern/ChartsYAxis/ChartsYAxis.js +92 -35
- package/modern/LineChart/AreaElement.js +10 -0
- package/modern/LineChart/AreaPlot.js +25 -6
- package/modern/LineChart/LineChart.js +86 -13
- package/modern/LineChart/LineElement.js +10 -0
- package/modern/LineChart/LineHighlightElement.js +10 -0
- package/modern/LineChart/LineHighlightPlot.js +13 -2
- package/modern/LineChart/LinePlot.js +23 -10
- package/modern/LineChart/MarkElement.js +11 -1
- package/modern/LineChart/MarkPlot.js +40 -8
- package/modern/LineChart/formatter.js +4 -3
- package/modern/PieChart/PieArc.js +26 -57
- package/modern/PieChart/PieArcLabel.js +43 -34
- package/modern/PieChart/PieArcLabelPlot.js +90 -0
- package/modern/PieChart/PieArcPlot.js +83 -0
- package/modern/PieChart/PieChart.js +93 -16
- package/modern/PieChart/PiePlot.js +76 -55
- package/modern/PieChart/dataTransform/transition.js +130 -0
- package/modern/PieChart/dataTransform/useTransformData.js +58 -0
- package/modern/ResponsiveChartContainer/index.js +3 -3
- package/modern/ScatterChart/Scatter.js +10 -0
- package/modern/ScatterChart/ScatterChart.js +74 -12
- package/modern/ScatterChart/ScatterPlot.js +10 -0
- package/modern/SparkLineChart/SparkLineChart.js +47 -3
- package/modern/constants.js +1 -1
- package/modern/context/CartesianContextProvider.js +40 -13
- package/modern/context/DrawingProvider.js +14 -0
- package/modern/hooks/useChartDimensions.js +2 -0
- package/modern/hooks/useMounted.js +16 -0
- package/modern/hooks/useReducedMotion.js +27 -0
- package/modern/hooks/useTicks.js +15 -9
- package/modern/index.js +2 -1
- package/modern/internals/components/AxisSharedComponents.js +15 -70
- package/modern/internals/components/ChartsText.js +77 -0
- package/modern/internals/domUtils.js +113 -0
- package/modern/internals/geometry.js +36 -0
- package/package.json +9 -6
- package/themeAugmentation/components.d.ts +1 -0
- package/themeAugmentation/overrides.d.ts +2 -0
|
@@ -5,19 +5,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.ChartsLegend = ChartsLegend;
|
|
8
|
-
exports.
|
|
8
|
+
exports.ChartsLegendRoot = void 0;
|
|
9
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
11
|
var React = _interopRequireWildcard(require("react"));
|
|
11
12
|
var _utils = require("@mui/base/utils");
|
|
13
|
+
var _NoSsr = require("@mui/base/NoSsr");
|
|
12
14
|
var _utils2 = require("@mui/utils");
|
|
13
15
|
var _styles = require("@mui/material/styles");
|
|
14
16
|
var _DrawingProvider = require("../context/DrawingProvider");
|
|
15
17
|
var _utils3 = require("./utils");
|
|
16
18
|
var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
17
19
|
var _chartsLegendClasses = require("./chartsLegendClasses");
|
|
20
|
+
var _ChartsText = require("../internals/components/ChartsText");
|
|
18
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
const _excluded = ["rotate", "dominantBaseline"],
|
|
23
|
+
_excluded2 = ["label"];
|
|
24
|
+
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); }
|
|
25
|
+
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 && Object.prototype.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; }
|
|
21
26
|
const useUtilityClasses = ownerState => {
|
|
22
27
|
const {
|
|
23
28
|
classes,
|
|
@@ -29,173 +34,212 @@ const useUtilityClasses = ownerState => {
|
|
|
29
34
|
label: ['label'],
|
|
30
35
|
series: ['series']
|
|
31
36
|
};
|
|
32
|
-
return (0, _utils2.unstable_composeClasses)(slots, _chartsLegendClasses.
|
|
37
|
+
return (0, _utils2.unstable_composeClasses)(slots, _chartsLegendClasses.getLegendUtilityClass, classes);
|
|
33
38
|
};
|
|
34
|
-
|
|
35
|
-
position,
|
|
36
|
-
drawingArea
|
|
37
|
-
}) {
|
|
38
|
-
let xValue;
|
|
39
|
-
switch (position.horizontal) {
|
|
40
|
-
case 'left':
|
|
41
|
-
xValue = `calc(var(--ChartsLegend-rootOffsetX, 0px) + ${drawingArea.left}px - var(--ChartsLegend-rootWidth))`;
|
|
42
|
-
break;
|
|
43
|
-
case 'middle':
|
|
44
|
-
xValue = `calc(var(--ChartsLegend-rootOffsetX, 0px) + ${drawingArea.left + drawingArea.width / 2}px - 0.5 * var(--ChartsLegend-rootWidth))`;
|
|
45
|
-
break;
|
|
46
|
-
default:
|
|
47
|
-
xValue = `calc(var(--ChartsLegend-rootOffsetX, 0px) + ${drawingArea.left + drawingArea.width}px)`;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
let yValue;
|
|
51
|
-
switch (position.vertical) {
|
|
52
|
-
case 'top':
|
|
53
|
-
yValue = `calc(var(--ChartsLegend-rootOffsetY, 0px) + ${drawingArea.top}px - var(--ChartsLegend-rootHeight))`;
|
|
54
|
-
break;
|
|
55
|
-
case 'middle':
|
|
56
|
-
yValue = `calc(var(--ChartsLegend-rootOffsetY, 0px) + ${drawingArea.top + drawingArea.height / 2}px - 0.5 * var(--ChartsLegend-rootHeight))`;
|
|
57
|
-
break;
|
|
58
|
-
default:
|
|
59
|
-
yValue = `calc(var(--ChartsLegend-rootOffsetY, 0px) + ${drawingArea.top + drawingArea.height}px)`;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
transform: `translate(${xValue}, ${yValue})`
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
const ChartsLegendRoot = (0, _styles.styled)('g', {
|
|
39
|
+
const ChartsLegendRoot = exports.ChartsLegendRoot = (0, _styles.styled)('g', {
|
|
67
40
|
name: 'MuiChartsLegend',
|
|
68
41
|
slot: 'Root',
|
|
69
42
|
overridesResolver: (props, styles) => styles.root
|
|
70
|
-
})(
|
|
71
|
-
ownerState
|
|
72
|
-
}) => {
|
|
73
|
-
const {
|
|
74
|
-
direction,
|
|
75
|
-
drawingArea,
|
|
76
|
-
offsetX,
|
|
77
|
-
offsetY,
|
|
78
|
-
seriesNumber,
|
|
79
|
-
position
|
|
80
|
-
} = ownerState;
|
|
81
|
-
return (0, _extends2.default)({
|
|
82
|
-
'--ChartsLegend-rootOffsetX': typeof offsetX === 'number' ? `${offsetX}px` : undefined,
|
|
83
|
-
'--ChartsLegend-rootOffsetY': typeof offsetY === 'number' ? `${offsetY}px` : undefined,
|
|
84
|
-
'--ChartsLegend-rootWidth': direction === 'row' ? `calc(var(--ChartsLegend-itemWidth) * ${seriesNumber} + var(--ChartsLegend-rootSpacing) * ${seriesNumber - 1} )` : 'var(--ChartsLegend-itemWidth)',
|
|
85
|
-
'--ChartsLegend-rootHeight': direction === 'row' ? 'var(--ChartsLegend-itemMarkSize)' : `calc(var(--ChartsLegend-itemMarkSize) * ${seriesNumber} + var(--ChartsLegend-rootSpacing) * ${seriesNumber - 1} )`
|
|
86
|
-
}, getTranslePosition({
|
|
87
|
-
position,
|
|
88
|
-
drawingArea,
|
|
89
|
-
offsetX,
|
|
90
|
-
offsetY
|
|
91
|
-
}));
|
|
92
|
-
});
|
|
93
|
-
exports.ChartsLegendRoot = ChartsLegendRoot;
|
|
94
|
-
const ChartsSeriesLegendGroup = (0, _styles.styled)('g', {
|
|
95
|
-
name: 'MuiChartsLegend',
|
|
96
|
-
slot: 'ChartsSeriesLegendGroup',
|
|
97
|
-
overridesResolver: (props, styles) => styles.series
|
|
98
|
-
})(({
|
|
99
|
-
ownerState
|
|
100
|
-
}) => {
|
|
101
|
-
const {
|
|
102
|
-
direction,
|
|
103
|
-
seriesIndex
|
|
104
|
-
} = ownerState;
|
|
105
|
-
if (direction === 'row') {
|
|
106
|
-
return {
|
|
107
|
-
transform: `translate(calc(${seriesIndex} * (var(--ChartsLegend-itemWidth) + var(--ChartsLegend-rootSpacing))), 0)`
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
transform: `translate(0, calc(${seriesIndex} * (var(--ChartsLegend-itemMarkSize) + var(--ChartsLegend-rootSpacing))))`
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
exports.ChartsSeriesLegendGroup = ChartsSeriesLegendGroup;
|
|
115
|
-
const ChartsLegendMark = (0, _styles.styled)('rect', {
|
|
116
|
-
name: 'MuiChartsLegend',
|
|
117
|
-
slot: 'Mark',
|
|
118
|
-
overridesResolver: (props, styles) => styles.mark
|
|
119
|
-
})(({
|
|
120
|
-
ownerState
|
|
121
|
-
}) => ({
|
|
122
|
-
x: 0,
|
|
123
|
-
y: 0,
|
|
124
|
-
width: 'var(--ChartsLegend-itemMarkSize)',
|
|
125
|
-
height: 'var(--ChartsLegend-itemMarkSize)',
|
|
126
|
-
fill: ownerState.color
|
|
127
|
-
}));
|
|
128
|
-
exports.ChartsLegendMark = ChartsLegendMark;
|
|
129
|
-
const ChartsLegendLabel = (0, _styles.styled)('text', {
|
|
130
|
-
name: 'MuiChartsLegend',
|
|
131
|
-
slot: 'Label',
|
|
132
|
-
overridesResolver: (props, styles) => styles.label
|
|
133
|
-
})(({
|
|
134
|
-
theme
|
|
135
|
-
}) => (0, _extends2.default)({}, theme.typography.body1, {
|
|
136
|
-
color: 'inherit',
|
|
137
|
-
transform: `translate(
|
|
138
|
-
calc(var(--ChartsLegend-itemMarkSize) + var(--ChartsLegend-labelSpacing)),
|
|
139
|
-
calc(0.5 * var(--ChartsLegend-itemMarkSize))
|
|
140
|
-
)`,
|
|
141
|
-
fill: theme.palette.text.primary,
|
|
142
|
-
dominantBaseline: 'central'
|
|
143
|
-
}));
|
|
144
|
-
exports.ChartsLegendLabel = ChartsLegendLabel;
|
|
43
|
+
})({});
|
|
145
44
|
const defaultProps = {
|
|
146
45
|
position: {
|
|
147
46
|
horizontal: 'middle',
|
|
148
47
|
vertical: 'top'
|
|
149
48
|
},
|
|
150
|
-
direction: 'row'
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
49
|
+
direction: 'row'
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Transforms number or partial padding object to a defaultized padding object.
|
|
53
|
+
*/
|
|
54
|
+
const getStandardizedPadding = padding => {
|
|
55
|
+
if (typeof padding === 'number') {
|
|
56
|
+
return {
|
|
57
|
+
left: padding,
|
|
58
|
+
right: padding,
|
|
59
|
+
top: padding,
|
|
60
|
+
bottom: padding
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return (0, _extends2.default)({
|
|
64
|
+
left: 0,
|
|
65
|
+
right: 0,
|
|
66
|
+
top: 0,
|
|
67
|
+
bottom: 0
|
|
68
|
+
}, padding);
|
|
154
69
|
};
|
|
155
70
|
function DefaultChartsLegend(props) {
|
|
156
71
|
const {
|
|
157
72
|
hidden,
|
|
158
73
|
position,
|
|
159
74
|
direction,
|
|
160
|
-
offset,
|
|
161
|
-
series,
|
|
162
75
|
seriesToDisplay,
|
|
163
76
|
drawingArea,
|
|
164
|
-
classes
|
|
77
|
+
classes,
|
|
78
|
+
itemMarkWidth = 20,
|
|
79
|
+
itemMarkHeight = 20,
|
|
80
|
+
markGap = 5,
|
|
81
|
+
itemGap = 10,
|
|
82
|
+
padding: paddingProps = 10,
|
|
83
|
+
labelStyle: inLabelStyle
|
|
165
84
|
} = props;
|
|
85
|
+
const theme = (0, _styles.useTheme)();
|
|
86
|
+
const labelStyle = React.useMemo(() => (0, _extends2.default)({}, theme.typography.subtitle1, {
|
|
87
|
+
color: 'inherit',
|
|
88
|
+
dominantBaseline: 'central',
|
|
89
|
+
textAnchor: 'start',
|
|
90
|
+
fill: (theme.vars || theme).palette.text.primary,
|
|
91
|
+
lineHeight: 1
|
|
92
|
+
}, inLabelStyle),
|
|
93
|
+
// To say to TS that the dominantBaseline and textAnchor are correct
|
|
94
|
+
[inLabelStyle, theme]);
|
|
95
|
+
const padding = React.useMemo(() => getStandardizedPadding(paddingProps), [paddingProps]);
|
|
96
|
+
const getItemSpace = React.useCallback((label, inStyle = {}) => {
|
|
97
|
+
const style = (0, _objectWithoutPropertiesLoose2.default)(inStyle, _excluded);
|
|
98
|
+
const linesSize = (0, _ChartsText.getWordsByLines)({
|
|
99
|
+
style,
|
|
100
|
+
needsComputation: true,
|
|
101
|
+
text: label
|
|
102
|
+
});
|
|
103
|
+
const innerSize = {
|
|
104
|
+
innerWidth: itemMarkWidth + markGap + Math.max(...linesSize.map(size => size.width)),
|
|
105
|
+
innerHeight: Math.max(itemMarkHeight, linesSize.length * linesSize[0].height)
|
|
106
|
+
};
|
|
107
|
+
return (0, _extends2.default)({}, innerSize, {
|
|
108
|
+
outerWidth: innerSize.innerWidth + itemGap,
|
|
109
|
+
outerHeight: innerSize.innerHeight + itemGap
|
|
110
|
+
});
|
|
111
|
+
}, [itemGap, itemMarkHeight, itemMarkWidth, markGap]);
|
|
112
|
+
const totalWidth = drawingArea.left + drawingArea.width + drawingArea.right;
|
|
113
|
+
const totalHeight = drawingArea.top + drawingArea.height + drawingArea.bottom;
|
|
114
|
+
const availableWidth = totalWidth - padding.left - padding.right;
|
|
115
|
+
const availableHeight = totalHeight - padding.top - padding.bottom;
|
|
116
|
+
const seriesWithPosition = React.useMemo(() => {
|
|
117
|
+
// Start at 0, 0. Will be modified later by padding and position.
|
|
118
|
+
let x = 0;
|
|
119
|
+
let y = 0;
|
|
120
|
+
|
|
121
|
+
// total values used to align legend later.
|
|
122
|
+
let totalWidthUsed = 0;
|
|
123
|
+
let totalHeightUsed = 0;
|
|
124
|
+
let rowIndex = 0;
|
|
125
|
+
const rowMaxHeight = [0];
|
|
126
|
+
const seriesWithRawPosition = seriesToDisplay.map(_ref => {
|
|
127
|
+
let {
|
|
128
|
+
label
|
|
129
|
+
} = _ref,
|
|
130
|
+
other = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded2);
|
|
131
|
+
const itemSpace = getItemSpace(label, labelStyle);
|
|
132
|
+
const rep = (0, _extends2.default)({}, other, {
|
|
133
|
+
label,
|
|
134
|
+
positionX: x,
|
|
135
|
+
positionY: y,
|
|
136
|
+
innerHeight: itemSpace.innerHeight,
|
|
137
|
+
innerWidth: itemSpace.innerWidth,
|
|
138
|
+
outerHeight: itemSpace.outerHeight,
|
|
139
|
+
outerWidth: itemSpace.outerWidth,
|
|
140
|
+
rowIndex
|
|
141
|
+
});
|
|
142
|
+
if (direction === 'row') {
|
|
143
|
+
if (x + itemSpace.innerWidth > availableWidth) {
|
|
144
|
+
// This legend item would create overflow along the x-axis, so we start a new row.
|
|
145
|
+
x = 0;
|
|
146
|
+
y += rowMaxHeight[rowIndex];
|
|
147
|
+
rowIndex += 1;
|
|
148
|
+
if (rowMaxHeight.length <= rowIndex) {
|
|
149
|
+
rowMaxHeight.push(0);
|
|
150
|
+
}
|
|
151
|
+
rep.positionX = x;
|
|
152
|
+
rep.positionY = y;
|
|
153
|
+
rep.rowIndex = rowIndex;
|
|
154
|
+
}
|
|
155
|
+
totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
|
|
156
|
+
totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
|
|
157
|
+
rowMaxHeight[rowIndex] = Math.max(rowMaxHeight[rowIndex], itemSpace.outerHeight);
|
|
158
|
+
x += itemSpace.outerWidth;
|
|
159
|
+
}
|
|
160
|
+
if (direction === 'column') {
|
|
161
|
+
if (y + itemSpace.innerHeight > availableHeight) {
|
|
162
|
+
// This legend item would create overflow along the y-axis, so we start a new column.
|
|
163
|
+
x = totalWidthUsed + itemGap;
|
|
164
|
+
y = 0;
|
|
165
|
+
rowIndex = 0;
|
|
166
|
+
rep.positionX = x;
|
|
167
|
+
rep.positionY = y;
|
|
168
|
+
rep.rowIndex = rowIndex;
|
|
169
|
+
}
|
|
170
|
+
if (rowMaxHeight.length <= rowIndex) {
|
|
171
|
+
rowMaxHeight.push(0);
|
|
172
|
+
}
|
|
173
|
+
totalWidthUsed = Math.max(totalWidthUsed, x + itemSpace.outerWidth);
|
|
174
|
+
totalHeightUsed = Math.max(totalHeightUsed, y + itemSpace.outerHeight);
|
|
175
|
+
rowIndex += 1;
|
|
176
|
+
y += itemSpace.outerHeight;
|
|
177
|
+
}
|
|
178
|
+
return rep;
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Move the legend according to padding and position
|
|
182
|
+
let gapX = 0;
|
|
183
|
+
let gapY = 0;
|
|
184
|
+
switch (position.horizontal) {
|
|
185
|
+
case 'left':
|
|
186
|
+
gapX = padding.left;
|
|
187
|
+
break;
|
|
188
|
+
case 'right':
|
|
189
|
+
gapX = totalWidth - padding.right - totalWidthUsed;
|
|
190
|
+
break;
|
|
191
|
+
default:
|
|
192
|
+
gapX = (totalWidth - totalWidthUsed) / 2;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
switch (position.vertical) {
|
|
196
|
+
case 'top':
|
|
197
|
+
gapY = padding.top;
|
|
198
|
+
break;
|
|
199
|
+
case 'bottom':
|
|
200
|
+
gapY = totalHeight - padding.bottom - totalHeightUsed;
|
|
201
|
+
break;
|
|
202
|
+
default:
|
|
203
|
+
gapY = (totalHeight - totalHeightUsed) / 2;
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
return seriesWithRawPosition.map(item => (0, _extends2.default)({}, item, {
|
|
207
|
+
// Add the gap due to the position
|
|
208
|
+
positionX: item.positionX + gapX,
|
|
209
|
+
// Add the gap due to the position
|
|
210
|
+
positionY: item.positionY + gapY + (direction === 'row' ? rowMaxHeight[item.rowIndex] / 2 // Get the center of the entire row
|
|
211
|
+
: item.outerHeight / 2) // Get the center of the item
|
|
212
|
+
}));
|
|
213
|
+
}, [seriesToDisplay, position.horizontal, position.vertical, getItemSpace, labelStyle, direction, availableWidth, availableHeight, itemGap, padding.left, padding.right, padding.top, padding.bottom, totalWidth, totalHeight]);
|
|
166
214
|
if (hidden) {
|
|
167
215
|
return null;
|
|
168
216
|
}
|
|
169
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
className: classes.label,
|
|
196
|
-
children: label
|
|
197
|
-
})]
|
|
198
|
-
}, id))
|
|
217
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_NoSsr.NoSsr, {
|
|
218
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ChartsLegendRoot, {
|
|
219
|
+
className: classes.root,
|
|
220
|
+
children: seriesWithPosition.map(({
|
|
221
|
+
id,
|
|
222
|
+
label,
|
|
223
|
+
color,
|
|
224
|
+
positionX,
|
|
225
|
+
positionY
|
|
226
|
+
}) => /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
227
|
+
className: classes.series,
|
|
228
|
+
transform: `translate(${positionX} ${positionY})`,
|
|
229
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("rect", {
|
|
230
|
+
className: classes.mark,
|
|
231
|
+
y: -itemMarkHeight / 2,
|
|
232
|
+
width: itemMarkWidth,
|
|
233
|
+
height: itemMarkHeight,
|
|
234
|
+
fill: color
|
|
235
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsText.ChartsText, {
|
|
236
|
+
style: labelStyle,
|
|
237
|
+
text: label,
|
|
238
|
+
x: itemMarkWidth + markGap,
|
|
239
|
+
y: 0
|
|
240
|
+
})]
|
|
241
|
+
}, id))
|
|
242
|
+
})
|
|
199
243
|
});
|
|
200
244
|
}
|
|
201
245
|
function ChartsLegend(inProps) {
|
|
@@ -206,7 +250,6 @@ function ChartsLegend(inProps) {
|
|
|
206
250
|
const {
|
|
207
251
|
position,
|
|
208
252
|
direction,
|
|
209
|
-
offset,
|
|
210
253
|
hidden,
|
|
211
254
|
slots,
|
|
212
255
|
slotProps
|
|
@@ -225,7 +268,6 @@ function ChartsLegend(inProps) {
|
|
|
225
268
|
additionalProps: {
|
|
226
269
|
position,
|
|
227
270
|
direction,
|
|
228
|
-
offset,
|
|
229
271
|
classes,
|
|
230
272
|
drawingArea,
|
|
231
273
|
series,
|
|
@@ -13,5 +13,5 @@ export interface ChartsLegendClasses {
|
|
|
13
13
|
row: string;
|
|
14
14
|
}
|
|
15
15
|
export type ChartsLegendClassKey = keyof ChartsLegendClasses;
|
|
16
|
-
export declare function
|
|
16
|
+
export declare function getLegendUtilityClass(slot: string): string;
|
|
17
17
|
export declare const legendClasses: ChartsLegendClasses;
|
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getLegendUtilityClass = getLegendUtilityClass;
|
|
7
7
|
exports.legendClasses = void 0;
|
|
8
8
|
var _utils = require("@mui/utils");
|
|
9
|
-
function
|
|
9
|
+
function getLegendUtilityClass(slot) {
|
|
10
10
|
return (0, _utils.unstable_generateUtilityClass)('MuiChartsLegend', slot);
|
|
11
11
|
}
|
|
12
|
-
const legendClasses = (0, _utils.unstable_generateUtilityClasses)('MuiChartsLegend', ['root', 'series', 'mark', 'label', 'column', 'row']);
|
|
13
|
-
exports.legendClasses = legendClasses;
|
|
12
|
+
const legendClasses = exports.legendClasses = (0, _utils.unstable_generateUtilityClasses)('MuiChartsLegend', ['root', 'series', 'mark', 'label', 'column', 'row']);
|
package/ChartsLegend/utils.d.ts
CHANGED
|
@@ -5,10 +5,5 @@ export type AnchorPosition = {
|
|
|
5
5
|
horizontal: AnchorX;
|
|
6
6
|
vertical: AnchorY;
|
|
7
7
|
};
|
|
8
|
-
export type
|
|
9
|
-
direction?: 'row' | 'column';
|
|
10
|
-
markSize?: number;
|
|
11
|
-
itemWidth?: number;
|
|
12
|
-
spacing?: number;
|
|
13
|
-
};
|
|
8
|
+
export type Direction = 'row' | 'column';
|
|
14
9
|
export declare function getSeriesToDisplay(series: FormattedSeries): import("../models/seriesType/config").LegendParams[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartsXReferenceLineProps } from './ChartsXReferenceLine';
|
|
3
|
+
import { ChartsYReferenceLineProps } from './ChartsYReferenceLine';
|
|
4
|
+
import { XOR } from '../internals/utils';
|
|
5
|
+
type ChartsReferenceLineProps<TValue extends string | number | Date = string | number | Date> = XOR<ChartsXReferenceLineProps<TValue>, ChartsYReferenceLineProps<TValue>>;
|
|
6
|
+
declare function ChartsReferenceLine(props: ChartsReferenceLineProps): React.JSX.Element;
|
|
7
|
+
declare namespace ChartsReferenceLine {
|
|
8
|
+
var propTypes: any;
|
|
9
|
+
}
|
|
10
|
+
export { ChartsReferenceLine };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ChartsReferenceLine = ChartsReferenceLine;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
var _ChartsXReferenceLine = require("./ChartsXReferenceLine");
|
|
12
|
+
var _ChartsYReferenceLine = require("./ChartsYReferenceLine");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
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); }
|
|
15
|
+
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 && Object.prototype.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; }
|
|
16
|
+
function ChartsReferenceLine(props) {
|
|
17
|
+
if (props.x !== undefined && props.y !== undefined) {
|
|
18
|
+
throw new Error('MUI-X: The ChartsReferenceLine can not have both `x` and `y` props set.');
|
|
19
|
+
}
|
|
20
|
+
if (props.x === undefined && props.y === undefined) {
|
|
21
|
+
throw new Error('MUI-X: The ChartsReferenceLine should have a value in `x` or `y` prop.');
|
|
22
|
+
}
|
|
23
|
+
if (props.x !== undefined) {
|
|
24
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsXReferenceLine.ChartsXReferenceLine, (0, _extends2.default)({}, props));
|
|
25
|
+
}
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsYReferenceLine.ChartsYReferenceLine, (0, _extends2.default)({}, props));
|
|
27
|
+
}
|
|
28
|
+
process.env.NODE_ENV !== "production" ? ChartsReferenceLine.propTypes = {
|
|
29
|
+
// ----------------------------- Warning --------------------------------
|
|
30
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
31
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
32
|
+
// ----------------------------------------------------------------------
|
|
33
|
+
/**
|
|
34
|
+
* The id of the axis used for the reference value.
|
|
35
|
+
* @default The `id` of the first defined axis.
|
|
36
|
+
*/
|
|
37
|
+
axisId: _propTypes.default.string,
|
|
38
|
+
/**
|
|
39
|
+
* Override or extend the styles applied to the component.
|
|
40
|
+
*/
|
|
41
|
+
classes: _propTypes.default.object,
|
|
42
|
+
/**
|
|
43
|
+
* The label to display along the reference line.
|
|
44
|
+
*/
|
|
45
|
+
label: _propTypes.default.string,
|
|
46
|
+
/**
|
|
47
|
+
* The alignment if the label is in the chart drawing area.
|
|
48
|
+
* @default 'middle'
|
|
49
|
+
*/
|
|
50
|
+
labelAlign: _propTypes.default.oneOf(['end', 'middle', 'start']),
|
|
51
|
+
/**
|
|
52
|
+
* The style applied to the label.
|
|
53
|
+
*/
|
|
54
|
+
labelStyle: _propTypes.default.object,
|
|
55
|
+
/**
|
|
56
|
+
* The style applied to the line.
|
|
57
|
+
*/
|
|
58
|
+
lineStyle: _propTypes.default.object,
|
|
59
|
+
/**
|
|
60
|
+
* Additional space arround the label in px.
|
|
61
|
+
* Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
|
|
62
|
+
* @default 5
|
|
63
|
+
*/
|
|
64
|
+
spacing: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
|
|
65
|
+
x: _propTypes.default.number,
|
|
66
|
+
y: _propTypes.default.number
|
|
67
|
+
})]),
|
|
68
|
+
/**
|
|
69
|
+
* The x value associated with the reference line.
|
|
70
|
+
* If defined the reference line will be vertical.
|
|
71
|
+
*/
|
|
72
|
+
x: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string]),
|
|
73
|
+
/**
|
|
74
|
+
* The y value associated with the reference line.
|
|
75
|
+
* If defined the reference line will be horizontal.
|
|
76
|
+
*/
|
|
77
|
+
y: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number, _propTypes.default.string])
|
|
78
|
+
} : void 0;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CommonChartsReferenceLineProps } from './common';
|
|
3
|
+
import { ChartsReferenceLineClasses } from './chartsReferenceLineClasses';
|
|
4
|
+
export type ChartsXReferenceLineProps<TValue extends string | number | Date = string | number | Date> = CommonChartsReferenceLineProps & {
|
|
5
|
+
/**
|
|
6
|
+
* The x value associated with the reference line.
|
|
7
|
+
* If defined the reference line will be vertical.
|
|
8
|
+
*/
|
|
9
|
+
x: TValue;
|
|
10
|
+
};
|
|
11
|
+
export declare function getXReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"label" | "line" | "root", string>;
|
|
12
|
+
declare function ChartsXReferenceLine(props: ChartsXReferenceLineProps): React.JSX.Element | null;
|
|
13
|
+
export { ChartsXReferenceLine };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ChartsXReferenceLine = ChartsXReferenceLine;
|
|
8
|
+
exports.getXReferenceLineClasses = getXReferenceLineClasses;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
12
|
+
var _hooks = require("../hooks");
|
|
13
|
+
var _common = require("./common");
|
|
14
|
+
var _ChartsText = require("../internals/components/ChartsText");
|
|
15
|
+
var _chartsReferenceLineClasses = require("./chartsReferenceLineClasses");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
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); }
|
|
18
|
+
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 && Object.prototype.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; }
|
|
19
|
+
const getTextParams = ({
|
|
20
|
+
top,
|
|
21
|
+
height,
|
|
22
|
+
spacingY,
|
|
23
|
+
labelAlign = 'middle'
|
|
24
|
+
}) => {
|
|
25
|
+
switch (labelAlign) {
|
|
26
|
+
case 'start':
|
|
27
|
+
return {
|
|
28
|
+
y: top + spacingY,
|
|
29
|
+
style: {
|
|
30
|
+
dominantBaseline: 'hanging',
|
|
31
|
+
textAnchor: 'start'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
case 'end':
|
|
35
|
+
return {
|
|
36
|
+
y: top + height - spacingY,
|
|
37
|
+
style: {
|
|
38
|
+
dominantBaseline: 'auto',
|
|
39
|
+
textAnchor: 'start'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
default:
|
|
43
|
+
return {
|
|
44
|
+
y: top + height / 2,
|
|
45
|
+
style: {
|
|
46
|
+
dominantBaseline: 'central',
|
|
47
|
+
textAnchor: 'start'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
function getXReferenceLineClasses(classes) {
|
|
53
|
+
return (0, _composeClasses.default)({
|
|
54
|
+
root: ['root', 'vertical'],
|
|
55
|
+
line: ['line'],
|
|
56
|
+
label: ['label']
|
|
57
|
+
}, _chartsReferenceLineClasses.getReferenceLineUtilityClass, classes);
|
|
58
|
+
}
|
|
59
|
+
let warnedOnce = false;
|
|
60
|
+
function ChartsXReferenceLine(props) {
|
|
61
|
+
const {
|
|
62
|
+
x,
|
|
63
|
+
label = '',
|
|
64
|
+
spacing = 5,
|
|
65
|
+
classes: inClasses,
|
|
66
|
+
labelAlign,
|
|
67
|
+
lineStyle,
|
|
68
|
+
labelStyle,
|
|
69
|
+
axisId
|
|
70
|
+
} = props;
|
|
71
|
+
const {
|
|
72
|
+
top,
|
|
73
|
+
height
|
|
74
|
+
} = (0, _hooks.useDrawingArea)();
|
|
75
|
+
const xAxisScale = (0, _hooks.useXScale)(axisId);
|
|
76
|
+
const xPosition = xAxisScale(x);
|
|
77
|
+
if (xPosition === undefined) {
|
|
78
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
79
|
+
if (!warnedOnce) {
|
|
80
|
+
warnedOnce = true;
|
|
81
|
+
console.error(`MUI X: the value ${x} does not exist in the data of x axis with id ${axisId}.`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const d = `M ${xPosition} ${top} l 0 ${height}`;
|
|
87
|
+
const classes = getXReferenceLineClasses(inClasses);
|
|
88
|
+
const spacingX = typeof spacing === 'object' ? spacing.x ?? 0 : spacing;
|
|
89
|
+
const spacingY = typeof spacing === 'object' ? spacing.y ?? 0 : spacing;
|
|
90
|
+
const textParams = (0, _extends2.default)({
|
|
91
|
+
x: xPosition + spacingX,
|
|
92
|
+
text: label,
|
|
93
|
+
fontSize: 12
|
|
94
|
+
}, getTextParams({
|
|
95
|
+
top,
|
|
96
|
+
height,
|
|
97
|
+
spacingY,
|
|
98
|
+
labelAlign
|
|
99
|
+
}), {
|
|
100
|
+
className: classes.label
|
|
101
|
+
});
|
|
102
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_common.ReferenceLineRoot, {
|
|
103
|
+
className: classes.root,
|
|
104
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
105
|
+
d: d,
|
|
106
|
+
className: classes.line,
|
|
107
|
+
style: lineStyle
|
|
108
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsText.ChartsText, (0, _extends2.default)({}, textParams, {
|
|
109
|
+
style: (0, _extends2.default)({}, textParams.style, labelStyle)
|
|
110
|
+
}))]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CommonChartsReferenceLineProps } from './common';
|
|
3
|
+
import { ChartsReferenceLineClasses } from './chartsReferenceLineClasses';
|
|
4
|
+
export type ChartsYReferenceLineProps<TValue extends string | number | Date = string | number | Date> = CommonChartsReferenceLineProps & {
|
|
5
|
+
/**
|
|
6
|
+
* The y value associated with the reference line.
|
|
7
|
+
* If defined the reference line will be horizontal.
|
|
8
|
+
*/
|
|
9
|
+
y: TValue;
|
|
10
|
+
};
|
|
11
|
+
export declare function getYReferenceLineClasses(classes?: Partial<ChartsReferenceLineClasses>): Record<"label" | "line" | "root", string>;
|
|
12
|
+
declare function ChartsYReferenceLine(props: ChartsYReferenceLineProps): React.JSX.Element | null;
|
|
13
|
+
export { ChartsYReferenceLine };
|