@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
|
@@ -9,17 +9,21 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _utils = require("@mui/utils");
|
|
12
|
+
var _utils = require("@mui/base/utils");
|
|
13
|
+
var _utils2 = require("@mui/utils");
|
|
13
14
|
var _styles = require("@mui/material/styles");
|
|
14
15
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
15
16
|
var _DrawingProvider = require("../context/DrawingProvider");
|
|
16
17
|
var _useTicks = _interopRequireDefault(require("../hooks/useTicks"));
|
|
17
18
|
var _axisClasses = require("../ChartsAxis/axisClasses");
|
|
18
19
|
var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
|
|
20
|
+
var _ChartsText = require("../internals/components/ChartsText");
|
|
21
|
+
var _geometry = require("../internals/geometry");
|
|
22
|
+
var _useMounted = require("../hooks/useMounted");
|
|
19
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
const _excluded = ["scale", "
|
|
21
|
-
function _getRequireWildcardCache(
|
|
22
|
-
function _interopRequireWildcard(
|
|
24
|
+
const _excluded = ["scale", "tickNumber"];
|
|
25
|
+
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); }
|
|
26
|
+
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; }
|
|
23
27
|
const useUtilityClasses = ownerState => {
|
|
24
28
|
const {
|
|
25
29
|
classes,
|
|
@@ -33,44 +37,114 @@ const useUtilityClasses = ownerState => {
|
|
|
33
37
|
tickLabel: ['tickLabel'],
|
|
34
38
|
label: ['label']
|
|
35
39
|
};
|
|
36
|
-
return (0,
|
|
40
|
+
return (0, _utils2.unstable_composeClasses)(slots, _axisClasses.getAxisUtilityClass, classes);
|
|
37
41
|
};
|
|
42
|
+
function addLabelDimension(xTicks, {
|
|
43
|
+
tickLabelStyle: style,
|
|
44
|
+
tickLabelInterval,
|
|
45
|
+
isMounted
|
|
46
|
+
}) {
|
|
47
|
+
const withDimension = xTicks.map(tick => {
|
|
48
|
+
if (!isMounted || tick.formattedValue === undefined) {
|
|
49
|
+
return (0, _extends2.default)({}, tick, {
|
|
50
|
+
width: 0,
|
|
51
|
+
height: 0
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const tickSizes = (0, _ChartsText.getWordsByLines)({
|
|
55
|
+
style,
|
|
56
|
+
needsComputation: true,
|
|
57
|
+
text: tick.formattedValue
|
|
58
|
+
});
|
|
59
|
+
return (0, _extends2.default)({}, tick, {
|
|
60
|
+
width: Math.max(...tickSizes.map(size => size.width)),
|
|
61
|
+
height: Math.max(tickSizes.length * tickSizes[0].height)
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
if (typeof tickLabelInterval === 'function') {
|
|
65
|
+
return withDimension.map((item, index) => (0, _extends2.default)({}, item, {
|
|
66
|
+
skipLabel: !tickLabelInterval(item.value, index)
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Filter label to avoid overlap
|
|
71
|
+
let textStart = 0;
|
|
72
|
+
let textEnd = 0;
|
|
73
|
+
return withDimension.map((item, labelIndex) => {
|
|
74
|
+
const {
|
|
75
|
+
width,
|
|
76
|
+
offset,
|
|
77
|
+
labelOffset,
|
|
78
|
+
height
|
|
79
|
+
} = item;
|
|
80
|
+
const distance = (0, _geometry.getMinXTranslation)(width, height, style?.angle);
|
|
81
|
+
const textPosition = offset + labelOffset;
|
|
82
|
+
const gapRatio = 1.2; // Ratio applied to the minimal distance to add some margin.
|
|
83
|
+
|
|
84
|
+
textStart = textPosition - gapRatio * distance / 2;
|
|
85
|
+
if (labelIndex > 0 && textStart < textEnd) {
|
|
86
|
+
// Except for the first label, we skip all label that overlap with the last accepted.
|
|
87
|
+
// Notice that the early return prevents `textEnd` from being updated.
|
|
88
|
+
return (0, _extends2.default)({}, item, {
|
|
89
|
+
skipLabel: true
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
textEnd = textPosition + gapRatio * distance / 2;
|
|
93
|
+
return item;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
38
96
|
const defaultProps = {
|
|
39
97
|
position: 'bottom',
|
|
40
98
|
disableLine: false,
|
|
41
99
|
disableTicks: false,
|
|
42
|
-
tickFontSize: 12,
|
|
43
|
-
labelFontSize: 14,
|
|
44
100
|
tickSize: 6
|
|
45
101
|
};
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Demos:
|
|
105
|
+
*
|
|
106
|
+
* - [Axis](https://mui.com/x/react-charts/axis/)
|
|
107
|
+
*
|
|
108
|
+
* API:
|
|
109
|
+
*
|
|
110
|
+
* - [ChartsXAxis API](https://mui.com/x/api/charts/charts-x-axis/)
|
|
111
|
+
*/
|
|
46
112
|
function ChartsXAxis(inProps) {
|
|
47
113
|
const props = (0, _styles.useThemeProps)({
|
|
48
114
|
props: (0, _extends2.default)({}, defaultProps, inProps),
|
|
49
115
|
name: 'MuiChartsXAxis'
|
|
50
116
|
});
|
|
117
|
+
const {
|
|
118
|
+
xAxisIds
|
|
119
|
+
} = React.useContext(_CartesianContextProvider.CartesianContext);
|
|
51
120
|
const _React$useContext = React.useContext(_CartesianContextProvider.CartesianContext),
|
|
52
|
-
|
|
121
|
+
_ref = props.axisId ?? xAxisIds[0],
|
|
53
122
|
{
|
|
54
123
|
xAxis: {
|
|
55
|
-
[
|
|
124
|
+
[_ref]: {
|
|
56
125
|
scale: xScale,
|
|
57
|
-
|
|
126
|
+
tickNumber
|
|
58
127
|
}
|
|
59
128
|
}
|
|
60
129
|
} = _React$useContext,
|
|
61
|
-
settings = (0, _objectWithoutPropertiesLoose2.default)(_React$useContext.xAxis[
|
|
130
|
+
settings = (0, _objectWithoutPropertiesLoose2.default)(_React$useContext.xAxis[_ref], _excluded);
|
|
131
|
+
const isMounted = (0, _useMounted.useMounted)();
|
|
62
132
|
const defaultizedProps = (0, _extends2.default)({}, defaultProps, settings, props);
|
|
63
133
|
const {
|
|
64
134
|
position,
|
|
65
135
|
disableLine,
|
|
66
136
|
disableTicks,
|
|
67
|
-
|
|
137
|
+
tickLabelStyle,
|
|
68
138
|
label,
|
|
139
|
+
labelStyle,
|
|
140
|
+
tickFontSize,
|
|
69
141
|
labelFontSize,
|
|
70
142
|
tickSize: tickSizeProp,
|
|
71
143
|
valueFormatter,
|
|
72
144
|
slots,
|
|
73
|
-
slotProps
|
|
145
|
+
slotProps,
|
|
146
|
+
tickInterval,
|
|
147
|
+
tickLabelInterval
|
|
74
148
|
} = defaultizedProps;
|
|
75
149
|
const theme = (0, _styles.useTheme)();
|
|
76
150
|
const classes = useUtilityClasses((0, _extends2.default)({}, defaultizedProps, {
|
|
@@ -83,20 +157,52 @@ function ChartsXAxis(inProps) {
|
|
|
83
157
|
height
|
|
84
158
|
} = React.useContext(_DrawingProvider.DrawingContext);
|
|
85
159
|
const tickSize = disableTicks ? 4 : tickSizeProp;
|
|
160
|
+
const positionSign = position === 'bottom' ? 1 : -1;
|
|
161
|
+
const Line = slots?.axisLine ?? 'line';
|
|
162
|
+
const Tick = slots?.axisTick ?? 'line';
|
|
163
|
+
const TickLabel = slots?.axisTickLabel ?? _ChartsText.ChartsText;
|
|
164
|
+
const Label = slots?.axisLabel ?? _ChartsText.ChartsText;
|
|
165
|
+
const axisTickLabelProps = (0, _utils.useSlotProps)({
|
|
166
|
+
elementType: TickLabel,
|
|
167
|
+
externalSlotProps: slotProps?.axisTickLabel,
|
|
168
|
+
additionalProps: {
|
|
169
|
+
style: (0, _extends2.default)({
|
|
170
|
+
textAnchor: 'middle',
|
|
171
|
+
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto',
|
|
172
|
+
fontSize: tickFontSize ?? 12
|
|
173
|
+
}, tickLabelStyle),
|
|
174
|
+
className: classes.tickLabel
|
|
175
|
+
},
|
|
176
|
+
className: classes.tickLabel,
|
|
177
|
+
ownerState: {}
|
|
178
|
+
});
|
|
86
179
|
const xTicks = (0, _useTicks.default)({
|
|
87
180
|
scale: xScale,
|
|
88
|
-
|
|
89
|
-
valueFormatter
|
|
181
|
+
tickNumber,
|
|
182
|
+
valueFormatter,
|
|
183
|
+
tickInterval
|
|
184
|
+
});
|
|
185
|
+
const xTicksWithDimension = addLabelDimension(xTicks, {
|
|
186
|
+
tickLabelStyle: axisTickLabelProps.style,
|
|
187
|
+
tickLabelInterval,
|
|
188
|
+
isMounted
|
|
90
189
|
});
|
|
91
|
-
const positionSigne = position === 'bottom' ? 1 : -1;
|
|
92
190
|
const labelRefPoint = {
|
|
93
191
|
x: left + width / 2,
|
|
94
|
-
y:
|
|
192
|
+
y: positionSign * (tickSize + 22)
|
|
95
193
|
};
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
194
|
+
const axisLabelProps = (0, _utils.useSlotProps)({
|
|
195
|
+
elementType: Label,
|
|
196
|
+
externalSlotProps: slotProps?.axisLabel,
|
|
197
|
+
additionalProps: {
|
|
198
|
+
style: (0, _extends2.default)({
|
|
199
|
+
fontSize: labelFontSize ?? 14,
|
|
200
|
+
textAnchor: 'middle',
|
|
201
|
+
dominantBaseline: position === 'bottom' ? 'hanging' : 'auto'
|
|
202
|
+
}, labelStyle)
|
|
203
|
+
},
|
|
204
|
+
ownerState: {}
|
|
205
|
+
});
|
|
100
206
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_AxisSharedComponents.AxisRoot, {
|
|
101
207
|
transform: `translate(0, ${position === 'bottom' ? top + height : top})`,
|
|
102
208
|
className: classes.root,
|
|
@@ -104,40 +210,33 @@ function ChartsXAxis(inProps) {
|
|
|
104
210
|
x1: xScale.range()[0],
|
|
105
211
|
x2: xScale.range()[1],
|
|
106
212
|
className: classes.line
|
|
107
|
-
}, slotProps?.axisLine)),
|
|
213
|
+
}, slotProps?.axisLine)), xTicksWithDimension.map(({
|
|
108
214
|
formattedValue,
|
|
109
215
|
offset,
|
|
110
|
-
labelOffset
|
|
216
|
+
labelOffset,
|
|
217
|
+
skipLabel
|
|
111
218
|
}, index) => {
|
|
112
219
|
const xTickLabel = labelOffset ?? 0;
|
|
113
|
-
const yTickLabel =
|
|
220
|
+
const yTickLabel = positionSign * (tickSize + 3);
|
|
114
221
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
115
222
|
transform: `translate(${offset}, 0)`,
|
|
116
223
|
className: classes.tickContainer,
|
|
117
224
|
children: [!disableTicks && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tick, (0, _extends2.default)({
|
|
118
|
-
y2:
|
|
225
|
+
y2: positionSign * tickSize,
|
|
119
226
|
className: classes.tick
|
|
120
|
-
}, slotProps?.axisTick)), formattedValue !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
|
|
227
|
+
}, slotProps?.axisTick)), formattedValue !== undefined && !skipLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
|
|
121
228
|
x: xTickLabel,
|
|
122
|
-
y: yTickLabel
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
fontSize: tickFontSize
|
|
126
|
-
},
|
|
127
|
-
className: classes.tickLabel
|
|
128
|
-
}, slotProps?.axisTickLabel, {
|
|
129
|
-
children: formattedValue
|
|
229
|
+
y: yTickLabel
|
|
230
|
+
}, axisTickLabelProps, {
|
|
231
|
+
text: formattedValue.toString()
|
|
130
232
|
}))]
|
|
131
233
|
}, index);
|
|
132
|
-
}), label && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
}, slotProps?.axisLabel, {
|
|
139
|
-
children: label
|
|
140
|
-
}))]
|
|
234
|
+
}), label && /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
235
|
+
className: classes.label,
|
|
236
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
|
|
237
|
+
text: label
|
|
238
|
+
}))
|
|
239
|
+
})]
|
|
141
240
|
});
|
|
142
241
|
}
|
|
143
242
|
process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
@@ -146,9 +245,10 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
146
245
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
147
246
|
// ----------------------------------------------------------------------
|
|
148
247
|
/**
|
|
149
|
-
*
|
|
248
|
+
* The id of the axis to render.
|
|
249
|
+
* If undefined, it will be the first defined axis.
|
|
150
250
|
*/
|
|
151
|
-
axisId: _propTypes.default.string
|
|
251
|
+
axisId: _propTypes.default.string,
|
|
152
252
|
/**
|
|
153
253
|
* Override or extend the styles applied to the component.
|
|
154
254
|
*/
|
|
@@ -175,8 +275,13 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
175
275
|
/**
|
|
176
276
|
* The font size of the axis label.
|
|
177
277
|
* @default 14
|
|
278
|
+
* @deprecated Consider using `labelStyle.fontSize` instead.
|
|
178
279
|
*/
|
|
179
280
|
labelFontSize: _propTypes.default.number,
|
|
281
|
+
/**
|
|
282
|
+
* The style applied to the axis label.
|
|
283
|
+
*/
|
|
284
|
+
labelStyle: _propTypes.default.object,
|
|
180
285
|
/**
|
|
181
286
|
* Position of the axis.
|
|
182
287
|
*/
|
|
@@ -199,8 +304,28 @@ process.env.NODE_ENV !== "production" ? ChartsXAxis.propTypes = {
|
|
|
199
304
|
/**
|
|
200
305
|
* The font size of the axis ticks text.
|
|
201
306
|
* @default 12
|
|
307
|
+
* @deprecated Consider using `tickLabelStyle.fontSize` instead.
|
|
202
308
|
*/
|
|
203
309
|
tickFontSize: _propTypes.default.number,
|
|
310
|
+
/**
|
|
311
|
+
* Defines which ticks are displayed. Its value can be:
|
|
312
|
+
* - 'auto' In such case the ticks are computed based on axis scale and other parameters.
|
|
313
|
+
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
|
|
314
|
+
* - an array containing the values where ticks should be displayed.
|
|
315
|
+
* @default 'auto'
|
|
316
|
+
*/
|
|
317
|
+
tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
|
|
318
|
+
/**
|
|
319
|
+
* Defines which ticks get its label displayed. Its value can be:
|
|
320
|
+
* - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
|
|
321
|
+
* - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
|
|
322
|
+
* @default 'auto'
|
|
323
|
+
*/
|
|
324
|
+
tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
|
|
325
|
+
/**
|
|
326
|
+
* The style applied to ticks text.
|
|
327
|
+
*/
|
|
328
|
+
tickLabelStyle: _propTypes.default.object,
|
|
204
329
|
/**
|
|
205
330
|
* Maximal step between two ticks.
|
|
206
331
|
* When using time data, the value is assumed to be in ms.
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ChartsYAxisProps } from '../models/axis';
|
|
3
|
+
/**
|
|
4
|
+
* Demos:
|
|
5
|
+
*
|
|
6
|
+
* - [Axis](https://mui.com/x/react-charts/axis/)
|
|
7
|
+
*
|
|
8
|
+
* API:
|
|
9
|
+
*
|
|
10
|
+
* - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
|
|
11
|
+
*/
|
|
3
12
|
declare function ChartsYAxis(inProps: ChartsYAxisProps): React.JSX.Element;
|
|
4
13
|
declare namespace ChartsYAxis {
|
|
5
14
|
var propTypes: any;
|
|
@@ -9,17 +9,19 @@ var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runt
|
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
-
var _utils = require("@mui/utils");
|
|
12
|
+
var _utils = require("@mui/base/utils");
|
|
13
|
+
var _utils2 = require("@mui/utils");
|
|
13
14
|
var _styles = require("@mui/material/styles");
|
|
14
15
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
15
16
|
var _DrawingProvider = require("../context/DrawingProvider");
|
|
16
17
|
var _useTicks = _interopRequireDefault(require("../hooks/useTicks"));
|
|
17
18
|
var _AxisSharedComponents = require("../internals/components/AxisSharedComponents");
|
|
19
|
+
var _ChartsText = require("../internals/components/ChartsText");
|
|
18
20
|
var _axisClasses = require("../ChartsAxis/axisClasses");
|
|
19
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
-
const _excluded = ["scale", "
|
|
21
|
-
function _getRequireWildcardCache(
|
|
22
|
-
function _interopRequireWildcard(
|
|
22
|
+
const _excluded = ["scale", "tickNumber"];
|
|
23
|
+
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); }
|
|
24
|
+
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; }
|
|
23
25
|
const useUtilityClasses = ownerState => {
|
|
24
26
|
const {
|
|
25
27
|
classes,
|
|
@@ -33,7 +35,7 @@ const useUtilityClasses = ownerState => {
|
|
|
33
35
|
tickLabel: ['tickLabel'],
|
|
34
36
|
label: ['label']
|
|
35
37
|
};
|
|
36
|
-
return (0,
|
|
38
|
+
return (0, _utils2.unstable_composeClasses)(slots, _axisClasses.getAxisUtilityClass, classes);
|
|
37
39
|
};
|
|
38
40
|
const defaultProps = {
|
|
39
41
|
position: 'left',
|
|
@@ -43,22 +45,35 @@ const defaultProps = {
|
|
|
43
45
|
labelFontSize: 14,
|
|
44
46
|
tickSize: 6
|
|
45
47
|
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Demos:
|
|
51
|
+
*
|
|
52
|
+
* - [Axis](https://mui.com/x/react-charts/axis/)
|
|
53
|
+
*
|
|
54
|
+
* API:
|
|
55
|
+
*
|
|
56
|
+
* - [ChartsYAxis API](https://mui.com/x/api/charts/charts-y-axis/)
|
|
57
|
+
*/
|
|
46
58
|
function ChartsYAxis(inProps) {
|
|
47
59
|
const props = (0, _styles.useThemeProps)({
|
|
48
60
|
props: (0, _extends2.default)({}, defaultProps, inProps),
|
|
49
61
|
name: 'MuiChartsYAxis'
|
|
50
62
|
});
|
|
63
|
+
const {
|
|
64
|
+
yAxisIds
|
|
65
|
+
} = React.useContext(_CartesianContextProvider.CartesianContext);
|
|
51
66
|
const _React$useContext = React.useContext(_CartesianContextProvider.CartesianContext),
|
|
52
|
-
|
|
67
|
+
_ref = props.axisId ?? yAxisIds[0],
|
|
53
68
|
{
|
|
54
69
|
yAxis: {
|
|
55
|
-
[
|
|
70
|
+
[_ref]: {
|
|
56
71
|
scale: yScale,
|
|
57
|
-
|
|
72
|
+
tickNumber
|
|
58
73
|
}
|
|
59
74
|
}
|
|
60
75
|
} = _React$useContext,
|
|
61
|
-
settings = (0, _objectWithoutPropertiesLoose2.default)(_React$useContext.yAxis[
|
|
76
|
+
settings = (0, _objectWithoutPropertiesLoose2.default)(_React$useContext.yAxis[_ref], _excluded);
|
|
62
77
|
const defaultizedProps = (0, _extends2.default)({}, defaultProps, settings, props);
|
|
63
78
|
const {
|
|
64
79
|
position,
|
|
@@ -85,18 +100,44 @@ function ChartsYAxis(inProps) {
|
|
|
85
100
|
const tickSize = disableTicks ? 4 : tickSizeProp;
|
|
86
101
|
const yTicks = (0, _useTicks.default)({
|
|
87
102
|
scale: yScale,
|
|
88
|
-
|
|
103
|
+
tickNumber,
|
|
89
104
|
valueFormatter
|
|
90
105
|
});
|
|
91
|
-
const
|
|
106
|
+
const positionSign = position === 'right' ? 1 : -1;
|
|
92
107
|
const labelRefPoint = {
|
|
93
|
-
x:
|
|
108
|
+
x: positionSign * (tickFontSize + tickSize + 10),
|
|
94
109
|
y: top + height / 2
|
|
95
110
|
};
|
|
96
|
-
const Line = slots?.axisLine ??
|
|
97
|
-
const Tick = slots?.axisTick ??
|
|
98
|
-
const TickLabel = slots?.axisTickLabel ??
|
|
99
|
-
const Label = slots?.axisLabel ??
|
|
111
|
+
const Line = slots?.axisLine ?? 'line';
|
|
112
|
+
const Tick = slots?.axisTick ?? 'line';
|
|
113
|
+
const TickLabel = slots?.axisTickLabel ?? _ChartsText.ChartsText;
|
|
114
|
+
const Label = slots?.axisLabel ?? _ChartsText.ChartsText;
|
|
115
|
+
const axisTickLabelProps = (0, _utils.useSlotProps)({
|
|
116
|
+
elementType: TickLabel,
|
|
117
|
+
externalSlotProps: slotProps?.axisTickLabel,
|
|
118
|
+
additionalProps: {
|
|
119
|
+
style: {
|
|
120
|
+
fontSize: tickFontSize,
|
|
121
|
+
textAnchor: position === 'right' ? 'start' : 'end',
|
|
122
|
+
dominantBaseline: 'central'
|
|
123
|
+
},
|
|
124
|
+
className: classes.tickLabel
|
|
125
|
+
},
|
|
126
|
+
ownerState: {}
|
|
127
|
+
});
|
|
128
|
+
const axisLabelProps = (0, _utils.useSlotProps)({
|
|
129
|
+
elementType: Label,
|
|
130
|
+
externalSlotProps: slotProps?.axisLabel,
|
|
131
|
+
additionalProps: {
|
|
132
|
+
style: {
|
|
133
|
+
fontSize: labelFontSize,
|
|
134
|
+
angle: positionSign * 90,
|
|
135
|
+
textAnchor: 'middle',
|
|
136
|
+
dominantBaseline: 'auto'
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
ownerState: {}
|
|
140
|
+
});
|
|
100
141
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_AxisSharedComponents.AxisRoot, {
|
|
101
142
|
transform: `translate(${position === 'right' ? left + width : left}, 0)`,
|
|
102
143
|
className: classes.root,
|
|
@@ -109,36 +150,26 @@ function ChartsYAxis(inProps) {
|
|
|
109
150
|
offset,
|
|
110
151
|
labelOffset
|
|
111
152
|
}, index) => {
|
|
112
|
-
const xTickLabel =
|
|
153
|
+
const xTickLabel = positionSign * (tickSize + 2);
|
|
113
154
|
const yTickLabel = labelOffset;
|
|
114
155
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
115
156
|
transform: `translate(0, ${offset})`,
|
|
116
157
|
className: classes.tickContainer,
|
|
117
158
|
children: [!disableTicks && /*#__PURE__*/(0, _jsxRuntime.jsx)(Tick, (0, _extends2.default)({
|
|
118
|
-
x2:
|
|
159
|
+
x2: positionSign * tickSize,
|
|
119
160
|
className: classes.tick
|
|
120
161
|
}, slotProps?.axisTick)), formattedValue !== undefined && /*#__PURE__*/(0, _jsxRuntime.jsx)(TickLabel, (0, _extends2.default)({
|
|
121
162
|
x: xTickLabel,
|
|
122
163
|
y: yTickLabel,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
fontSize: tickFontSize
|
|
126
|
-
},
|
|
127
|
-
className: classes.tickLabel
|
|
128
|
-
}, slotProps?.axisTickLabel, {
|
|
129
|
-
children: formattedValue.toLocaleString()
|
|
130
|
-
}))]
|
|
164
|
+
text: formattedValue.toString()
|
|
165
|
+
}, axisTickLabelProps))]
|
|
131
166
|
}, index);
|
|
132
|
-
}), label && /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
className: classes.label
|
|
139
|
-
}, slotProps?.axisLabel, {
|
|
140
|
-
children: label
|
|
141
|
-
}))]
|
|
167
|
+
}), label && /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
168
|
+
className: classes.label,
|
|
169
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Label, (0, _extends2.default)({}, labelRefPoint, axisLabelProps, {
|
|
170
|
+
text: label
|
|
171
|
+
}))
|
|
172
|
+
})]
|
|
142
173
|
});
|
|
143
174
|
}
|
|
144
175
|
process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
@@ -147,9 +178,10 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
147
178
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
148
179
|
// ----------------------------------------------------------------------
|
|
149
180
|
/**
|
|
150
|
-
*
|
|
181
|
+
* The id of the axis to render.
|
|
182
|
+
* If undefined, it will be the first defined axis.
|
|
151
183
|
*/
|
|
152
|
-
axisId: _propTypes.default.string
|
|
184
|
+
axisId: _propTypes.default.string,
|
|
153
185
|
/**
|
|
154
186
|
* Override or extend the styles applied to the component.
|
|
155
187
|
*/
|
|
@@ -176,8 +208,13 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
176
208
|
/**
|
|
177
209
|
* The font size of the axis label.
|
|
178
210
|
* @default 14
|
|
211
|
+
* @deprecated Consider using `labelStyle.fontSize` instead.
|
|
179
212
|
*/
|
|
180
213
|
labelFontSize: _propTypes.default.number,
|
|
214
|
+
/**
|
|
215
|
+
* The style applied to the axis label.
|
|
216
|
+
*/
|
|
217
|
+
labelStyle: _propTypes.default.object,
|
|
181
218
|
/**
|
|
182
219
|
* Position of the axis.
|
|
183
220
|
*/
|
|
@@ -200,8 +237,28 @@ process.env.NODE_ENV !== "production" ? ChartsYAxis.propTypes = {
|
|
|
200
237
|
/**
|
|
201
238
|
* The font size of the axis ticks text.
|
|
202
239
|
* @default 12
|
|
240
|
+
* @deprecated Consider using `tickLabelStyle.fontSize` instead.
|
|
203
241
|
*/
|
|
204
242
|
tickFontSize: _propTypes.default.number,
|
|
243
|
+
/**
|
|
244
|
+
* Defines which ticks are displayed. Its value can be:
|
|
245
|
+
* - 'auto' In such case the ticks are computed based on axis scale and other parameters.
|
|
246
|
+
* - a filtering function of the form `(value, index) => boolean` which is available only if the axis has a data property.
|
|
247
|
+
* - an array containing the values where ticks should be displayed.
|
|
248
|
+
* @default 'auto'
|
|
249
|
+
*/
|
|
250
|
+
tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]),
|
|
251
|
+
/**
|
|
252
|
+
* Defines which ticks get its label displayed. Its value can be:
|
|
253
|
+
* - 'auto' In such case, labels are displayed if they do not overlap with the previous one.
|
|
254
|
+
* - a filtering function of the form (value, index) => boolean. Warning: the index is tick index, not data ones.
|
|
255
|
+
* @default 'auto'
|
|
256
|
+
*/
|
|
257
|
+
tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]),
|
|
258
|
+
/**
|
|
259
|
+
* The style applied to ticks text.
|
|
260
|
+
*/
|
|
261
|
+
tickLabelStyle: _propTypes.default.object,
|
|
205
262
|
/**
|
|
206
263
|
* Maximal step between two ticks.
|
|
207
264
|
* When using time data, the value is assumed to be in ms.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { SlotComponentProps } from '@mui/base';
|
|
2
|
+
import { SlotComponentProps } from '@mui/base/utils';
|
|
3
3
|
import { HighlightScope } from '../context/HighlightProvider';
|
|
4
4
|
export interface AreaElementClasses {
|
|
5
5
|
/** Styles applied to the root element. */
|
|
@@ -43,6 +43,16 @@ export type AreaElementProps = Omit<AreaElementOwnerState, 'isFaded' | 'isHighli
|
|
|
43
43
|
area?: React.ElementType;
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Demos:
|
|
48
|
+
*
|
|
49
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
50
|
+
* - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
|
|
51
|
+
*
|
|
52
|
+
* API:
|
|
53
|
+
*
|
|
54
|
+
* - [AreaElement API](https://mui.com/x/api/charts/area-element/)
|
|
55
|
+
*/
|
|
46
56
|
declare function AreaElement(props: AreaElementProps): React.JSX.Element;
|
|
47
57
|
declare namespace AreaElement {
|
|
48
58
|
var propTypes: any;
|
package/LineChart/AreaElement.js
CHANGED
|
@@ -21,13 +21,12 @@ var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
|
21
21
|
var _InteractionProvider = require("../context/InteractionProvider");
|
|
22
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
23
|
const _excluded = ["id", "classes", "color", "highlightScope", "slots", "slotProps"];
|
|
24
|
-
function _getRequireWildcardCache(
|
|
25
|
-
function _interopRequireWildcard(
|
|
24
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
25
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
26
|
function getAreaElementUtilityClass(slot) {
|
|
27
27
|
return (0, _generateUtilityClass.default)('MuiAreaElement', slot);
|
|
28
28
|
}
|
|
29
|
-
const areaElementClasses = (0, _generateUtilityClasses.default)('MuiAreaElement', ['root', 'highlighted', 'faded']);
|
|
30
|
-
exports.areaElementClasses = areaElementClasses;
|
|
29
|
+
const areaElementClasses = exports.areaElementClasses = (0, _generateUtilityClasses.default)('MuiAreaElement', ['root', 'highlighted', 'faded']);
|
|
31
30
|
const useUtilityClasses = ownerState => {
|
|
32
31
|
const {
|
|
33
32
|
classes,
|
|
@@ -40,7 +39,7 @@ const useUtilityClasses = ownerState => {
|
|
|
40
39
|
};
|
|
41
40
|
return (0, _composeClasses.default)(slots, getAreaElementUtilityClass, classes);
|
|
42
41
|
};
|
|
43
|
-
const AreaElementPath = (0, _styles.styled)('path', {
|
|
42
|
+
const AreaElementPath = exports.AreaElementPath = (0, _styles.styled)('path', {
|
|
44
43
|
name: 'MuiAreaElement',
|
|
45
44
|
slot: 'Root',
|
|
46
45
|
overridesResolver: (_, styles) => styles.root
|
|
@@ -52,7 +51,6 @@ const AreaElementPath = (0, _styles.styled)('path', {
|
|
|
52
51
|
transition: 'opacity 0.2s ease-in, fill 0.2s ease-in',
|
|
53
52
|
opacity: ownerState.isFaded ? 0.3 : 1
|
|
54
53
|
}));
|
|
55
|
-
exports.AreaElementPath = AreaElementPath;
|
|
56
54
|
AreaElementPath.propTypes = {
|
|
57
55
|
// ----------------------------- Warning --------------------------------
|
|
58
56
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
@@ -68,6 +66,16 @@ AreaElementPath.propTypes = {
|
|
|
68
66
|
}).isRequired,
|
|
69
67
|
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object])
|
|
70
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* Demos:
|
|
71
|
+
*
|
|
72
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
73
|
+
* - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
|
|
74
|
+
*
|
|
75
|
+
* API:
|
|
76
|
+
*
|
|
77
|
+
* - [AreaElement API](https://mui.com/x/api/charts/area-element/)
|
|
78
|
+
*/
|
|
71
79
|
function AreaElement(props) {
|
|
72
80
|
const {
|
|
73
81
|
id,
|
package/LineChart/AreaPlot.d.ts
CHANGED
|
@@ -8,6 +8,17 @@ export interface AreaPlotSlotComponentProps {
|
|
|
8
8
|
}
|
|
9
9
|
export interface AreaPlotProps extends React.SVGAttributes<SVGSVGElement>, Pick<AreaElementProps, 'slots' | 'slotProps'> {
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Demos:
|
|
13
|
+
*
|
|
14
|
+
* - [Lines](https://mui.com/x/react-charts/lines/)
|
|
15
|
+
* - [Areas demonstration](https://mui.com/x/react-charts/areas-demo/)
|
|
16
|
+
* - [Stacking](https://mui.com/x/react-charts/stacking/)
|
|
17
|
+
*
|
|
18
|
+
* API:
|
|
19
|
+
*
|
|
20
|
+
* - [AreaPlot API](https://mui.com/x/api/charts/area-plot/)
|
|
21
|
+
*/
|
|
11
22
|
declare function AreaPlot(props: AreaPlotProps): React.JSX.Element | null;
|
|
12
23
|
declare namespace AreaPlot {
|
|
13
24
|
var propTypes: any;
|