@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
package/hooks/useTicks.js
CHANGED
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
exports.
|
|
7
|
+
exports.getTickNumber = getTickNumber;
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _isBandScale = require("../internals/isBandScale");
|
|
10
|
-
function _getRequireWildcardCache(
|
|
11
|
-
function _interopRequireWildcard(
|
|
12
|
-
function
|
|
10
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && 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; }
|
|
12
|
+
function getTickNumber(params) {
|
|
13
13
|
const {
|
|
14
14
|
tickMaxStep,
|
|
15
15
|
tickMinStep,
|
|
@@ -25,8 +25,9 @@ function getTicksNumber(params) {
|
|
|
25
25
|
function useTicks(options) {
|
|
26
26
|
const {
|
|
27
27
|
scale,
|
|
28
|
-
|
|
29
|
-
valueFormatter
|
|
28
|
+
tickNumber,
|
|
29
|
+
valueFormatter,
|
|
30
|
+
tickInterval
|
|
30
31
|
} = options;
|
|
31
32
|
return React.useMemo(() => {
|
|
32
33
|
// band scale
|
|
@@ -35,7 +36,8 @@ function useTicks(options) {
|
|
|
35
36
|
if (scale.bandwidth() > 0) {
|
|
36
37
|
// scale type = 'band'
|
|
37
38
|
return [...domain.map(value => ({
|
|
38
|
-
|
|
39
|
+
value,
|
|
40
|
+
formattedValue: valueFormatter?.(value) ?? `${value}`,
|
|
39
41
|
offset: scale(value) - (scale.step() - scale.bandwidth()) / 2,
|
|
40
42
|
labelOffset: scale.step() / 2
|
|
41
43
|
})), {
|
|
@@ -46,18 +48,21 @@ function useTicks(options) {
|
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
// scale type = 'point'
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
|
|
52
|
+
return filteredDomain.map(value => ({
|
|
53
|
+
value,
|
|
54
|
+
formattedValue: valueFormatter?.(value) ?? `${value}`,
|
|
51
55
|
offset: scale(value),
|
|
52
56
|
labelOffset: 0
|
|
53
57
|
}));
|
|
54
58
|
}
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
|
|
60
|
+
return ticks.map(value => ({
|
|
61
|
+
value,
|
|
62
|
+
formattedValue: valueFormatter?.(value) ?? scale.tickFormat(tickNumber)(value),
|
|
57
63
|
offset: scale(value),
|
|
58
64
|
labelOffset: 0
|
|
59
65
|
}));
|
|
60
|
-
}, [
|
|
66
|
+
}, [tickNumber, scale, valueFormatter, tickInterval]);
|
|
61
67
|
}
|
|
62
|
-
var _default = useTicks;
|
|
63
|
-
exports.default = _default;
|
|
68
|
+
var _default = exports.default = useTicks;
|
package/index.d.ts
CHANGED
package/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
|
|
@@ -76,6 +76,17 @@ Object.keys(_ChartsClipPath).forEach(function (key) {
|
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
});
|
|
79
|
+
var _ChartsReferenceLine = require("./ChartsReferenceLine");
|
|
80
|
+
Object.keys(_ChartsReferenceLine).forEach(function (key) {
|
|
81
|
+
if (key === "default" || key === "__esModule") return;
|
|
82
|
+
if (key in exports && exports[key] === _ChartsReferenceLine[key]) return;
|
|
83
|
+
Object.defineProperty(exports, key, {
|
|
84
|
+
enumerable: true,
|
|
85
|
+
get: function () {
|
|
86
|
+
return _ChartsReferenceLine[key];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
79
90
|
var _ChartsAxis = require("./ChartsAxis");
|
|
80
91
|
Object.keys(_ChartsAxis).forEach(function (key) {
|
|
81
92
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const AxisRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, {}>;
|
|
3
|
-
export declare const ChartsLine: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGLineElementAttributes<SVGLineElement>, keyof import("react").SVGLineElementAttributes<SVGLineElement>>, {}>;
|
|
4
|
-
export declare const ChartsTick: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGLineElementAttributes<SVGLineElement>, keyof import("react").SVGLineElementAttributes<SVGLineElement>>, {}>;
|
|
5
|
-
export declare const ChartsTickLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGTextElementAttributes<SVGTextElement>, keyof import("react").SVGTextElementAttributes<SVGTextElement>>, {}>;
|
|
6
|
-
export declare const ChartsLabel: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGTextElementAttributes<SVGTextElement>, keyof import("react").SVGTextElementAttributes<SVGTextElement>>, {}>;
|
|
@@ -4,90 +4,30 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.AxisRoot = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _styles = require("@mui/material/styles");
|
|
10
10
|
var _axisClasses = require("../../ChartsAxis/axisClasses");
|
|
11
|
-
const AxisRoot = (0, _styles.styled)('g', {
|
|
11
|
+
const AxisRoot = exports.AxisRoot = (0, _styles.styled)('g', {
|
|
12
12
|
name: 'MuiChartsAxis',
|
|
13
13
|
slot: 'Root',
|
|
14
14
|
overridesResolver: (props, styles) => styles.root
|
|
15
|
-
})({
|
|
16
|
-
[`&.${_axisClasses.axisClasses.directionY}`]: {
|
|
17
|
-
[`.${_axisClasses.axisClasses.tickLabel}`]: {
|
|
18
|
-
dominantBaseline: 'middle'
|
|
19
|
-
},
|
|
20
|
-
[`.${_axisClasses.axisClasses.label}`]: {
|
|
21
|
-
dominantBaseline: 'auto',
|
|
22
|
-
textAnchor: 'middle'
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
[`&.${_axisClasses.axisClasses.left}`]: {
|
|
26
|
-
[`.${_axisClasses.axisClasses.tickLabel}`]: {
|
|
27
|
-
dominantBaseline: 'central',
|
|
28
|
-
textAnchor: 'end'
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
[`&.${_axisClasses.axisClasses.right}`]: {
|
|
32
|
-
[`.${_axisClasses.axisClasses.tickLabel}`]: {
|
|
33
|
-
dominantBaseline: 'central',
|
|
34
|
-
textAnchor: 'start'
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
[`&.${_axisClasses.axisClasses.bottom}`]: {
|
|
38
|
-
[`.${_axisClasses.axisClasses.tickLabel}, .${_axisClasses.axisClasses.label}`]: {
|
|
39
|
-
dominantBaseline: 'hanging',
|
|
40
|
-
textAnchor: 'middle'
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
[`&.${_axisClasses.axisClasses.top}`]: {
|
|
44
|
-
[`.${_axisClasses.axisClasses.tickLabel}, .${_axisClasses.axisClasses.label}`]: {
|
|
45
|
-
dominantBaseline: 'baseline',
|
|
46
|
-
textAnchor: 'middle'
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
exports.AxisRoot = AxisRoot;
|
|
51
|
-
const ChartsLine = (0, _styles.styled)('line', {
|
|
52
|
-
name: 'MuiChartsAxis',
|
|
53
|
-
slot: 'Line',
|
|
54
|
-
overridesResolver: (props, styles) => styles.line
|
|
55
15
|
})(({
|
|
56
16
|
theme
|
|
57
17
|
}) => ({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const ChartsTickLabel = (0, _styles.styled)('text', {
|
|
75
|
-
name: 'MuiChartsAxis',
|
|
76
|
-
slot: 'TickLabel',
|
|
77
|
-
overridesResolver: (props, styles) => styles.tickLabel
|
|
78
|
-
})(({
|
|
79
|
-
theme
|
|
80
|
-
}) => (0, _extends2.default)({}, theme.typography.caption, {
|
|
81
|
-
fill: theme.palette.text.primary
|
|
82
|
-
}));
|
|
83
|
-
exports.ChartsTickLabel = ChartsTickLabel;
|
|
84
|
-
const ChartsLabel = (0, _styles.styled)('text', {
|
|
85
|
-
name: 'MuiChartsAxis',
|
|
86
|
-
slot: 'Label',
|
|
87
|
-
overridesResolver: (props, styles) => styles.label
|
|
88
|
-
})(({
|
|
89
|
-
theme
|
|
90
|
-
}) => (0, _extends2.default)({}, theme.typography.body1, {
|
|
91
|
-
fill: theme.palette.text.primary
|
|
92
|
-
}));
|
|
93
|
-
exports.ChartsLabel = ChartsLabel;
|
|
18
|
+
[`& .${_axisClasses.axisClasses.tickLabel}`]: (0, _extends2.default)({}, theme.typography.caption, {
|
|
19
|
+
fill: (theme.vars || theme).palette.text.primary
|
|
20
|
+
}),
|
|
21
|
+
[`& .${_axisClasses.axisClasses.label}`]: (0, _extends2.default)({}, theme.typography.body1, {
|
|
22
|
+
fill: (theme.vars || theme).palette.text.primary
|
|
23
|
+
}),
|
|
24
|
+
[`& .${_axisClasses.axisClasses.line}`]: {
|
|
25
|
+
stroke: (theme.vars || theme).palette.text.primary,
|
|
26
|
+
shapeRendering: 'crispEdges',
|
|
27
|
+
strokeWidth: 1
|
|
28
|
+
},
|
|
29
|
+
[`& .${_axisClasses.axisClasses.tick}`]: {
|
|
30
|
+
stroke: (theme.vars || theme).palette.text.primary,
|
|
31
|
+
shapeRendering: 'crispEdges'
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type ChartsTextBaseline = 'hanging' | 'central' | 'auto';
|
|
3
|
+
export interface ChartsTextStyle extends React.CSSProperties {
|
|
4
|
+
angle?: number;
|
|
5
|
+
/**
|
|
6
|
+
* The text baseline
|
|
7
|
+
* @default 'central'
|
|
8
|
+
*/
|
|
9
|
+
dominantBaseline?: ChartsTextBaseline;
|
|
10
|
+
}
|
|
11
|
+
interface GetWordsByLinesParams {
|
|
12
|
+
/**
|
|
13
|
+
* Text displayed.
|
|
14
|
+
*/
|
|
15
|
+
text: string;
|
|
16
|
+
/**
|
|
17
|
+
* Style applied to text elements.
|
|
18
|
+
*/
|
|
19
|
+
style?: ChartsTextStyle;
|
|
20
|
+
/**
|
|
21
|
+
* If `true`, the line width is computed.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
needsComputation?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ChartsTextProps extends Omit<React.SVGTextElementAttributes<SVGTextElement>, 'width' | 'ref' | 'style' | 'dominantBaseline'>, GetWordsByLinesParams {
|
|
27
|
+
/**
|
|
28
|
+
* Height of a text line (in `em`).
|
|
29
|
+
*/
|
|
30
|
+
lineHeight?: number;
|
|
31
|
+
ownerState?: any;
|
|
32
|
+
}
|
|
33
|
+
export declare function getWordsByLines({ style, needsComputation, text }: GetWordsByLinesParams): any[];
|
|
34
|
+
export declare function ChartsText(props: ChartsTextProps): React.JSX.Element;
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ChartsText = ChartsText;
|
|
8
|
+
exports.getWordsByLines = getWordsByLines;
|
|
9
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _domUtils = require("../domUtils");
|
|
13
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
+
const _excluded = ["x", "y", "style", "text", "ownerState"],
|
|
15
|
+
_excluded2 = ["angle", "textAnchor", "dominantBaseline"];
|
|
16
|
+
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); }
|
|
17
|
+
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; }
|
|
18
|
+
function getWordsByLines({
|
|
19
|
+
style,
|
|
20
|
+
needsComputation,
|
|
21
|
+
text
|
|
22
|
+
}) {
|
|
23
|
+
return text.split('\n').map(subText => (0, _extends2.default)({
|
|
24
|
+
text: subText
|
|
25
|
+
}, needsComputation ? (0, _domUtils.getStringSize)(subText, style) : {
|
|
26
|
+
width: 0,
|
|
27
|
+
height: 0
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
function ChartsText(props) {
|
|
31
|
+
const {
|
|
32
|
+
x,
|
|
33
|
+
y,
|
|
34
|
+
style: styleProps,
|
|
35
|
+
text
|
|
36
|
+
} = props,
|
|
37
|
+
textProps = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
38
|
+
const _ref = styleProps ?? {},
|
|
39
|
+
{
|
|
40
|
+
angle,
|
|
41
|
+
textAnchor,
|
|
42
|
+
dominantBaseline
|
|
43
|
+
} = _ref,
|
|
44
|
+
style = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded2);
|
|
45
|
+
const wordsByLines = React.useMemo(() => getWordsByLines({
|
|
46
|
+
style,
|
|
47
|
+
needsComputation: text.includes('\n'),
|
|
48
|
+
text
|
|
49
|
+
}), [style, text]);
|
|
50
|
+
let startDy;
|
|
51
|
+
switch (dominantBaseline) {
|
|
52
|
+
case 'hanging':
|
|
53
|
+
startDy = 0;
|
|
54
|
+
break;
|
|
55
|
+
case 'central':
|
|
56
|
+
startDy = (wordsByLines.length - 1) / 2 * -wordsByLines[0].height;
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
startDy = (wordsByLines.length - 1) * -wordsByLines[0].height;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
const transforms = [];
|
|
63
|
+
// if (scaleToFit) {
|
|
64
|
+
// const lineWidth = wordsByLines[0].width;
|
|
65
|
+
// transforms.push(`scale(${(isNumber(width as number) ? (width as number) / lineWidth : 1) / lineWidth})`);
|
|
66
|
+
// }
|
|
67
|
+
if (angle) {
|
|
68
|
+
transforms.push(`rotate(${angle}, ${x}, ${y})`);
|
|
69
|
+
}
|
|
70
|
+
if (transforms.length) {
|
|
71
|
+
textProps.transform = transforms.join(' ');
|
|
72
|
+
}
|
|
73
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("text", (0, _extends2.default)({}, textProps, {
|
|
74
|
+
x: x,
|
|
75
|
+
y: y,
|
|
76
|
+
textAnchor: textAnchor,
|
|
77
|
+
dominantBaseline: dominantBaseline,
|
|
78
|
+
style: style,
|
|
79
|
+
children: wordsByLines.map((line, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("tspan", {
|
|
80
|
+
x: x,
|
|
81
|
+
dy: `${index === 0 ? startDy : wordsByLines[0].height}px`,
|
|
82
|
+
dominantBaseline: dominantBaseline // Propagated to fix Safari issue: https://github.com/mui/mui-x/issues/10808
|
|
83
|
+
,
|
|
84
|
+
children: line.text
|
|
85
|
+
}, index))
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
@@ -23,12 +23,16 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
|
|
|
23
23
|
innerRadius?: number | undefined;
|
|
24
24
|
outerRadius?: number | undefined;
|
|
25
25
|
cornerRadius?: number | undefined;
|
|
26
|
+
paddingAngle?: number | undefined;
|
|
27
|
+
color?: string | undefined;
|
|
26
28
|
} | undefined;
|
|
27
29
|
faded?: {
|
|
28
30
|
additionalRadius?: number | undefined;
|
|
29
31
|
innerRadius?: number | undefined;
|
|
30
32
|
outerRadius?: number | undefined;
|
|
31
33
|
cornerRadius?: number | undefined;
|
|
34
|
+
paddingAngle?: number | undefined;
|
|
35
|
+
color?: string | undefined;
|
|
32
36
|
} | undefined;
|
|
33
37
|
id?: string | undefined;
|
|
34
38
|
color?: string | undefined;
|
|
@@ -51,14 +55,15 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
|
|
|
51
55
|
stackOrder?: "reverse" | "none" | "appearance" | "ascending" | "descending" | "insideOut" | undefined;
|
|
52
56
|
} | {
|
|
53
57
|
type: "line";
|
|
54
|
-
data?: number[] | undefined;
|
|
58
|
+
data?: (number | null)[] | undefined;
|
|
55
59
|
dataKey?: string | undefined;
|
|
56
60
|
stack?: string | undefined;
|
|
57
61
|
area?: boolean | undefined;
|
|
58
62
|
label?: string | undefined;
|
|
59
63
|
curve?: import("../models/seriesType").CurveType | undefined;
|
|
60
|
-
showMark?: boolean | ((params: import("../models/seriesType").ShowMarkParams) => boolean) | undefined;
|
|
64
|
+
showMark?: boolean | ((params: import("../models/seriesType").ShowMarkParams<number | Date>) => boolean) | undefined;
|
|
61
65
|
disableHighlight?: boolean | undefined;
|
|
66
|
+
connectNulls?: boolean | undefined;
|
|
62
67
|
id?: string | undefined;
|
|
63
68
|
color: string;
|
|
64
69
|
valueFormatter?: ((value: number) => string) | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param style React style object
|
|
4
|
+
* @returns CSS styling string
|
|
5
|
+
*/
|
|
6
|
+
export declare const getStyleString: (style: React.CSSProperties) => string;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param text The string to estimate
|
|
10
|
+
* @param style The style applied
|
|
11
|
+
* @returns width and height of the text
|
|
12
|
+
*/
|
|
13
|
+
export declare const getStringSize: (text: string | number, style?: React.CSSProperties) => any;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getStyleString = exports.getStringSize = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
// DOM utils taken from
|
|
10
|
+
// https://github.com/recharts/recharts/blob/master/src/util/DOMUtils.ts
|
|
11
|
+
|
|
12
|
+
const isSsr = () => !(typeof window !== 'undefined' && window.document && window.setTimeout);
|
|
13
|
+
const stringCache = {
|
|
14
|
+
widthCache: {},
|
|
15
|
+
cacheCount: 0
|
|
16
|
+
};
|
|
17
|
+
const MAX_CACHE_NUM = 2000;
|
|
18
|
+
const SPAN_STYLE = {
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
top: '-20000px',
|
|
21
|
+
left: 0,
|
|
22
|
+
padding: 0,
|
|
23
|
+
margin: 0,
|
|
24
|
+
border: 'none',
|
|
25
|
+
whiteSpace: 'pre'
|
|
26
|
+
};
|
|
27
|
+
const STYLE_LIST = ['minWidth', 'maxWidth', 'width', 'minHeight', 'maxHeight', 'height', 'top', 'left', 'fontSize', 'padding', 'margin', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom'];
|
|
28
|
+
const MEASUREMENT_SPAN_ID = 'mui_measurement_span';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param name CSS property name
|
|
33
|
+
* @param value
|
|
34
|
+
* @returns add 'px' for distance properties
|
|
35
|
+
*/
|
|
36
|
+
function autoCompleteStyle(name, value) {
|
|
37
|
+
if (STYLE_LIST.indexOf(name) >= 0 && value === +value) {
|
|
38
|
+
return `${value}px`;
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param text camelcase css property
|
|
46
|
+
* @returns css property
|
|
47
|
+
*/
|
|
48
|
+
function camelToMiddleLine(text) {
|
|
49
|
+
const strs = text.split('');
|
|
50
|
+
const formatStrs = strs.reduce((result, entry) => {
|
|
51
|
+
if (entry === entry.toUpperCase()) {
|
|
52
|
+
return [...result, '-', entry.toLowerCase()];
|
|
53
|
+
}
|
|
54
|
+
return [...result, entry];
|
|
55
|
+
}, []);
|
|
56
|
+
return formatStrs.join('');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param style React style object
|
|
62
|
+
* @returns CSS styling string
|
|
63
|
+
*/
|
|
64
|
+
const getStyleString = style => Object.keys(style).sort().reduce((result, s) => `${result}${camelToMiddleLine(s)}:${autoCompleteStyle(s, style[s])};`, '');
|
|
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
|
+
exports.getStyleString = getStyleString;
|
|
73
|
+
const getStringSize = (text, style = {}) => {
|
|
74
|
+
if (text === undefined || text === null || isSsr()) {
|
|
75
|
+
return {
|
|
76
|
+
width: 0,
|
|
77
|
+
height: 0
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const str = `${text}`;
|
|
81
|
+
const styleString = getStyleString(style);
|
|
82
|
+
const cacheKey = `${str}-${styleString}`;
|
|
83
|
+
if (stringCache.widthCache[cacheKey]) {
|
|
84
|
+
return stringCache.widthCache[cacheKey];
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
let 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
|
+
const measurementSpanStyle = (0, _extends2.default)({}, SPAN_STYLE, style);
|
|
97
|
+
Object.keys(measurementSpanStyle).map(styleKey => {
|
|
98
|
+
measurementSpan.style[camelToMiddleLine(styleKey)] = autoCompleteStyle(styleKey, measurementSpanStyle[styleKey]);
|
|
99
|
+
return styleKey;
|
|
100
|
+
});
|
|
101
|
+
measurementSpan.textContent = str;
|
|
102
|
+
const rect = measurementSpan.getBoundingClientRect();
|
|
103
|
+
const 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
|
+
};
|
|
122
|
+
exports.getStringSize = getStringSize;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the minimal translation along the x-axis to avoid overflow of a rectangle of a given width, height, and rotation.
|
|
3
|
+
* This assumes that all rectangles have the same height and angle between -90 and 90.
|
|
4
|
+
* Otherwise it would be problematic because you need the height/width of the next rectangle to do the correct computation.
|
|
5
|
+
* @param width the side along the x-axis.
|
|
6
|
+
* @param height the side along the y-axis.
|
|
7
|
+
* @param angle the rotation in degrees.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getMinXTranslation(width: number, height: number, angle?: number): number;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getMinXTranslation = getMinXTranslation;
|
|
7
|
+
const ANGLE_APPROX = 5; // Angle (in deg) for which we approximate the rectangle as perfectly horizontal/vertical
|
|
8
|
+
|
|
9
|
+
let warnedOnce = false;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Return the minimal translation along the x-axis to avoid overflow of a rectangle of a given width, height, and rotation.
|
|
13
|
+
* This assumes that all rectangles have the same height and angle between -90 and 90.
|
|
14
|
+
* Otherwise it would be problematic because you need the height/width of the next rectangle to do the correct computation.
|
|
15
|
+
* @param width the side along the x-axis.
|
|
16
|
+
* @param height the side along the y-axis.
|
|
17
|
+
* @param angle the rotation in degrees.
|
|
18
|
+
*/
|
|
19
|
+
function getMinXTranslation(width, height, angle = 0) {
|
|
20
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
21
|
+
if (!warnedOnce && angle > 90 && angle < -90) {
|
|
22
|
+
warnedOnce = true;
|
|
23
|
+
console.warn([`MUI X: It seems you applied an angle larger than 90° or smaller than -90° 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'));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
|
|
27
|
+
|
|
28
|
+
if (standardAngle < ANGLE_APPROX) {
|
|
29
|
+
// It's nearly horizontal
|
|
30
|
+
return width;
|
|
31
|
+
}
|
|
32
|
+
if (standardAngle > 90 - ANGLE_APPROX) {
|
|
33
|
+
// It's nearly vertical
|
|
34
|
+
return height;
|
|
35
|
+
}
|
|
36
|
+
const radAngle = standardAngle * Math.PI / 180;
|
|
37
|
+
const angleSwich = Math.atan2(height, width);
|
|
38
|
+
if (radAngle < angleSwich) {
|
|
39
|
+
return width / Math.cos(radAngle);
|
|
40
|
+
}
|
|
41
|
+
return height / Math.sin(radAngle);
|
|
42
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { ScaleBand, ScalePoint } from 'd3-scale';
|
|
2
2
|
import { D3Scale } from '../models/axis';
|
|
3
|
-
export declare function isBandScale
|
|
3
|
+
export declare function isBandScale<T extends {
|
|
4
|
+
toString(): string;
|
|
5
|
+
}>(scale: D3Scale<T>): scale is ScaleBand<T> | ScalePoint<T>;
|
package/internals/stackSeries.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getStackingGroups = exports.StackOrder = exports.StackOffset = void 0;
|
|
7
7
|
var _d3Shape = require("d3-shape");
|
|
8
|
-
const StackOrder = {
|
|
8
|
+
const StackOrder = exports.StackOrder = {
|
|
9
9
|
/**
|
|
10
10
|
* Series order such that the earliest series (according to the maximum value) is at the bottom.
|
|
11
11
|
* */
|
|
@@ -31,8 +31,7 @@ const StackOrder = {
|
|
|
31
31
|
*/
|
|
32
32
|
reverse: _d3Shape.stackOrderReverse
|
|
33
33
|
};
|
|
34
|
-
exports.
|
|
35
|
-
const StackOffset = {
|
|
34
|
+
const StackOffset = exports.StackOffset = {
|
|
36
35
|
/**
|
|
37
36
|
* Applies a zero baseline and normalizes the values for each point such that the topline is always one.
|
|
38
37
|
* */
|
|
@@ -60,7 +59,6 @@ const StackOffset = {
|
|
|
60
59
|
* @param series the object of all bars series
|
|
61
60
|
* @returns an array of groups, including the ids, the stacking order, and the stacking offset.
|
|
62
61
|
*/
|
|
63
|
-
exports.StackOffset = StackOffset;
|
|
64
62
|
const getStackingGroups = params => {
|
|
65
63
|
const {
|
|
66
64
|
series,
|
package/internals/utils.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
export type SymbolsTypes = 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye';
|
|
2
2
|
export declare function getSymbol(shape: SymbolsTypes): number;
|
|
3
|
+
type Without<T, U> = {
|
|
4
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
5
|
+
};
|
|
6
|
+
export type XOR<T, U> = T | U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : T | U;
|
|
7
|
+
export {};
|