@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import { DrawingProvider } from '../context/DrawingProvider';
|
|
@@ -8,78 +9,36 @@ import { ChartsSurface } from '../ChartsSurface';
|
|
|
8
9
|
import { CartesianContextProvider } from '../context/CartesianProvider';
|
|
9
10
|
import { ChartsAxesGradients } from '../internals/components/ChartsAxesGradients';
|
|
10
11
|
import { HighlightedProvider, ZAxisContextProvider } from '../context';
|
|
11
|
-
import {
|
|
12
|
+
import { useChartContainerProps } from './useChartContainerProps';
|
|
12
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
|
|
14
15
|
const {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
onHighlightChange,
|
|
30
|
-
plugins,
|
|
31
|
-
children
|
|
32
|
-
} = props;
|
|
33
|
-
const {
|
|
34
|
-
svgRef,
|
|
35
|
-
handleRef,
|
|
36
|
-
xExtremumGetters,
|
|
37
|
-
yExtremumGetters,
|
|
38
|
-
seriesFormatters,
|
|
39
|
-
colorProcessors
|
|
40
|
-
} = useChartContainerHooks(ref, plugins);
|
|
41
|
-
return /*#__PURE__*/_jsx(DrawingProvider, {
|
|
42
|
-
width: width,
|
|
43
|
-
height: height,
|
|
44
|
-
margin: margin,
|
|
45
|
-
svgRef: svgRef,
|
|
46
|
-
children: /*#__PURE__*/_jsx(ColorProvider, {
|
|
47
|
-
colorProcessors: colorProcessors,
|
|
48
|
-
children: /*#__PURE__*/_jsx(SeriesContextProvider, {
|
|
49
|
-
series: series,
|
|
50
|
-
colors: colors,
|
|
51
|
-
dataset: dataset,
|
|
52
|
-
seriesFormatters: seriesFormatters,
|
|
53
|
-
children: /*#__PURE__*/_jsx(CartesianContextProvider, {
|
|
54
|
-
xAxis: xAxis,
|
|
55
|
-
yAxis: yAxis,
|
|
56
|
-
dataset: dataset,
|
|
57
|
-
xExtremumGetters: xExtremumGetters,
|
|
58
|
-
yExtremumGetters: yExtremumGetters,
|
|
59
|
-
children: /*#__PURE__*/_jsx(ZAxisContextProvider, {
|
|
60
|
-
zAxis: zAxis,
|
|
61
|
-
dataset: dataset,
|
|
16
|
+
children,
|
|
17
|
+
drawingProviderProps,
|
|
18
|
+
colorProviderProps,
|
|
19
|
+
seriesContextProps,
|
|
20
|
+
cartesianContextProps,
|
|
21
|
+
zAxisContextProps,
|
|
22
|
+
highlightedProviderProps,
|
|
23
|
+
chartsSurfaceProps
|
|
24
|
+
} = useChartContainerProps(props, ref);
|
|
25
|
+
return /*#__PURE__*/_jsx(DrawingProvider, _extends({}, drawingProviderProps, {
|
|
26
|
+
children: /*#__PURE__*/_jsx(ColorProvider, _extends({}, colorProviderProps, {
|
|
27
|
+
children: /*#__PURE__*/_jsx(SeriesContextProvider, _extends({}, seriesContextProps, {
|
|
28
|
+
children: /*#__PURE__*/_jsx(CartesianContextProvider, _extends({}, cartesianContextProps, {
|
|
29
|
+
children: /*#__PURE__*/_jsx(ZAxisContextProvider, _extends({}, zAxisContextProps, {
|
|
62
30
|
children: /*#__PURE__*/_jsx(InteractionProvider, {
|
|
63
|
-
children: /*#__PURE__*/_jsx(HighlightedProvider, {
|
|
64
|
-
|
|
65
|
-
onHighlightChange: onHighlightChange,
|
|
66
|
-
children: /*#__PURE__*/_jsxs(ChartsSurface, {
|
|
67
|
-
width: width,
|
|
68
|
-
height: height,
|
|
69
|
-
ref: handleRef,
|
|
70
|
-
sx: sx,
|
|
71
|
-
title: title,
|
|
72
|
-
desc: desc,
|
|
73
|
-
disableAxisListener: disableAxisListener,
|
|
31
|
+
children: /*#__PURE__*/_jsx(HighlightedProvider, _extends({}, highlightedProviderProps, {
|
|
32
|
+
children: /*#__PURE__*/_jsxs(ChartsSurface, _extends({}, chartsSurfaceProps, {
|
|
74
33
|
children: [/*#__PURE__*/_jsx(ChartsAxesGradients, {}), children]
|
|
75
|
-
})
|
|
76
|
-
})
|
|
34
|
+
}))
|
|
35
|
+
}))
|
|
77
36
|
})
|
|
78
|
-
})
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
})
|
|
82
|
-
});
|
|
37
|
+
}))
|
|
38
|
+
}))
|
|
39
|
+
}))
|
|
40
|
+
}))
|
|
41
|
+
}));
|
|
83
42
|
});
|
|
84
43
|
process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
85
44
|
// ----------------------------- Warning --------------------------------
|
|
@@ -4,7 +4,7 @@ import { usePluginsMerge } from './usePluginsMerge';
|
|
|
4
4
|
import { useReducedMotion } from '../hooks/useReducedMotion';
|
|
5
5
|
export const useChartContainerHooks = (ref, plugins) => {
|
|
6
6
|
const svgRef = React.useRef(null);
|
|
7
|
-
const
|
|
7
|
+
const chartSurfaceRef = useForkRef(ref, svgRef);
|
|
8
8
|
const {
|
|
9
9
|
xExtremumGetters,
|
|
10
10
|
yExtremumGetters,
|
|
@@ -15,7 +15,7 @@ export const useChartContainerHooks = (ref, plugins) => {
|
|
|
15
15
|
|
|
16
16
|
return {
|
|
17
17
|
svgRef,
|
|
18
|
-
|
|
18
|
+
chartSurfaceRef,
|
|
19
19
|
xExtremumGetters,
|
|
20
20
|
yExtremumGetters,
|
|
21
21
|
seriesFormatters,
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["width", "height", "series", "margin", "xAxis", "yAxis", "zAxis", "colors", "dataset", "sx", "title", "desc", "disableAxisListener", "highlightedItem", "onHighlightChange", "plugins", "children"];
|
|
4
|
+
import { useChartContainerHooks } from './useChartContainerHooks';
|
|
5
|
+
import { useDefaultizeAxis } from './useDefaultizeAxis';
|
|
6
|
+
export const useChartContainerProps = (props, ref) => {
|
|
7
|
+
const {
|
|
8
|
+
width,
|
|
9
|
+
height,
|
|
10
|
+
series,
|
|
11
|
+
margin,
|
|
12
|
+
xAxis,
|
|
13
|
+
yAxis,
|
|
14
|
+
zAxis,
|
|
15
|
+
colors,
|
|
16
|
+
dataset,
|
|
17
|
+
sx,
|
|
18
|
+
title,
|
|
19
|
+
desc,
|
|
20
|
+
disableAxisListener,
|
|
21
|
+
highlightedItem,
|
|
22
|
+
onHighlightChange,
|
|
23
|
+
plugins,
|
|
24
|
+
children
|
|
25
|
+
} = props,
|
|
26
|
+
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
27
|
+
const {
|
|
28
|
+
svgRef,
|
|
29
|
+
chartSurfaceRef,
|
|
30
|
+
xExtremumGetters,
|
|
31
|
+
yExtremumGetters,
|
|
32
|
+
seriesFormatters,
|
|
33
|
+
colorProcessors
|
|
34
|
+
} = useChartContainerHooks(ref, plugins);
|
|
35
|
+
const [defaultizedXAxis, defaultizedYAxis] = useDefaultizeAxis(xAxis, yAxis);
|
|
36
|
+
const drawingProviderProps = {
|
|
37
|
+
width,
|
|
38
|
+
height,
|
|
39
|
+
margin,
|
|
40
|
+
svgRef
|
|
41
|
+
};
|
|
42
|
+
const colorProviderProps = {
|
|
43
|
+
colorProcessors
|
|
44
|
+
};
|
|
45
|
+
const seriesContextProps = {
|
|
46
|
+
series,
|
|
47
|
+
colors,
|
|
48
|
+
dataset,
|
|
49
|
+
seriesFormatters
|
|
50
|
+
};
|
|
51
|
+
const cartesianContextProps = {
|
|
52
|
+
xAxis: defaultizedXAxis,
|
|
53
|
+
yAxis: defaultizedYAxis,
|
|
54
|
+
dataset,
|
|
55
|
+
xExtremumGetters,
|
|
56
|
+
yExtremumGetters
|
|
57
|
+
};
|
|
58
|
+
const zAxisContextProps = {
|
|
59
|
+
zAxis,
|
|
60
|
+
dataset
|
|
61
|
+
};
|
|
62
|
+
const highlightedProviderProps = {
|
|
63
|
+
highlightedItem,
|
|
64
|
+
onHighlightChange
|
|
65
|
+
};
|
|
66
|
+
const chartsSurfaceProps = _extends({}, other, {
|
|
67
|
+
width,
|
|
68
|
+
height,
|
|
69
|
+
ref: chartSurfaceRef,
|
|
70
|
+
sx,
|
|
71
|
+
title,
|
|
72
|
+
desc,
|
|
73
|
+
disableAxisListener
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
children,
|
|
77
|
+
drawingProviderProps,
|
|
78
|
+
colorProviderProps,
|
|
79
|
+
seriesContextProps,
|
|
80
|
+
cartesianContextProps,
|
|
81
|
+
zAxisContextProps,
|
|
82
|
+
highlightedProviderProps,
|
|
83
|
+
chartsSurfaceProps,
|
|
84
|
+
xAxis: defaultizedXAxis,
|
|
85
|
+
yAxis: defaultizedYAxis
|
|
86
|
+
};
|
|
87
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
4
|
+
const defaultizeAxis = (inAxis, axisName) => {
|
|
5
|
+
const DEFAULT_AXIS_KEY = axisName === 'x' ? DEFAULT_X_AXIS_KEY : DEFAULT_Y_AXIS_KEY;
|
|
6
|
+
return [...(inAxis?.map((axis, index) => _extends({
|
|
7
|
+
id: `defaultized-${axisName}-axis-${index}`
|
|
8
|
+
}, axis)) ?? []), ...(inAxis === undefined || inAxis.findIndex(({
|
|
9
|
+
id
|
|
10
|
+
}) => id === DEFAULT_AXIS_KEY) === -1 ? [{
|
|
11
|
+
id: DEFAULT_AXIS_KEY,
|
|
12
|
+
scaleType: 'linear'
|
|
13
|
+
}] : [])];
|
|
14
|
+
};
|
|
15
|
+
export const useDefaultizeAxis = (inXAxis, inYAxis) => {
|
|
16
|
+
const xAxis = React.useMemo(() => defaultizeAxis(inXAxis, 'x'), [inXAxis]);
|
|
17
|
+
const yAxis = React.useMemo(() => defaultizeAxis(inYAxis, 'y'), [inYAxis]);
|
|
18
|
+
return [xAxis, yAxis];
|
|
19
|
+
};
|
|
@@ -57,16 +57,16 @@ function ChartsAxis(props) {
|
|
|
57
57
|
const topId = getAxisId(topAxis, xAxisIds[0]);
|
|
58
58
|
const rightId = getAxisId(rightAxis, yAxisIds[0]);
|
|
59
59
|
if (topId !== null && !xAxis[topId]) {
|
|
60
|
-
throw Error([`MUI X
|
|
60
|
+
throw Error([`MUI X: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
61
61
|
}
|
|
62
62
|
if (leftId !== null && !yAxis[leftId]) {
|
|
63
|
-
throw Error([`MUI X
|
|
63
|
+
throw Error([`MUI X: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
64
64
|
}
|
|
65
65
|
if (rightId !== null && !yAxis[rightId]) {
|
|
66
|
-
throw Error([`MUI X
|
|
66
|
+
throw Error([`MUI X: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
67
67
|
}
|
|
68
68
|
if (bottomId !== null && !xAxis[bottomId]) {
|
|
69
|
-
throw Error([`MUI X
|
|
69
|
+
throw Error([`MUI X: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
70
70
|
}
|
|
71
71
|
const topAxisProps = mergeProps(topAxis, slots, slotProps);
|
|
72
72
|
const bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
|
|
@@ -74,7 +74,7 @@ function ChartsAxisHighlight(props) {
|
|
|
74
74
|
const isXError = isBandScaleX && xScale(axisX.value) === undefined;
|
|
75
75
|
const isYError = isBandScaleY && yScale(axisY.value) === undefined;
|
|
76
76
|
if (isXError || isYError) {
|
|
77
|
-
console.error([`MUI X
|
|
77
|
+
console.error([`MUI X: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { useTheme } from '@mui/material/styles';
|
|
5
|
+
import ChartsContinuousGradient from '../internals/components/ChartsAxesGradients/ChartsContinuousGradient';
|
|
6
|
+
import { useChartId, useDrawingArea } from '../hooks';
|
|
7
|
+
import { getScale } from '../internals/getScale';
|
|
8
|
+
import { getPercentageValue } from '../internals/getPercentageValue';
|
|
9
|
+
import { ChartsText } from '../ChartsText';
|
|
10
|
+
import { getStringSize } from '../internals/domUtils';
|
|
11
|
+
import { useAxis } from './useAxis';
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
function getPositionOffset(position, legendBox, svgBox) {
|
|
14
|
+
let offsetX = 0;
|
|
15
|
+
let offsetY = 0;
|
|
16
|
+
switch (position.horizontal) {
|
|
17
|
+
case 'left':
|
|
18
|
+
offsetX = 0;
|
|
19
|
+
break;
|
|
20
|
+
case 'middle':
|
|
21
|
+
offsetX = (svgBox.width - legendBox.width) / 2;
|
|
22
|
+
break;
|
|
23
|
+
case 'right':
|
|
24
|
+
default:
|
|
25
|
+
offsetX = svgBox.width - legendBox.width;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
switch (position.vertical) {
|
|
29
|
+
case 'top':
|
|
30
|
+
offsetY = 0;
|
|
31
|
+
break;
|
|
32
|
+
case 'middle':
|
|
33
|
+
offsetY = (svgBox.height - legendBox.height) / 2;
|
|
34
|
+
break;
|
|
35
|
+
case 'bottom':
|
|
36
|
+
default:
|
|
37
|
+
offsetY = svgBox.height - legendBox.height;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
offsetX,
|
|
42
|
+
offsetY
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Takes placement parameters and element bounding boxes.
|
|
48
|
+
* Returns the x, y coordinates of the elements. And the textAnchor, dominantBaseline for texts.
|
|
49
|
+
*/
|
|
50
|
+
function getElementPositions(text1Box, barBox, text2Box, params) {
|
|
51
|
+
if (params.direction === 'column') {
|
|
52
|
+
const text1 = {
|
|
53
|
+
y: text1Box.height,
|
|
54
|
+
dominantBaseline: 'auto'
|
|
55
|
+
};
|
|
56
|
+
const text2 = {
|
|
57
|
+
y: text1Box.height + 2 * params.spacing + barBox.height,
|
|
58
|
+
dominantBaseline: 'hanging'
|
|
59
|
+
};
|
|
60
|
+
const bar = {
|
|
61
|
+
y: text1Box.height + params.spacing
|
|
62
|
+
};
|
|
63
|
+
const totalWidth = Math.max(text1Box.width, barBox.width, text2Box.width);
|
|
64
|
+
const totalHeight = text1Box.height + barBox.height + text2Box.height + 2 * params.spacing;
|
|
65
|
+
const boundingBox = {
|
|
66
|
+
width: totalWidth,
|
|
67
|
+
height: totalHeight
|
|
68
|
+
};
|
|
69
|
+
switch (params.align) {
|
|
70
|
+
case 'start':
|
|
71
|
+
return {
|
|
72
|
+
text1: _extends({}, text1, {
|
|
73
|
+
textAnchor: 'start',
|
|
74
|
+
x: 0
|
|
75
|
+
}),
|
|
76
|
+
text2: _extends({}, text2, {
|
|
77
|
+
textAnchor: 'start',
|
|
78
|
+
x: 0
|
|
79
|
+
}),
|
|
80
|
+
bar: _extends({}, bar, {
|
|
81
|
+
x: 0
|
|
82
|
+
}),
|
|
83
|
+
boundingBox
|
|
84
|
+
};
|
|
85
|
+
case 'end':
|
|
86
|
+
return {
|
|
87
|
+
text1: _extends({}, text1, {
|
|
88
|
+
textAnchor: 'end',
|
|
89
|
+
x: totalWidth
|
|
90
|
+
}),
|
|
91
|
+
text2: _extends({}, text2, {
|
|
92
|
+
textAnchor: 'end',
|
|
93
|
+
x: totalWidth
|
|
94
|
+
}),
|
|
95
|
+
bar: _extends({}, bar, {
|
|
96
|
+
x: totalWidth - barBox.width
|
|
97
|
+
}),
|
|
98
|
+
boundingBox
|
|
99
|
+
};
|
|
100
|
+
case 'middle':
|
|
101
|
+
default:
|
|
102
|
+
return {
|
|
103
|
+
text1: _extends({}, text1, {
|
|
104
|
+
textAnchor: 'middle',
|
|
105
|
+
x: totalWidth / 2
|
|
106
|
+
}),
|
|
107
|
+
text2: _extends({}, text2, {
|
|
108
|
+
textAnchor: 'middle',
|
|
109
|
+
x: totalWidth / 2
|
|
110
|
+
}),
|
|
111
|
+
bar: _extends({}, bar, {
|
|
112
|
+
x: totalWidth / 2 - barBox.width / 2
|
|
113
|
+
}),
|
|
114
|
+
boundingBox
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
} else {
|
|
118
|
+
const text1 = {
|
|
119
|
+
x: text1Box.width,
|
|
120
|
+
textAnchor: 'end'
|
|
121
|
+
};
|
|
122
|
+
const text2 = {
|
|
123
|
+
x: text1Box.width + 2 * params.spacing + barBox.width,
|
|
124
|
+
textAnchor: 'start'
|
|
125
|
+
};
|
|
126
|
+
const bar = {
|
|
127
|
+
x: text1Box.width + params.spacing
|
|
128
|
+
};
|
|
129
|
+
const totalHeight = Math.max(text1Box.height, barBox.height, text2Box.height);
|
|
130
|
+
const totalWidth = text1Box.width + barBox.width + text2Box.width + 2 * params.spacing;
|
|
131
|
+
const boundingBox = {
|
|
132
|
+
width: totalWidth,
|
|
133
|
+
height: totalHeight
|
|
134
|
+
};
|
|
135
|
+
switch (params.align) {
|
|
136
|
+
case 'start':
|
|
137
|
+
return {
|
|
138
|
+
text1: _extends({}, text1, {
|
|
139
|
+
dominantBaseline: 'hanging',
|
|
140
|
+
y: 0
|
|
141
|
+
}),
|
|
142
|
+
text2: _extends({}, text2, {
|
|
143
|
+
dominantBaseline: 'hanging',
|
|
144
|
+
y: 0
|
|
145
|
+
}),
|
|
146
|
+
bar: _extends({}, bar, {
|
|
147
|
+
y: 0
|
|
148
|
+
}),
|
|
149
|
+
boundingBox
|
|
150
|
+
};
|
|
151
|
+
case 'end':
|
|
152
|
+
return {
|
|
153
|
+
text1: _extends({}, text1, {
|
|
154
|
+
dominantBaseline: 'auto',
|
|
155
|
+
y: totalHeight
|
|
156
|
+
}),
|
|
157
|
+
text2: _extends({}, text2, {
|
|
158
|
+
dominantBaseline: 'auto',
|
|
159
|
+
y: totalHeight
|
|
160
|
+
}),
|
|
161
|
+
bar: _extends({}, bar, {
|
|
162
|
+
y: totalHeight - barBox.height
|
|
163
|
+
}),
|
|
164
|
+
boundingBox
|
|
165
|
+
};
|
|
166
|
+
case 'middle':
|
|
167
|
+
default:
|
|
168
|
+
return {
|
|
169
|
+
text1: _extends({}, text1, {
|
|
170
|
+
dominantBaseline: 'central',
|
|
171
|
+
y: totalHeight / 2
|
|
172
|
+
}),
|
|
173
|
+
text2: _extends({}, text2, {
|
|
174
|
+
dominantBaseline: 'central',
|
|
175
|
+
y: totalHeight / 2
|
|
176
|
+
}),
|
|
177
|
+
bar: _extends({}, bar, {
|
|
178
|
+
y: totalHeight / 2 - barBox.height / 2
|
|
179
|
+
}),
|
|
180
|
+
boundingBox
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const defaultLabelFormatter = ({
|
|
186
|
+
formattedValue
|
|
187
|
+
}) => formattedValue;
|
|
188
|
+
function ContinuousColorLegend(props) {
|
|
189
|
+
const theme = useTheme();
|
|
190
|
+
const {
|
|
191
|
+
id: idProp,
|
|
192
|
+
minLabel = defaultLabelFormatter,
|
|
193
|
+
maxLabel = defaultLabelFormatter,
|
|
194
|
+
scaleType = 'linear',
|
|
195
|
+
direction,
|
|
196
|
+
length = '50%',
|
|
197
|
+
thickness = 5,
|
|
198
|
+
spacing = 4,
|
|
199
|
+
align = 'middle',
|
|
200
|
+
labelStyle = theme.typography.subtitle1,
|
|
201
|
+
position,
|
|
202
|
+
axisDirection,
|
|
203
|
+
axisId
|
|
204
|
+
} = props;
|
|
205
|
+
const chartId = useChartId();
|
|
206
|
+
const id = idProp ?? `gradient-legend-${chartId}`;
|
|
207
|
+
const isRTL = theme.direction === 'rtl';
|
|
208
|
+
const axisItem = useAxis({
|
|
209
|
+
axisDirection,
|
|
210
|
+
axisId
|
|
211
|
+
});
|
|
212
|
+
const {
|
|
213
|
+
width,
|
|
214
|
+
height,
|
|
215
|
+
left,
|
|
216
|
+
right,
|
|
217
|
+
top,
|
|
218
|
+
bottom
|
|
219
|
+
} = useDrawingArea();
|
|
220
|
+
const refLength = direction === 'column' ? height + top + bottom : width + left + right;
|
|
221
|
+
const size = getPercentageValue(length, refLength);
|
|
222
|
+
const isReversed = direction === 'column';
|
|
223
|
+
const colorMap = axisItem?.colorMap;
|
|
224
|
+
if (!colorMap || !colorMap.type || colorMap.type !== 'continuous') {
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Define the coordinate to color mapping
|
|
229
|
+
|
|
230
|
+
const colorScale = axisItem.colorScale;
|
|
231
|
+
const minValue = colorMap.min ?? 0;
|
|
232
|
+
const maxValue = colorMap.max ?? 100;
|
|
233
|
+
const scale = getScale(scaleType, [minValue, maxValue], isReversed ? [size, 0] : [0, size]);
|
|
234
|
+
|
|
235
|
+
// Get texts to display
|
|
236
|
+
|
|
237
|
+
const formattedMin = axisItem.valueFormatter?.(minValue, {
|
|
238
|
+
location: 'legend'
|
|
239
|
+
}) ?? minValue.toLocaleString();
|
|
240
|
+
const formattedMax = axisItem.valueFormatter?.(maxValue, {
|
|
241
|
+
location: 'legend'
|
|
242
|
+
}) ?? maxValue.toLocaleString();
|
|
243
|
+
const minText = typeof minLabel === 'string' ? minLabel : minLabel({
|
|
244
|
+
value: minValue ?? 0,
|
|
245
|
+
formattedValue: formattedMin
|
|
246
|
+
});
|
|
247
|
+
const maxText = typeof maxLabel === 'string' ? maxLabel : maxLabel({
|
|
248
|
+
value: maxValue ?? 0,
|
|
249
|
+
formattedValue: formattedMax
|
|
250
|
+
});
|
|
251
|
+
const text1 = isReversed ? maxText : minText;
|
|
252
|
+
const text2 = isReversed ? minText : maxText;
|
|
253
|
+
const text1Box = getStringSize(text1, _extends({}, labelStyle));
|
|
254
|
+
const text2Box = getStringSize(text2, _extends({}, labelStyle));
|
|
255
|
+
|
|
256
|
+
// Place bar and texts
|
|
257
|
+
|
|
258
|
+
const barBox = direction === 'column' || isRTL && direction === 'row' ? {
|
|
259
|
+
width: thickness,
|
|
260
|
+
height: size
|
|
261
|
+
} : {
|
|
262
|
+
width: size,
|
|
263
|
+
height: thickness
|
|
264
|
+
};
|
|
265
|
+
const legendPositions = getElementPositions(text1Box, barBox, text2Box, {
|
|
266
|
+
spacing,
|
|
267
|
+
align,
|
|
268
|
+
direction
|
|
269
|
+
});
|
|
270
|
+
const svgBoundingBox = {
|
|
271
|
+
width: width + left + right,
|
|
272
|
+
height: height + top + bottom
|
|
273
|
+
};
|
|
274
|
+
const positionOffset = getPositionOffset(_extends({
|
|
275
|
+
horizontal: 'middle',
|
|
276
|
+
vertical: 'top'
|
|
277
|
+
}, position), legendPositions.boundingBox, svgBoundingBox);
|
|
278
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
279
|
+
children: [/*#__PURE__*/_jsx(ChartsContinuousGradient, {
|
|
280
|
+
isReversed: isReversed,
|
|
281
|
+
gradientId: id,
|
|
282
|
+
size: size,
|
|
283
|
+
direction: direction === 'row' ? 'x' : 'y',
|
|
284
|
+
scale: scale,
|
|
285
|
+
colorScale: colorScale,
|
|
286
|
+
colorMap: colorMap,
|
|
287
|
+
gradientUnits: "objectBoundingBox"
|
|
288
|
+
}), /*#__PURE__*/_jsx(ChartsText, {
|
|
289
|
+
text: text1,
|
|
290
|
+
x: positionOffset.offsetX + legendPositions.text1.x,
|
|
291
|
+
y: positionOffset.offsetY + legendPositions.text1.y,
|
|
292
|
+
style: _extends({
|
|
293
|
+
dominantBaseline: legendPositions.text1.dominantBaseline,
|
|
294
|
+
textAnchor: legendPositions.text1.textAnchor
|
|
295
|
+
}, labelStyle)
|
|
296
|
+
}), /*#__PURE__*/_jsx("rect", _extends({
|
|
297
|
+
x: positionOffset.offsetX + legendPositions.bar.x,
|
|
298
|
+
y: positionOffset.offsetY + legendPositions.bar.y
|
|
299
|
+
}, barBox, {
|
|
300
|
+
fill: `url(#${id})`
|
|
301
|
+
})), /*#__PURE__*/_jsx(ChartsText, {
|
|
302
|
+
text: text2,
|
|
303
|
+
x: positionOffset.offsetX + legendPositions.text2.x,
|
|
304
|
+
y: positionOffset.offsetY + legendPositions.text2.y,
|
|
305
|
+
style: _extends({
|
|
306
|
+
dominantBaseline: legendPositions.text2.dominantBaseline,
|
|
307
|
+
textAnchor: legendPositions.text2.textAnchor
|
|
308
|
+
}, labelStyle)
|
|
309
|
+
})]
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
process.env.NODE_ENV !== "production" ? ContinuousColorLegend.propTypes = {
|
|
313
|
+
// ----------------------------- Warning --------------------------------
|
|
314
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
315
|
+
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
316
|
+
// ----------------------------------------------------------------------
|
|
317
|
+
/**
|
|
318
|
+
* The alignment of the texts with the gradient bar.
|
|
319
|
+
* @default 'middle'
|
|
320
|
+
*/
|
|
321
|
+
align: PropTypes.oneOf(['end', 'middle', 'start']),
|
|
322
|
+
/**
|
|
323
|
+
* The axis direction containing the color configuration to represent.
|
|
324
|
+
* @default 'z'
|
|
325
|
+
*/
|
|
326
|
+
axisDirection: PropTypes.oneOf(['x', 'y', 'z']),
|
|
327
|
+
/**
|
|
328
|
+
* The id of the axis item with the color configuration to represent.
|
|
329
|
+
* @default The first axis item.
|
|
330
|
+
*/
|
|
331
|
+
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
332
|
+
/**
|
|
333
|
+
* The direction of the legend layout.
|
|
334
|
+
* The default depends on the chart.
|
|
335
|
+
*/
|
|
336
|
+
direction: PropTypes.oneOf(['column', 'row']),
|
|
337
|
+
/**
|
|
338
|
+
* A unique identifier for the gradient.
|
|
339
|
+
* @default auto-generated id
|
|
340
|
+
*/
|
|
341
|
+
id: PropTypes.string,
|
|
342
|
+
/**
|
|
343
|
+
* The style applied to labels.
|
|
344
|
+
* @default theme.typography.subtitle1
|
|
345
|
+
*/
|
|
346
|
+
labelStyle: PropTypes.object,
|
|
347
|
+
/**
|
|
348
|
+
* The length of the gradient bar.
|
|
349
|
+
* Can be a number (in px) or a string with a percentage such as '50%'.
|
|
350
|
+
* The '100%' is the length of the svg.
|
|
351
|
+
* @default '50%'
|
|
352
|
+
*/
|
|
353
|
+
length: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
354
|
+
/**
|
|
355
|
+
* The label to display at the maximum side of the gradient.
|
|
356
|
+
* Can either be a string, or a function.
|
|
357
|
+
* If not defined, the formatted maximal value is display.
|
|
358
|
+
* @default ({ formattedValue }) => formattedValue
|
|
359
|
+
*/
|
|
360
|
+
maxLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
361
|
+
/**
|
|
362
|
+
* The label to display at the minimum side of the gradient.
|
|
363
|
+
* Can either be a string, or a function.
|
|
364
|
+
* @default ({ formattedValue }) => formattedValue
|
|
365
|
+
*/
|
|
366
|
+
minLabel: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
367
|
+
/**
|
|
368
|
+
* The position of the legend.
|
|
369
|
+
*/
|
|
370
|
+
position: PropTypes.shape({
|
|
371
|
+
horizontal: PropTypes.oneOf(['left', 'middle', 'right']).isRequired,
|
|
372
|
+
vertical: PropTypes.oneOf(['bottom', 'middle', 'top']).isRequired
|
|
373
|
+
}),
|
|
374
|
+
/**
|
|
375
|
+
* The scale used to display gradient colors.
|
|
376
|
+
* @default 'linear'
|
|
377
|
+
*/
|
|
378
|
+
scaleType: PropTypes.oneOf(['linear', 'log', 'pow', 'sqrt', 'time', 'utc']),
|
|
379
|
+
/**
|
|
380
|
+
* The space between the gradient bar and the labels.
|
|
381
|
+
* @default 4
|
|
382
|
+
*/
|
|
383
|
+
spacing: PropTypes.number,
|
|
384
|
+
/**
|
|
385
|
+
* The thickness of the gradient bar.
|
|
386
|
+
* @default 5
|
|
387
|
+
*/
|
|
388
|
+
thickness: PropTypes.number
|
|
389
|
+
} : void 0;
|
|
390
|
+
export { ContinuousColorLegend };
|