@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
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useIsomorphicLayoutEffect, Globals } from '@react-spring/web';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns `boolean` or `null`, used to automatically
|
|
5
|
+
* set skipAnimations to the value of the user's
|
|
6
|
+
* `prefers-reduced-motion` query.
|
|
7
|
+
*
|
|
8
|
+
* The return value, post-effect, is the value of their prefered setting
|
|
9
|
+
*/
|
|
10
|
+
export var useReducedMotion = function useReducedMotion() {
|
|
11
|
+
// Taken from: https://github.com/pmndrs/react-spring/blob/02ec877bbfab0df46da0e4a47d5f68d3e731206a/packages/shared/src/hooks/useReducedMotion.ts#L13
|
|
12
|
+
|
|
13
|
+
useIsomorphicLayoutEffect(function () {
|
|
14
|
+
var mql = window.matchMedia('(prefers-reduced-motion)');
|
|
15
|
+
var handleMediaChange = function handleMediaChange(e) {
|
|
16
|
+
Globals.assign({
|
|
17
|
+
// Modification such the react-spring implementation such that this hook can remove animation but never activate animation.
|
|
18
|
+
skipAnimation: e.matches || undefined
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
handleMediaChange(mql);
|
|
22
|
+
mql.addEventListener('change', handleMediaChange);
|
|
23
|
+
return function () {
|
|
24
|
+
mql.removeEventListener('change', handleMediaChange);
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
};
|
package/legacy/hooks/useTicks.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
1
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import { isBandScale } from '../internals/isBandScale';
|
|
4
|
-
export function
|
|
5
|
+
export function getTickNumber(params) {
|
|
5
6
|
var tickMaxStep = params.tickMaxStep,
|
|
6
7
|
tickMinStep = params.tickMinStep,
|
|
7
8
|
tickNumber = params.tickNumber,
|
|
@@ -14,8 +15,9 @@ export function getTicksNumber(params) {
|
|
|
14
15
|
}
|
|
15
16
|
function useTicks(options) {
|
|
16
17
|
var scale = options.scale,
|
|
17
|
-
|
|
18
|
-
valueFormatter = options.valueFormatter
|
|
18
|
+
tickNumber = options.tickNumber,
|
|
19
|
+
valueFormatter = options.valueFormatter,
|
|
20
|
+
tickInterval = options.tickInterval;
|
|
19
21
|
return React.useMemo(function () {
|
|
20
22
|
// band scale
|
|
21
23
|
if (isBandScale(scale)) {
|
|
@@ -25,7 +27,8 @@ function useTicks(options) {
|
|
|
25
27
|
return [].concat(_toConsumableArray(domain.map(function (value) {
|
|
26
28
|
var _valueFormatter;
|
|
27
29
|
return {
|
|
28
|
-
|
|
30
|
+
value: value,
|
|
31
|
+
formattedValue: (_valueFormatter = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter : "".concat(value),
|
|
29
32
|
offset: scale(value) - (scale.step() - scale.bandwidth()) / 2,
|
|
30
33
|
labelOffset: scale.step() / 2
|
|
31
34
|
};
|
|
@@ -37,23 +40,27 @@ function useTicks(options) {
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
// scale type = 'point'
|
|
40
|
-
|
|
43
|
+
var filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || _typeof(tickInterval) === 'object' && tickInterval || domain;
|
|
44
|
+
return filteredDomain.map(function (value) {
|
|
41
45
|
var _valueFormatter2;
|
|
42
46
|
return {
|
|
43
|
-
|
|
47
|
+
value: value,
|
|
48
|
+
formattedValue: (_valueFormatter2 = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter2 : "".concat(value),
|
|
44
49
|
offset: scale(value),
|
|
45
50
|
labelOffset: 0
|
|
46
51
|
};
|
|
47
52
|
});
|
|
48
53
|
}
|
|
49
|
-
|
|
54
|
+
var ticks = _typeof(tickInterval) === 'object' ? tickInterval : scale.ticks(tickNumber);
|
|
55
|
+
return ticks.map(function (value) {
|
|
50
56
|
var _valueFormatter3;
|
|
51
57
|
return {
|
|
52
|
-
|
|
58
|
+
value: value,
|
|
59
|
+
formattedValue: (_valueFormatter3 = valueFormatter == null ? void 0 : valueFormatter(value)) != null ? _valueFormatter3 : scale.tickFormat(tickNumber)(value),
|
|
53
60
|
offset: scale(value),
|
|
54
61
|
labelOffset: 0
|
|
55
62
|
};
|
|
56
63
|
});
|
|
57
|
-
}, [
|
|
64
|
+
}, [tickNumber, scale, valueFormatter, tickInterval]);
|
|
58
65
|
}
|
|
59
66
|
export default useTicks;
|
package/legacy/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts v6.
|
|
2
|
+
* @mui/x-charts v6.18.1
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -11,6 +11,7 @@ export * from './hooks';
|
|
|
11
11
|
export * from './colorPalettes';
|
|
12
12
|
export * from './models';
|
|
13
13
|
export * from './ChartsClipPath';
|
|
14
|
+
export * from './ChartsReferenceLine';
|
|
14
15
|
export * from './ChartsAxis';
|
|
15
16
|
export * from './ChartsXAxis';
|
|
16
17
|
export * from './ChartsYAxis';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
-
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
3
|
import { styled } from '@mui/material/styles';
|
|
5
4
|
import { axisClasses } from '../../ChartsAxis/axisClasses';
|
|
6
5
|
export var AxisRoot = styled('g', {
|
|
@@ -9,72 +8,19 @@ export var AxisRoot = styled('g', {
|
|
|
9
8
|
overridesResolver: function overridesResolver(props, styles) {
|
|
10
9
|
return styles.root;
|
|
11
10
|
}
|
|
12
|
-
})((_styled = {}, _defineProperty(_styled, "&.".concat(axisClasses.directionY), (_$concat = {}, _defineProperty(_$concat, ".".concat(axisClasses.tickLabel), {
|
|
13
|
-
dominantBaseline: 'middle'
|
|
14
|
-
}), _defineProperty(_$concat, ".".concat(axisClasses.label), {
|
|
15
|
-
dominantBaseline: 'auto',
|
|
16
|
-
textAnchor: 'middle'
|
|
17
|
-
}), _$concat)), _defineProperty(_styled, "&.".concat(axisClasses.left), _defineProperty({}, ".".concat(axisClasses.tickLabel), {
|
|
18
|
-
dominantBaseline: 'central',
|
|
19
|
-
textAnchor: 'end'
|
|
20
|
-
})), _defineProperty(_styled, "&.".concat(axisClasses.right), _defineProperty({}, ".".concat(axisClasses.tickLabel), {
|
|
21
|
-
dominantBaseline: 'central',
|
|
22
|
-
textAnchor: 'start'
|
|
23
|
-
})), _defineProperty(_styled, "&.".concat(axisClasses.bottom), _defineProperty({}, ".".concat(axisClasses.tickLabel, ", .").concat(axisClasses.label), {
|
|
24
|
-
dominantBaseline: 'hanging',
|
|
25
|
-
textAnchor: 'middle'
|
|
26
|
-
})), _defineProperty(_styled, "&.".concat(axisClasses.top), _defineProperty({}, ".".concat(axisClasses.tickLabel, ", .").concat(axisClasses.label), {
|
|
27
|
-
dominantBaseline: 'baseline',
|
|
28
|
-
textAnchor: 'middle'
|
|
29
|
-
})), _styled));
|
|
30
|
-
export var ChartsLine = styled('line', {
|
|
31
|
-
name: 'MuiChartsAxis',
|
|
32
|
-
slot: 'Line',
|
|
33
|
-
overridesResolver: function overridesResolver(props, styles) {
|
|
34
|
-
return styles.line;
|
|
35
|
-
}
|
|
36
11
|
})(function (_ref) {
|
|
12
|
+
var _ref2;
|
|
37
13
|
var theme = _ref.theme;
|
|
38
|
-
return {
|
|
39
|
-
|
|
14
|
+
return _ref2 = {}, _defineProperty(_ref2, "& .".concat(axisClasses.tickLabel), _extends({}, theme.typography.caption, {
|
|
15
|
+
fill: (theme.vars || theme).palette.text.primary
|
|
16
|
+
})), _defineProperty(_ref2, "& .".concat(axisClasses.label), _extends({}, theme.typography.body1, {
|
|
17
|
+
fill: (theme.vars || theme).palette.text.primary
|
|
18
|
+
})), _defineProperty(_ref2, "& .".concat(axisClasses.line), {
|
|
19
|
+
stroke: (theme.vars || theme).palette.text.primary,
|
|
40
20
|
shapeRendering: 'crispEdges',
|
|
41
21
|
strokeWidth: 1
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export var ChartsTick = styled('line', {
|
|
45
|
-
name: 'MuiChartsAxis',
|
|
46
|
-
slot: 'Tick',
|
|
47
|
-
overridesResolver: function overridesResolver(props, styles) {
|
|
48
|
-
return styles.tick;
|
|
49
|
-
}
|
|
50
|
-
})(function (_ref2) {
|
|
51
|
-
var theme = _ref2.theme;
|
|
52
|
-
return {
|
|
53
|
-
stroke: theme.palette.text.primary,
|
|
22
|
+
}), _defineProperty(_ref2, "& .".concat(axisClasses.tick), {
|
|
23
|
+
stroke: (theme.vars || theme).palette.text.primary,
|
|
54
24
|
shapeRendering: 'crispEdges'
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
export var ChartsTickLabel = styled('text', {
|
|
58
|
-
name: 'MuiChartsAxis',
|
|
59
|
-
slot: 'TickLabel',
|
|
60
|
-
overridesResolver: function overridesResolver(props, styles) {
|
|
61
|
-
return styles.tickLabel;
|
|
62
|
-
}
|
|
63
|
-
})(function (_ref3) {
|
|
64
|
-
var theme = _ref3.theme;
|
|
65
|
-
return _extends({}, theme.typography.caption, {
|
|
66
|
-
fill: theme.palette.text.primary
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
export var ChartsLabel = styled('text', {
|
|
70
|
-
name: 'MuiChartsAxis',
|
|
71
|
-
slot: 'Label',
|
|
72
|
-
overridesResolver: function overridesResolver(props, styles) {
|
|
73
|
-
return styles.label;
|
|
74
|
-
}
|
|
75
|
-
})(function (_ref4) {
|
|
76
|
-
var theme = _ref4.theme;
|
|
77
|
-
return _extends({}, theme.typography.body1, {
|
|
78
|
-
fill: theme.palette.text.primary
|
|
79
|
-
});
|
|
25
|
+
}), _ref2;
|
|
80
26
|
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
+
var _excluded = ["x", "y", "style", "text", "ownerState"],
|
|
4
|
+
_excluded2 = ["angle", "textAnchor", "dominantBaseline"];
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { getStringSize } from '../domUtils';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export function getWordsByLines(_ref) {
|
|
9
|
+
var style = _ref.style,
|
|
10
|
+
needsComputation = _ref.needsComputation,
|
|
11
|
+
text = _ref.text;
|
|
12
|
+
return text.split('\n').map(function (subText) {
|
|
13
|
+
return _extends({
|
|
14
|
+
text: subText
|
|
15
|
+
}, needsComputation ? getStringSize(subText, style) : {
|
|
16
|
+
width: 0,
|
|
17
|
+
height: 0
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function ChartsText(props) {
|
|
22
|
+
var x = props.x,
|
|
23
|
+
y = props.y,
|
|
24
|
+
styleProps = props.style,
|
|
25
|
+
text = props.text,
|
|
26
|
+
ownerState = props.ownerState,
|
|
27
|
+
textProps = _objectWithoutProperties(props, _excluded);
|
|
28
|
+
var _ref2 = styleProps != null ? styleProps : {},
|
|
29
|
+
angle = _ref2.angle,
|
|
30
|
+
textAnchor = _ref2.textAnchor,
|
|
31
|
+
dominantBaseline = _ref2.dominantBaseline,
|
|
32
|
+
style = _objectWithoutProperties(_ref2, _excluded2);
|
|
33
|
+
var wordsByLines = React.useMemo(function () {
|
|
34
|
+
return getWordsByLines({
|
|
35
|
+
style: style,
|
|
36
|
+
needsComputation: text.includes('\n'),
|
|
37
|
+
text: text
|
|
38
|
+
});
|
|
39
|
+
}, [style, text]);
|
|
40
|
+
var startDy;
|
|
41
|
+
switch (dominantBaseline) {
|
|
42
|
+
case 'hanging':
|
|
43
|
+
startDy = 0;
|
|
44
|
+
break;
|
|
45
|
+
case 'central':
|
|
46
|
+
startDy = (wordsByLines.length - 1) / 2 * -wordsByLines[0].height;
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
startDy = (wordsByLines.length - 1) * -wordsByLines[0].height;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
var transforms = [];
|
|
53
|
+
// if (scaleToFit) {
|
|
54
|
+
// const lineWidth = wordsByLines[0].width;
|
|
55
|
+
// transforms.push(`scale(${(isNumber(width as number) ? (width as number) / lineWidth : 1) / lineWidth})`);
|
|
56
|
+
// }
|
|
57
|
+
if (angle) {
|
|
58
|
+
transforms.push("rotate(".concat(angle, ", ").concat(x, ", ").concat(y, ")"));
|
|
59
|
+
}
|
|
60
|
+
if (transforms.length) {
|
|
61
|
+
textProps.transform = transforms.join(' ');
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/_jsx("text", _extends({}, textProps, {
|
|
64
|
+
x: x,
|
|
65
|
+
y: y,
|
|
66
|
+
textAnchor: textAnchor,
|
|
67
|
+
dominantBaseline: dominantBaseline,
|
|
68
|
+
style: style,
|
|
69
|
+
children: wordsByLines.map(function (line, index) {
|
|
70
|
+
return /*#__PURE__*/_jsx("tspan", {
|
|
71
|
+
x: x,
|
|
72
|
+
dy: "".concat(index === 0 ? startDy : wordsByLines[0].height, "px"),
|
|
73
|
+
dominantBaseline: dominantBaseline // Propagated to fix Safari issue: https://github.com/mui/mui-x/issues/10808
|
|
74
|
+
,
|
|
75
|
+
children: line.text
|
|
76
|
+
}, index);
|
|
77
|
+
})
|
|
78
|
+
}));
|
|
79
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
// DOM utils taken from
|
|
4
|
+
// https://github.com/recharts/recharts/blob/master/src/util/DOMUtils.ts
|
|
5
|
+
|
|
6
|
+
var isSsr = function isSsr() {
|
|
7
|
+
return !(typeof window !== 'undefined' && window.document && window.setTimeout);
|
|
8
|
+
};
|
|
9
|
+
var stringCache = {
|
|
10
|
+
widthCache: {},
|
|
11
|
+
cacheCount: 0
|
|
12
|
+
};
|
|
13
|
+
var MAX_CACHE_NUM = 2000;
|
|
14
|
+
var SPAN_STYLE = {
|
|
15
|
+
position: 'absolute',
|
|
16
|
+
top: '-20000px',
|
|
17
|
+
left: 0,
|
|
18
|
+
padding: 0,
|
|
19
|
+
margin: 0,
|
|
20
|
+
border: 'none',
|
|
21
|
+
whiteSpace: 'pre'
|
|
22
|
+
};
|
|
23
|
+
var STYLE_LIST = ['minWidth', 'maxWidth', 'width', 'minHeight', 'maxHeight', 'height', 'top', 'left', 'fontSize', 'padding', 'margin', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom'];
|
|
24
|
+
var MEASUREMENT_SPAN_ID = 'mui_measurement_span';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param name CSS property name
|
|
29
|
+
* @param value
|
|
30
|
+
* @returns add 'px' for distance properties
|
|
31
|
+
*/
|
|
32
|
+
function autoCompleteStyle(name, value) {
|
|
33
|
+
if (STYLE_LIST.indexOf(name) >= 0 && value === +value) {
|
|
34
|
+
return "".concat(value, "px");
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param text camelcase css property
|
|
42
|
+
* @returns css property
|
|
43
|
+
*/
|
|
44
|
+
function camelToMiddleLine(text) {
|
|
45
|
+
var strs = text.split('');
|
|
46
|
+
var formatStrs = strs.reduce(function (result, entry) {
|
|
47
|
+
if (entry === entry.toUpperCase()) {
|
|
48
|
+
return [].concat(_toConsumableArray(result), ['-', entry.toLowerCase()]);
|
|
49
|
+
}
|
|
50
|
+
return [].concat(_toConsumableArray(result), [entry]);
|
|
51
|
+
}, []);
|
|
52
|
+
return formatStrs.join('');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param style React style object
|
|
58
|
+
* @returns CSS styling string
|
|
59
|
+
*/
|
|
60
|
+
export var getStyleString = function getStyleString(style) {
|
|
61
|
+
return Object.keys(style).sort().reduce(function (result, s) {
|
|
62
|
+
return "".concat(result).concat(camelToMiddleLine(s), ":").concat(autoCompleteStyle(s, style[s]), ";");
|
|
63
|
+
}, '');
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param text The string to estimate
|
|
69
|
+
* @param style The style applied
|
|
70
|
+
* @returns width and height of the text
|
|
71
|
+
*/
|
|
72
|
+
export var getStringSize = function getStringSize(text) {
|
|
73
|
+
var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
74
|
+
if (text === undefined || text === null || isSsr()) {
|
|
75
|
+
return {
|
|
76
|
+
width: 0,
|
|
77
|
+
height: 0
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
var str = "".concat(text);
|
|
81
|
+
var styleString = getStyleString(style);
|
|
82
|
+
var cacheKey = "".concat(str, "-").concat(styleString);
|
|
83
|
+
if (stringCache.widthCache[cacheKey]) {
|
|
84
|
+
return stringCache.widthCache[cacheKey];
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
var measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
|
|
88
|
+
if (measurementSpan === null) {
|
|
89
|
+
measurementSpan = document.createElement('span');
|
|
90
|
+
measurementSpan.setAttribute('id', MEASUREMENT_SPAN_ID);
|
|
91
|
+
measurementSpan.setAttribute('aria-hidden', 'true');
|
|
92
|
+
document.body.appendChild(measurementSpan);
|
|
93
|
+
}
|
|
94
|
+
// Need to use CSS Object Model (CSSOM) to be able to comply with Content Security Policy (CSP)
|
|
95
|
+
// https://en.wikipedia.org/wiki/Content_Security_Policy
|
|
96
|
+
var measurementSpanStyle = _extends({}, SPAN_STYLE, style);
|
|
97
|
+
Object.keys(measurementSpanStyle).map(function (styleKey) {
|
|
98
|
+
measurementSpan.style[camelToMiddleLine(styleKey)] = autoCompleteStyle(styleKey, measurementSpanStyle[styleKey]);
|
|
99
|
+
return styleKey;
|
|
100
|
+
});
|
|
101
|
+
measurementSpan.textContent = str;
|
|
102
|
+
var rect = measurementSpan.getBoundingClientRect();
|
|
103
|
+
var result = {
|
|
104
|
+
width: rect.width,
|
|
105
|
+
height: rect.height
|
|
106
|
+
};
|
|
107
|
+
stringCache.widthCache[cacheKey] = result;
|
|
108
|
+
if (stringCache.cacheCount + 1 > MAX_CACHE_NUM) {
|
|
109
|
+
stringCache.cacheCount = 0;
|
|
110
|
+
stringCache.widthCache = {};
|
|
111
|
+
} else {
|
|
112
|
+
stringCache.cacheCount += 1;
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
} catch (e) {
|
|
116
|
+
return {
|
|
117
|
+
width: 0,
|
|
118
|
+
height: 0
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var ANGLE_APPROX = 5; // Angle (in deg) for which we approximate the rectangle as perfectly horizontal/vertical
|
|
2
|
+
|
|
3
|
+
var warnedOnce = false;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Return the minimal translation along the x-axis to avoid overflow of a rectangle of a given width, height, and rotation.
|
|
7
|
+
* This assumes that all rectangles have the same height and angle between -90 and 90.
|
|
8
|
+
* Otherwise it would be problematic because you need the height/width of the next rectangle to do the correct computation.
|
|
9
|
+
* @param width the side along the x-axis.
|
|
10
|
+
* @param height the side along the y-axis.
|
|
11
|
+
* @param angle the rotation in degrees.
|
|
12
|
+
*/
|
|
13
|
+
export function getMinXTranslation(width, height) {
|
|
14
|
+
var angle = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
15
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
16
|
+
if (!warnedOnce && angle > 90 && angle < -90) {
|
|
17
|
+
warnedOnce = true;
|
|
18
|
+
console.warn(["MUI X: It seems you applied an angle larger than 90\xB0 or smaller than -90\xB0 to an axis text.", "This could cause some text overlapping.", "If you encounter a use case where it's needed, please open an issue."].join('\n'));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
var standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
|
|
22
|
+
|
|
23
|
+
if (standardAngle < ANGLE_APPROX) {
|
|
24
|
+
// It's nearly horizontal
|
|
25
|
+
return width;
|
|
26
|
+
}
|
|
27
|
+
if (standardAngle > 90 - ANGLE_APPROX) {
|
|
28
|
+
// It's nearly vertical
|
|
29
|
+
return height;
|
|
30
|
+
}
|
|
31
|
+
var radAngle = standardAngle * Math.PI / 180;
|
|
32
|
+
var angleSwich = Math.atan2(height, width);
|
|
33
|
+
if (radAngle < angleSwich) {
|
|
34
|
+
return width / Math.cos(radAngle);
|
|
35
|
+
}
|
|
36
|
+
return height / Math.sin(radAngle);
|
|
37
|
+
}
|
package/models/axis.d.ts
CHANGED
|
@@ -2,25 +2,29 @@
|
|
|
2
2
|
import type { ScaleBand, ScaleLogarithmic, ScalePower, ScaleTime, ScaleLinear, ScalePoint } from 'd3-scale';
|
|
3
3
|
import { ChartsAxisClasses } from '../ChartsAxis/axisClasses';
|
|
4
4
|
import type { TickParams } from '../hooks/useTicks';
|
|
5
|
-
|
|
6
|
-
export type
|
|
5
|
+
import { ChartsTextProps } from '../internals/components/ChartsText';
|
|
6
|
+
export type D3Scale<Domain extends {
|
|
7
|
+
toString(): string;
|
|
8
|
+
} = number | Date | string, Range = number, Output = number> = ScaleBand<Domain> | ScaleLogarithmic<Range, Output> | ScalePoint<Domain> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
|
|
9
|
+
export type D3ContinuouseScale<Range = number, Output = number> = ScaleLogarithmic<Range, Output> | ScalePower<Range, Output> | ScaleTime<Range, Output> | ScaleLinear<Range, Output>;
|
|
7
10
|
export interface ChartsAxisSlotsComponent {
|
|
8
11
|
axisLine?: React.JSXElementConstructor<React.SVGAttributes<SVGPathElement>>;
|
|
9
12
|
axisTick?: React.JSXElementConstructor<React.SVGAttributes<SVGPathElement>>;
|
|
10
|
-
axisTickLabel?: React.JSXElementConstructor<
|
|
11
|
-
axisLabel?: React.JSXElementConstructor<
|
|
13
|
+
axisTickLabel?: React.JSXElementConstructor<ChartsTextProps>;
|
|
14
|
+
axisLabel?: React.JSXElementConstructor<ChartsTextProps>;
|
|
12
15
|
}
|
|
13
16
|
export interface ChartsAxisSlotComponentProps {
|
|
14
17
|
axisLine?: Partial<React.SVGAttributes<SVGPathElement>>;
|
|
15
18
|
axisTick?: Partial<React.SVGAttributes<SVGPathElement>>;
|
|
16
|
-
axisTickLabel?: Partial<
|
|
17
|
-
axisLabel?: Partial<
|
|
19
|
+
axisTickLabel?: Partial<ChartsTextProps>;
|
|
20
|
+
axisLabel?: Partial<ChartsTextProps>;
|
|
18
21
|
}
|
|
19
22
|
export interface ChartsAxisProps extends TickParams {
|
|
20
23
|
/**
|
|
21
|
-
*
|
|
24
|
+
* The id of the axis to render.
|
|
25
|
+
* If undefined, it will be the first defined axis.
|
|
22
26
|
*/
|
|
23
|
-
axisId
|
|
27
|
+
axisId?: string;
|
|
24
28
|
/**
|
|
25
29
|
* If true, the axis line is disabled.
|
|
26
30
|
* @default false
|
|
@@ -39,8 +43,24 @@ export interface ChartsAxisProps extends TickParams {
|
|
|
39
43
|
/**
|
|
40
44
|
* The font size of the axis ticks text.
|
|
41
45
|
* @default 12
|
|
46
|
+
* @deprecated Consider using `tickLabelStyle.fontSize` instead.
|
|
42
47
|
*/
|
|
43
48
|
tickFontSize?: number;
|
|
49
|
+
/**
|
|
50
|
+
* The style applied to ticks text.
|
|
51
|
+
*/
|
|
52
|
+
tickLabelStyle?: ChartsTextProps['style'];
|
|
53
|
+
/**
|
|
54
|
+
* The style applied to the axis label.
|
|
55
|
+
*/
|
|
56
|
+
labelStyle?: ChartsTextProps['style'];
|
|
57
|
+
/**
|
|
58
|
+
* Defines which ticks get its label displayed. Its value can be:
|
|
59
|
+
* - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
|
|
60
|
+
* - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
|
|
61
|
+
* @default 'auto'
|
|
62
|
+
*/
|
|
63
|
+
tickLabelInterval?: 'auto' | ((value: any, index: number) => boolean);
|
|
44
64
|
/**
|
|
45
65
|
* The label of the axis.
|
|
46
66
|
*/
|
|
@@ -48,6 +68,7 @@ export interface ChartsAxisProps extends TickParams {
|
|
|
48
68
|
/**
|
|
49
69
|
* The font size of the axis label.
|
|
50
70
|
* @default 14
|
|
71
|
+
* @deprecated Consider using `labelStyle.fontSize` instead.
|
|
51
72
|
*/
|
|
52
73
|
labelFontSize?: number;
|
|
53
74
|
/**
|
|
@@ -92,56 +113,70 @@ export type ContinuouseScaleName = 'linear' | 'log' | 'pow' | 'sqrt' | 'time' |
|
|
|
92
113
|
interface AxisScaleConfig {
|
|
93
114
|
band: {
|
|
94
115
|
scaleType: 'band';
|
|
95
|
-
scale: ScaleBand<
|
|
116
|
+
scale: ScaleBand<number | Date | string>;
|
|
96
117
|
/**
|
|
97
118
|
* The ratio between the space allocated for padding between two categories and the category width.
|
|
98
119
|
* 0 means no gap, and 1 no data.
|
|
99
|
-
* @default 0.
|
|
120
|
+
* @default 0.2
|
|
100
121
|
*/
|
|
101
122
|
categoryGapRatio: number;
|
|
102
123
|
/**
|
|
103
124
|
* The ratio between the width of a bar, and the gap between two bars.
|
|
104
125
|
* 0 means no gap, and 1 no bar.
|
|
105
|
-
* @default 0
|
|
126
|
+
* @default 0.1
|
|
106
127
|
*/
|
|
107
128
|
barGapRatio: number;
|
|
108
129
|
};
|
|
109
130
|
point: {
|
|
110
131
|
scaleType: 'point';
|
|
111
|
-
scale: ScalePoint<
|
|
132
|
+
scale: ScalePoint<number | Date | string>;
|
|
112
133
|
};
|
|
113
134
|
log: {
|
|
114
135
|
scaleType: 'log';
|
|
115
|
-
scale: ScaleLogarithmic<
|
|
136
|
+
scale: ScaleLogarithmic<number, number>;
|
|
116
137
|
};
|
|
117
138
|
pow: {
|
|
118
139
|
scaleType: 'pow';
|
|
119
|
-
scale: ScalePower<
|
|
140
|
+
scale: ScalePower<number, number>;
|
|
120
141
|
};
|
|
121
142
|
sqrt: {
|
|
122
143
|
scaleType: 'sqrt';
|
|
123
|
-
scale: ScalePower<
|
|
144
|
+
scale: ScalePower<number, number>;
|
|
124
145
|
};
|
|
125
146
|
time: {
|
|
126
147
|
scaleType: 'time';
|
|
127
|
-
scale: ScaleTime<
|
|
148
|
+
scale: ScaleTime<number, number>;
|
|
128
149
|
};
|
|
129
150
|
utc: {
|
|
130
151
|
scaleType: 'utc';
|
|
131
|
-
scale: ScaleTime<
|
|
152
|
+
scale: ScaleTime<number, number>;
|
|
132
153
|
};
|
|
133
154
|
linear: {
|
|
134
155
|
scaleType: 'linear';
|
|
135
|
-
scale: ScaleLinear<
|
|
156
|
+
scale: ScaleLinear<number, number>;
|
|
136
157
|
};
|
|
137
158
|
}
|
|
138
159
|
export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
|
|
160
|
+
/**
|
|
161
|
+
* Id used to identify the axis.
|
|
162
|
+
*/
|
|
139
163
|
id: string;
|
|
164
|
+
/**
|
|
165
|
+
* The minimal value of the domain.
|
|
166
|
+
* If not provided, it gets computed to display the entire chart data.
|
|
167
|
+
*/
|
|
140
168
|
min?: number | Date;
|
|
169
|
+
/**
|
|
170
|
+
* The maximal value of the domain.
|
|
171
|
+
* If not provided, it gets computed to display the entire chart data.
|
|
172
|
+
*/
|
|
141
173
|
max?: number | Date;
|
|
174
|
+
/**
|
|
175
|
+
* The data used by `'band'` and `'point'` scales.
|
|
176
|
+
*/
|
|
142
177
|
data?: V[];
|
|
143
178
|
/**
|
|
144
|
-
* The key used to retrieve data from the dataset prop.
|
|
179
|
+
* The key used to retrieve `data` from the `dataset` prop.
|
|
145
180
|
*/
|
|
146
181
|
dataKey?: string;
|
|
147
182
|
valueFormatter?: (value: V) => string;
|
|
@@ -151,7 +186,10 @@ export type AxisConfig<S extends ScaleName = ScaleName, V = any> = {
|
|
|
151
186
|
hideTooltip?: boolean;
|
|
152
187
|
} & Partial<ChartsXAxisProps | ChartsYAxisProps> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & TickParams;
|
|
153
188
|
export type AxisDefaultized<S extends ScaleName = ScaleName, V = any> = Omit<AxisConfig<S, V>, 'scaleType'> & AxisScaleConfig[S] & {
|
|
154
|
-
|
|
189
|
+
/**
|
|
190
|
+
* An indication of the expected number of ticks.
|
|
191
|
+
*/
|
|
192
|
+
tickNumber: number;
|
|
155
193
|
};
|
|
156
194
|
export declare function isBandScaleConfig(scaleConfig: AxisConfig<ScaleName>): scaleConfig is AxisConfig<'band'> & {
|
|
157
195
|
scaleType: 'band';
|
package/models/layout.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
export interface CardinalDirections<T> {
|
|
2
|
+
top?: T;
|
|
3
|
+
bottom?: T;
|
|
4
|
+
left?: T;
|
|
5
|
+
right?: T;
|
|
6
|
+
}
|
|
1
7
|
export type LayoutConfig = {
|
|
2
8
|
width: number;
|
|
3
9
|
height: number;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The margin between the SVG and the drawing area.
|
|
12
|
+
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
13
|
+
* Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
|
|
14
|
+
* @default object Depends on the charts type.
|
|
15
|
+
*/
|
|
16
|
+
margin?: Partial<CardinalDirections<number>>;
|
|
10
17
|
};
|
|
@@ -13,12 +13,28 @@ export type CommonSeriesType<TValue> = {
|
|
|
13
13
|
};
|
|
14
14
|
export type CommonDefaultizedProps = 'id' | 'valueFormatter' | 'data';
|
|
15
15
|
export type CartesianSeriesType = {
|
|
16
|
+
/**
|
|
17
|
+
* The id of the x-axis used to render the series.
|
|
18
|
+
*/
|
|
16
19
|
xAxisKey?: string;
|
|
20
|
+
/**
|
|
21
|
+
* The id of the y-axis used to render the series.
|
|
22
|
+
*/
|
|
17
23
|
yAxisKey?: string;
|
|
18
24
|
};
|
|
19
25
|
export type StackableSeriesType = {
|
|
26
|
+
/**
|
|
27
|
+
* The key that identifies the stacking group.
|
|
28
|
+
* Series with the same `stack` property will be stacked together.
|
|
29
|
+
*/
|
|
20
30
|
stack?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Defines how stacked series handle negative values.
|
|
33
|
+
*/
|
|
21
34
|
stackOffset?: StackOffsetType;
|
|
35
|
+
/**
|
|
36
|
+
* The order in which series' of the same group are stacked together.
|
|
37
|
+
*/
|
|
22
38
|
stackOrder?: StackOrderType;
|
|
23
39
|
};
|
|
24
40
|
export type StackOrderType = keyof typeof StackOrder;
|