@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,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ChartsYReferenceLine = ChartsYReferenceLine;
|
|
8
|
+
exports.getYReferenceLineClasses = getYReferenceLineClasses;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
12
|
+
var _hooks = require("../hooks");
|
|
13
|
+
var _common = require("./common");
|
|
14
|
+
var _ChartsText = require("../internals/components/ChartsText");
|
|
15
|
+
var _chartsReferenceLineClasses = require("./chartsReferenceLineClasses");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
19
|
+
const getTextParams = ({
|
|
20
|
+
left,
|
|
21
|
+
width,
|
|
22
|
+
spacingX,
|
|
23
|
+
labelAlign = 'middle'
|
|
24
|
+
}) => {
|
|
25
|
+
switch (labelAlign) {
|
|
26
|
+
case 'start':
|
|
27
|
+
return {
|
|
28
|
+
x: left + spacingX,
|
|
29
|
+
style: {
|
|
30
|
+
dominantBaseline: 'auto',
|
|
31
|
+
textAnchor: 'start'
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
case 'end':
|
|
35
|
+
return {
|
|
36
|
+
x: left + width - spacingX,
|
|
37
|
+
style: {
|
|
38
|
+
dominantBaseline: 'auto',
|
|
39
|
+
textAnchor: 'end'
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
default:
|
|
43
|
+
return {
|
|
44
|
+
x: left + width / 2,
|
|
45
|
+
style: {
|
|
46
|
+
dominantBaseline: 'auto',
|
|
47
|
+
textAnchor: 'middle'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
let warnedOnce = false;
|
|
53
|
+
function getYReferenceLineClasses(classes) {
|
|
54
|
+
return (0, _composeClasses.default)({
|
|
55
|
+
root: ['root', 'horizontal'],
|
|
56
|
+
line: ['line'],
|
|
57
|
+
label: ['label']
|
|
58
|
+
}, _chartsReferenceLineClasses.getReferenceLineUtilityClass, classes);
|
|
59
|
+
}
|
|
60
|
+
function ChartsYReferenceLine(props) {
|
|
61
|
+
const {
|
|
62
|
+
y,
|
|
63
|
+
label = '',
|
|
64
|
+
spacing = 5,
|
|
65
|
+
classes: inClasses,
|
|
66
|
+
labelAlign,
|
|
67
|
+
lineStyle,
|
|
68
|
+
labelStyle,
|
|
69
|
+
axisId
|
|
70
|
+
} = props;
|
|
71
|
+
const {
|
|
72
|
+
left,
|
|
73
|
+
width
|
|
74
|
+
} = (0, _hooks.useDrawingArea)();
|
|
75
|
+
const yAxisScale = (0, _hooks.useYScale)(axisId);
|
|
76
|
+
const yPosition = yAxisScale(y);
|
|
77
|
+
if (yPosition === undefined) {
|
|
78
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
79
|
+
if (!warnedOnce) {
|
|
80
|
+
warnedOnce = true;
|
|
81
|
+
console.error(`MUI X: the value ${y} does not exist in the data of y axis with id ${axisId}.`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
const d = `M ${left} ${yPosition} l ${width} 0`;
|
|
87
|
+
const classes = getYReferenceLineClasses(inClasses);
|
|
88
|
+
const spacingX = typeof spacing === 'object' ? spacing.x ?? 0 : spacing;
|
|
89
|
+
const spacingY = typeof spacing === 'object' ? spacing.y ?? 0 : spacing;
|
|
90
|
+
const textParams = (0, _extends2.default)({
|
|
91
|
+
y: yPosition - spacingY,
|
|
92
|
+
text: label,
|
|
93
|
+
fontSize: 12
|
|
94
|
+
}, getTextParams({
|
|
95
|
+
left,
|
|
96
|
+
width,
|
|
97
|
+
spacingX,
|
|
98
|
+
labelAlign
|
|
99
|
+
}), {
|
|
100
|
+
className: classes.label
|
|
101
|
+
});
|
|
102
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_common.ReferenceLineRoot, {
|
|
103
|
+
className: classes.root,
|
|
104
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
105
|
+
d: d,
|
|
106
|
+
className: classes.line,
|
|
107
|
+
style: lineStyle
|
|
108
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsText.ChartsText, (0, _extends2.default)({}, textParams, {
|
|
109
|
+
style: (0, _extends2.default)({}, textParams.style, labelStyle)
|
|
110
|
+
}))]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface ChartsReferenceLineClasses {
|
|
2
|
+
/** Styles applied to the root element. */
|
|
3
|
+
root: string;
|
|
4
|
+
/** Styles applied to the root element if the reference line is vertical. */
|
|
5
|
+
vertical: string;
|
|
6
|
+
/** Styles applied to the root element if the reference line is horizontal. */
|
|
7
|
+
horizontal: string;
|
|
8
|
+
/** Styles applied to the reference line. */
|
|
9
|
+
line: string;
|
|
10
|
+
/** Styles applied to the reference label. */
|
|
11
|
+
label: string;
|
|
12
|
+
}
|
|
13
|
+
export type ChartsReferenceLineClassKey = keyof ChartsReferenceLineClasses;
|
|
14
|
+
export declare function getReferenceLineUtilityClass(slot: string): string;
|
|
15
|
+
export declare const referenceLineClasses: ChartsReferenceLineClasses;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getReferenceLineUtilityClass = getReferenceLineUtilityClass;
|
|
8
|
+
exports.referenceLineClasses = void 0;
|
|
9
|
+
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
|
10
|
+
var _generateUtilityClasses = _interopRequireDefault(require("@mui/utils/generateUtilityClasses"));
|
|
11
|
+
function getReferenceLineUtilityClass(slot) {
|
|
12
|
+
return (0, _generateUtilityClass.default)('MuiChartsReferenceLine', slot);
|
|
13
|
+
}
|
|
14
|
+
const referenceLineClasses = exports.referenceLineClasses = (0, _generateUtilityClasses.default)('MuiChartsReferenceLine', ['root', 'vertical', 'horizontal', 'line', 'label']);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ChartsReferenceLineClasses } from './chartsReferenceLineClasses';
|
|
3
|
+
import { ChartsTextStyle } from '../internals/components/ChartsText';
|
|
4
|
+
export type CommonChartsReferenceLineProps = {
|
|
5
|
+
/**
|
|
6
|
+
* The alignment if the label is in the chart drawing area.
|
|
7
|
+
* @default 'middle'
|
|
8
|
+
*/
|
|
9
|
+
labelAlign?: 'start' | 'middle' | 'end';
|
|
10
|
+
/**
|
|
11
|
+
* The label to display along the reference line.
|
|
12
|
+
*/
|
|
13
|
+
label?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Additional space arround the label in px.
|
|
16
|
+
* Can be a number or an object `{ x, y }` to distinguish space with the reference line and space with axes.
|
|
17
|
+
* @default 5
|
|
18
|
+
*/
|
|
19
|
+
spacing?: number | {
|
|
20
|
+
x?: number;
|
|
21
|
+
y?: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The id of the axis used for the reference value.
|
|
25
|
+
* @default The `id` of the first defined axis.
|
|
26
|
+
*/
|
|
27
|
+
axisId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The style applied to the label.
|
|
30
|
+
*/
|
|
31
|
+
labelStyle?: ChartsTextStyle;
|
|
32
|
+
/**
|
|
33
|
+
* The style applied to the line.
|
|
34
|
+
*/
|
|
35
|
+
lineStyle?: React.CSSProperties;
|
|
36
|
+
/**
|
|
37
|
+
* Override or extend the styles applied to the component.
|
|
38
|
+
*/
|
|
39
|
+
classes?: Partial<ChartsReferenceLineClasses>;
|
|
40
|
+
};
|
|
41
|
+
export declare const ReferenceLineRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").SVGProps<SVGGElement>, {}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ReferenceLineRoot = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _styles = require("@mui/material/styles");
|
|
10
|
+
var _chartsReferenceLineClasses = require("./chartsReferenceLineClasses");
|
|
11
|
+
const ReferenceLineRoot = exports.ReferenceLineRoot = (0, _styles.styled)('g')(({
|
|
12
|
+
theme
|
|
13
|
+
}) => ({
|
|
14
|
+
[`& .${_chartsReferenceLineClasses.referenceLineClasses.line}`]: {
|
|
15
|
+
fill: 'none',
|
|
16
|
+
stroke: (theme.vars || theme).palette.text.primary,
|
|
17
|
+
shapeRendering: 'crispEdges',
|
|
18
|
+
strokeWidth: 1,
|
|
19
|
+
pointerEvents: 'none'
|
|
20
|
+
},
|
|
21
|
+
[`& .${_chartsReferenceLineClasses.referenceLineClasses.label}`]: (0, _extends2.default)({
|
|
22
|
+
fill: (theme.vars || theme).palette.text.primary,
|
|
23
|
+
stroke: 'none',
|
|
24
|
+
pointerEvents: 'none',
|
|
25
|
+
fontSize: 12
|
|
26
|
+
}, theme.typography.body1)
|
|
27
|
+
}));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _ChartsReferenceLine = require("./ChartsReferenceLine");
|
|
7
|
+
Object.keys(_ChartsReferenceLine).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _ChartsReferenceLine[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _ChartsReferenceLine[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _chartsReferenceLineClasses = require("./chartsReferenceLineClasses");
|
|
18
|
+
Object.keys(_chartsReferenceLineClasses).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _chartsReferenceLineClasses[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _chartsReferenceLineClasses[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
package/ChartsSurface.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SxProps, Theme } from '@mui/
|
|
1
|
+
import { SxProps, Theme } from '@mui/material/styles';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
type ViewBox = {
|
|
4
4
|
x?: number;
|
|
@@ -7,7 +7,13 @@ type ViewBox = {
|
|
|
7
7
|
height?: number;
|
|
8
8
|
};
|
|
9
9
|
export interface ChartsSurfaceProps {
|
|
10
|
+
/**
|
|
11
|
+
* The width of the chart in px.
|
|
12
|
+
*/
|
|
10
13
|
width: number;
|
|
14
|
+
/**
|
|
15
|
+
* The height of the chart in px.
|
|
16
|
+
*/
|
|
11
17
|
height: number;
|
|
12
18
|
viewBox?: ViewBox;
|
|
13
19
|
className?: string;
|
|
@@ -15,6 +21,11 @@ export interface ChartsSurfaceProps {
|
|
|
15
21
|
desc?: string;
|
|
16
22
|
sx?: SxProps<Theme>;
|
|
17
23
|
children?: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* If `true`, the charts will not listen to the mouse move event.
|
|
26
|
+
* It might break interactive features, but will improve performance.
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
18
29
|
disableAxisListener?: boolean;
|
|
19
30
|
}
|
|
20
31
|
export declare const ChartsSurface: React.ForwardRefExoticComponent<ChartsSurfaceProps & React.RefAttributes<SVGSVGElement>>;
|
package/ChartsSurface.js
CHANGED
|
@@ -7,25 +7,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.ChartsSurface = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
|
-
var
|
|
10
|
+
var _styles = require("@mui/material/styles");
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _useAxisEvents = require("./hooks/useAxisEvents");
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
const _excluded = ["children", "width", "height", "viewBox", "disableAxisListener", "className"
|
|
15
|
-
function _getRequireWildcardCache(
|
|
16
|
-
function _interopRequireWildcard(
|
|
17
|
-
const ChartChartsSurfaceStyles = (0,
|
|
14
|
+
const _excluded = ["children", "width", "height", "viewBox", "disableAxisListener", "className"];
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
17
|
+
const ChartChartsSurfaceStyles = (0, _styles.styled)('svg', {
|
|
18
18
|
name: 'MuiChartsSurface',
|
|
19
19
|
slot: 'Root'
|
|
20
20
|
})(() => ({}));
|
|
21
|
-
const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props, ref) {
|
|
21
|
+
const ChartsSurface = exports.ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props, ref) {
|
|
22
22
|
const {
|
|
23
23
|
children,
|
|
24
24
|
width,
|
|
25
25
|
height,
|
|
26
26
|
viewBox,
|
|
27
|
-
disableAxisListener = false
|
|
28
|
-
sx
|
|
27
|
+
disableAxisListener = false
|
|
29
28
|
} = props,
|
|
30
29
|
other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
|
31
30
|
const svgView = (0, _extends2.default)({
|
|
@@ -39,14 +38,7 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
|
|
|
39
38
|
width: width,
|
|
40
39
|
height: height,
|
|
41
40
|
viewBox: `${svgView.x} ${svgView.y} ${svgView.width} ${svgView.height}`,
|
|
42
|
-
ref: ref
|
|
43
|
-
sx: [{
|
|
44
|
-
'--ChartsLegend-itemWidth': '100px',
|
|
45
|
-
'--ChartsLegend-itemMarkSize': '20px',
|
|
46
|
-
'--ChartsLegend-rootSpacing': '5px',
|
|
47
|
-
'--ChartsLegend-labelSpacing': '5px',
|
|
48
|
-
'--ChartsLegend-rootOffsetY': '-20px'
|
|
49
|
-
}, ...(Array.isArray(sx) ? sx : [sx])]
|
|
41
|
+
ref: ref
|
|
50
42
|
}, other, {
|
|
51
43
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("title", {
|
|
52
44
|
children: props.title
|
|
@@ -54,5 +46,4 @@ const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(props
|
|
|
54
46
|
children: props.desc
|
|
55
47
|
}), children]
|
|
56
48
|
}));
|
|
57
|
-
});
|
|
58
|
-
exports.ChartsSurface = ChartsSurface;
|
|
49
|
+
});
|
|
@@ -35,6 +35,7 @@ export declare function DefaultChartsAxisContent(props: ChartsAxisContentProps):
|
|
|
35
35
|
export declare function ChartsAxisTooltipContent(props: {
|
|
36
36
|
axisData: AxisInteractionData;
|
|
37
37
|
content?: React.ElementType<ChartsAxisContentProps>;
|
|
38
|
+
contentProps?: Partial<ChartsAxisContentProps>;
|
|
38
39
|
sx?: SxProps<Theme>;
|
|
39
40
|
classes: ChartsAxisContentProps['classes'];
|
|
40
41
|
}): React.JSX.Element;
|
|
@@ -6,14 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.ChartsAxisTooltipContent = ChartsAxisTooltipContent;
|
|
8
8
|
exports.DefaultChartsAxisContent = DefaultChartsAxisContent;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
10
|
var React = _interopRequireWildcard(require("react"));
|
|
10
11
|
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
12
|
+
var _utils = require("@mui/base/utils");
|
|
11
13
|
var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
12
14
|
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
13
15
|
var _ChartsTooltipTable = require("./ChartsTooltipTable");
|
|
14
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
function _getRequireWildcardCache(
|
|
16
|
-
function _interopRequireWildcard(
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
19
|
function DefaultChartsAxisContent(props) {
|
|
18
20
|
const {
|
|
19
21
|
series,
|
|
@@ -29,7 +31,6 @@ function DefaultChartsAxisContent(props) {
|
|
|
29
31
|
const axisFormatter = axis.valueFormatter ?? (v => v.toLocaleString());
|
|
30
32
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipPaper, {
|
|
31
33
|
sx: sx,
|
|
32
|
-
variant: "outlined",
|
|
33
34
|
className: classes.root,
|
|
34
35
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsTooltipTable.ChartsTooltipTable, {
|
|
35
36
|
children: [axisValue != null && !axis.hideTooltip && /*#__PURE__*/(0, _jsxRuntime.jsx)("thead", {
|
|
@@ -48,27 +49,33 @@ function DefaultChartsAxisContent(props) {
|
|
|
48
49
|
label,
|
|
49
50
|
valueFormatter,
|
|
50
51
|
data
|
|
51
|
-
}) =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
52
|
+
}) => {
|
|
53
|
+
const formattedValue = valueFormatter(data[dataIndex]);
|
|
54
|
+
if (formattedValue == null) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ChartsTooltipTable.ChartsTooltipRow, {
|
|
58
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipCell, {
|
|
59
|
+
className: classes.markCell,
|
|
60
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipMark, {
|
|
61
|
+
ownerState: {
|
|
62
|
+
color
|
|
63
|
+
},
|
|
64
|
+
boxShadow: 1
|
|
65
|
+
})
|
|
66
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipCell, {
|
|
67
|
+
className: classes.labelCell,
|
|
68
|
+
children: label ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
69
|
+
children: label
|
|
70
|
+
}) : null
|
|
71
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipCell, {
|
|
72
|
+
className: classes.valueCell,
|
|
73
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
|
|
74
|
+
children: formattedValue
|
|
75
|
+
})
|
|
76
|
+
})]
|
|
77
|
+
}, id);
|
|
78
|
+
})
|
|
72
79
|
})]
|
|
73
80
|
})
|
|
74
81
|
});
|
|
@@ -76,6 +83,7 @@ function DefaultChartsAxisContent(props) {
|
|
|
76
83
|
function ChartsAxisTooltipContent(props) {
|
|
77
84
|
const {
|
|
78
85
|
content,
|
|
86
|
+
contentProps,
|
|
79
87
|
axisData,
|
|
80
88
|
sx,
|
|
81
89
|
classes
|
|
@@ -108,13 +116,19 @@ function ChartsAxisTooltipContent(props) {
|
|
|
108
116
|
return isXaxis ? xAxis[USED_AXIS_ID] : yAxis[USED_AXIS_ID];
|
|
109
117
|
}, [USED_AXIS_ID, isXaxis, xAxis, yAxis]);
|
|
110
118
|
const Content = content ?? DefaultChartsAxisContent;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
const chartTooltipContentProps = (0, _utils.useSlotProps)({
|
|
120
|
+
elementType: Content,
|
|
121
|
+
externalSlotProps: contentProps,
|
|
122
|
+
additionalProps: {
|
|
123
|
+
axisData,
|
|
124
|
+
series: relevantSeries,
|
|
125
|
+
axis: relevantAxis,
|
|
126
|
+
dataIndex,
|
|
127
|
+
axisValue,
|
|
128
|
+
sx,
|
|
129
|
+
classes
|
|
130
|
+
},
|
|
131
|
+
ownerState: {}
|
|
119
132
|
});
|
|
133
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Content, (0, _extends2.default)({}, chartTooltipContentProps));
|
|
120
134
|
}
|
|
@@ -3,7 +3,7 @@ import { SxProps, Theme } from '@mui/material/styles';
|
|
|
3
3
|
import { ItemInteractionData } from '../context/InteractionProvider';
|
|
4
4
|
import { ChartSeriesDefaultized, ChartSeriesType } from '../models/seriesType/config';
|
|
5
5
|
import { ChartsTooltipClasses } from './tooltipClasses';
|
|
6
|
-
export type ChartsItemContentProps<T extends ChartSeriesType> = {
|
|
6
|
+
export type ChartsItemContentProps<T extends ChartSeriesType = ChartSeriesType> = {
|
|
7
7
|
/**
|
|
8
8
|
* The data used to identify the triggered item.
|
|
9
9
|
*/
|
|
@@ -18,10 +18,11 @@ export type ChartsItemContentProps<T extends ChartSeriesType> = {
|
|
|
18
18
|
classes: ChartsTooltipClasses;
|
|
19
19
|
sx?: SxProps<Theme>;
|
|
20
20
|
};
|
|
21
|
-
export declare function DefaultChartsItemContent<T extends ChartSeriesType>(props: ChartsItemContentProps<T>): React.JSX.Element | null;
|
|
21
|
+
export declare function DefaultChartsItemContent<T extends ChartSeriesType = ChartSeriesType>(props: ChartsItemContentProps<T>): React.JSX.Element | null;
|
|
22
22
|
export declare function ChartsItemTooltipContent<T extends ChartSeriesType>(props: {
|
|
23
23
|
itemData: ItemInteractionData<T>;
|
|
24
24
|
content?: React.ElementType<ChartsItemContentProps<T>>;
|
|
25
|
+
contentProps?: Partial<ChartsItemContentProps<T>>;
|
|
25
26
|
sx?: SxProps<Theme>;
|
|
26
27
|
classes: ChartsItemContentProps<T>['classes'];
|
|
27
28
|
}): React.JSX.Element;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.ChartsItemTooltipContent = ChartsItemTooltipContent;
|
|
7
8
|
exports.DefaultChartsItemContent = DefaultChartsItemContent;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
8
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _utils = require("@mui/base/utils");
|
|
9
12
|
var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
10
13
|
var _ChartsTooltipTable = require("./ChartsTooltipTable");
|
|
11
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
function _getRequireWildcardCache(
|
|
13
|
-
function _interopRequireWildcard(
|
|
15
|
+
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); }
|
|
16
|
+
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; }
|
|
14
17
|
function DefaultChartsItemContent(props) {
|
|
15
18
|
const {
|
|
16
19
|
series,
|
|
@@ -37,7 +40,6 @@ function DefaultChartsItemContent(props) {
|
|
|
37
40
|
const formattedValue = series.valueFormatter(series.data[itemData.dataIndex]);
|
|
38
41
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipPaper, {
|
|
39
42
|
sx: sx,
|
|
40
|
-
variant: "outlined",
|
|
41
43
|
className: classes.root,
|
|
42
44
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltipTable.ChartsTooltipTable, {
|
|
43
45
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("tbody", {
|
|
@@ -66,14 +68,21 @@ function ChartsItemTooltipContent(props) {
|
|
|
66
68
|
content,
|
|
67
69
|
itemData,
|
|
68
70
|
sx,
|
|
69
|
-
classes
|
|
71
|
+
classes,
|
|
72
|
+
contentProps
|
|
70
73
|
} = props;
|
|
71
74
|
const series = React.useContext(_SeriesContextProvider.SeriesContext)[itemData.type].series[itemData.seriesId];
|
|
72
75
|
const Content = content ?? DefaultChartsItemContent;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
const chartTooltipContentProps = (0, _utils.useSlotProps)({
|
|
77
|
+
elementType: Content,
|
|
78
|
+
externalSlotProps: contentProps,
|
|
79
|
+
additionalProps: {
|
|
80
|
+
itemData,
|
|
81
|
+
series,
|
|
82
|
+
sx,
|
|
83
|
+
classes
|
|
84
|
+
},
|
|
85
|
+
ownerState: {}
|
|
78
86
|
});
|
|
87
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Content, (0, _extends2.default)({}, chartTooltipContentProps));
|
|
79
88
|
}
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { PopperProps } from '@mui/base/Popper';
|
|
2
3
|
import { TriggerOptions } from './utils';
|
|
3
4
|
import { ChartsItemContentProps } from './ChartsItemTooltipContent';
|
|
4
5
|
import { ChartsAxisContentProps } from './ChartsAxisTooltipContent';
|
|
5
6
|
import { ChartsTooltipClasses } from './tooltipClasses';
|
|
7
|
+
export interface ChartsTooltipSlotsComponent {
|
|
8
|
+
popper?: React.ElementType<PopperProps>;
|
|
9
|
+
axisContent?: React.ElementType<ChartsAxisContentProps>;
|
|
10
|
+
itemContent?: React.ElementType<ChartsItemContentProps>;
|
|
11
|
+
}
|
|
12
|
+
export interface ChartsTooltipSlotComponentProps {
|
|
13
|
+
popper?: Partial<PopperProps>;
|
|
14
|
+
axisContent?: Partial<ChartsAxisContentProps>;
|
|
15
|
+
itemContent?: Partial<ChartsItemContentProps>;
|
|
16
|
+
}
|
|
6
17
|
export type ChartsTooltipProps = {
|
|
7
18
|
/**
|
|
8
19
|
* Select the kind of tooltip to display
|
|
@@ -14,17 +25,38 @@ export type ChartsTooltipProps = {
|
|
|
14
25
|
trigger?: TriggerOptions;
|
|
15
26
|
/**
|
|
16
27
|
* Component to override the tooltip content when triger is set to 'item'.
|
|
28
|
+
* @deprecated Use slots.itemContent instead
|
|
17
29
|
*/
|
|
18
30
|
itemContent?: React.ElementType<ChartsItemContentProps<any>>;
|
|
19
31
|
/**
|
|
20
32
|
* Component to override the tooltip content when triger is set to 'axis'.
|
|
33
|
+
* @deprecated Use slots.axisContent instead
|
|
21
34
|
*/
|
|
22
35
|
axisContent?: React.ElementType<ChartsAxisContentProps>;
|
|
23
36
|
/**
|
|
24
37
|
* Override or extend the styles applied to the component.
|
|
25
38
|
*/
|
|
26
39
|
classes?: Partial<ChartsTooltipClasses>;
|
|
40
|
+
/**
|
|
41
|
+
* Overridable component slots.
|
|
42
|
+
* @default {}
|
|
43
|
+
*/
|
|
44
|
+
slots?: ChartsTooltipSlotsComponent;
|
|
45
|
+
/**
|
|
46
|
+
* The props used for each component slot.
|
|
47
|
+
* @default {}
|
|
48
|
+
*/
|
|
49
|
+
slotProps?: ChartsTooltipSlotComponentProps;
|
|
27
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Demos:
|
|
53
|
+
*
|
|
54
|
+
* - [ChartsTooltip](https://mui.com/x/react-charts/tooltip/)
|
|
55
|
+
*
|
|
56
|
+
* API:
|
|
57
|
+
*
|
|
58
|
+
* - [ChartsTooltip API](https://mui.com/x/api/charts/charts-tool-tip/)
|
|
59
|
+
*/
|
|
28
60
|
declare function ChartsTooltip(props: ChartsTooltipProps): React.JSX.Element | null;
|
|
29
61
|
declare namespace ChartsTooltip {
|
|
30
62
|
var propTypes: any;
|