@mui/x-charts 7.0.0-alpha.9 → 7.0.0-beta.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 +2 -1
- package/BarChart/BarChart.js +24 -23
- package/BarChart/BarElement.d.ts +1 -1
- package/BarChart/BarElement.js +6 -3
- package/BarChart/BarPlot.d.ts +8 -1
- package/BarChart/BarPlot.js +19 -5
- package/BarChart/formatter.js +1 -1
- package/CHANGELOG.md +386 -38
- package/ChartContainer/ChartContainer.d.ts +12 -0
- package/ChartContainer/ChartContainer.js +197 -0
- package/ChartContainer/index.d.ts +1 -11
- package/ChartContainer/index.js +9 -63
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.d.ts +20 -0
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +83 -0
- package/ChartsOnAxisClickHandler/index.d.ts +1 -0
- package/ChartsOnAxisClickHandler/index.js +16 -0
- package/ChartsOnAxisClickHandler/package.json +6 -0
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +8 -59
- package/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +8 -58
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
- package/ChartsTooltip/utils.d.ts +3 -1
- package/ChartsTooltip/utils.js +8 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +7 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/LineChart/AnimatedArea.d.ts +1361 -0
- package/LineChart/AnimatedArea.js +111 -0
- package/LineChart/AnimatedLine.d.ts +1361 -0
- package/LineChart/AnimatedLine.js +113 -0
- package/LineChart/AreaElement.d.ts +17 -17
- package/LineChart/AreaElement.js +17 -34
- package/LineChart/AreaPlot.d.ts +12 -7
- package/LineChart/AreaPlot.js +91 -58
- package/LineChart/LineChart.d.ts +13 -4
- package/LineChart/LineChart.js +36 -29
- package/LineChart/LineElement.d.ts +17 -17
- package/LineChart/LineElement.js +16 -36
- package/LineChart/LineHighlightElement.js +3 -2
- package/LineChart/LinePlot.d.ts +12 -7
- package/LineChart/LinePlot.js +89 -56
- package/LineChart/MarkElement.d.ts +5 -2
- package/LineChart/MarkElement.js +26 -13
- package/LineChart/MarkPlot.d.ts +8 -1
- package/LineChart/MarkPlot.js +80 -51
- package/LineChart/formatter.js +1 -1
- package/LineChart/index.d.ts +2 -0
- package/LineChart/index.js +22 -0
- package/PieChart/PieArcLabelPlot.d.ts +1 -1
- package/PieChart/PieArcLabelPlot.js +1 -1
- package/PieChart/PieArcPlot.d.ts +2 -2
- package/PieChart/PieArcPlot.js +6 -6
- package/PieChart/PieChart.d.ts +1 -1
- package/PieChart/PieChart.js +5 -50
- package/PieChart/PiePlot.d.ts +1 -1
- package/PieChart/PiePlot.js +4 -4
- package/README.md +2 -2
- package/ResponsiveChartContainer/ResponsiveChartContainer.d.ts +16 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +250 -0
- package/ResponsiveChartContainer/index.d.ts +1 -15
- package/ResponsiveChartContainer/index.js +8 -113
- package/ScatterChart/Scatter.d.ts +7 -1
- package/ScatterChart/Scatter.js +18 -23
- package/ScatterChart/ScatterChart.d.ts +8 -2
- package/ScatterChart/ScatterChart.js +12 -22
- package/ScatterChart/ScatterPlot.d.ts +1 -1
- package/ScatterChart/ScatterPlot.js +10 -2
- package/SparkLineChart/SparkLineChart.js +2 -0
- package/context/DrawingProvider.d.ts +6 -1
- package/context/DrawingProvider.js +9 -2
- package/context/InteractionProvider.d.ts +3 -3
- package/esm/BarChart/BarChart.js +24 -23
- package/esm/BarChart/BarElement.js +6 -3
- package/esm/BarChart/BarPlot.js +19 -5
- package/esm/BarChart/formatter.js +1 -1
- package/esm/ChartContainer/ChartContainer.js +189 -0
- package/esm/ChartContainer/index.js +1 -61
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +77 -0
- package/esm/ChartsOnAxisClickHandler/index.js +1 -0
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +8 -59
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +9 -58
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
- package/esm/ChartsTooltip/utils.js +6 -0
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/esm/LineChart/AnimatedArea.js +103 -0
- package/esm/LineChart/AnimatedLine.js +105 -0
- package/esm/LineChart/AreaElement.js +16 -33
- package/esm/LineChart/AreaPlot.js +92 -59
- package/esm/LineChart/LineChart.js +36 -29
- package/esm/LineChart/LineElement.js +16 -35
- package/esm/LineChart/LineHighlightElement.js +3 -2
- package/esm/LineChart/LinePlot.js +90 -57
- package/esm/LineChart/MarkElement.js +26 -13
- package/esm/LineChart/MarkPlot.js +80 -51
- package/esm/LineChart/formatter.js +1 -1
- package/esm/LineChart/index.js +2 -0
- package/esm/PieChart/PieArcLabelPlot.js +1 -1
- package/esm/PieChart/PieArcPlot.js +6 -6
- package/esm/PieChart/PieChart.js +5 -50
- package/esm/PieChart/PiePlot.js +4 -4
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +245 -0
- package/esm/ResponsiveChartContainer/index.js +1 -115
- package/esm/ScatterChart/Scatter.js +18 -23
- package/esm/ScatterChart/ScatterChart.js +12 -22
- package/esm/ScatterChart/ScatterPlot.js +10 -2
- package/esm/SparkLineChart/SparkLineChart.js +2 -0
- package/esm/context/DrawingProvider.js +9 -2
- package/esm/hooks/useDrawingArea.js +7 -3
- package/esm/index.js +1 -0
- package/esm/internals/geometry.js +1 -1
- package/esm/internals/useAnimatedPath.js +29 -0
- package/esm/internals/utils.js +7 -0
- package/hooks/useDrawingArea.d.ts +2 -0
- package/hooks/useDrawingArea.js +7 -3
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/geometry.js +1 -1
- package/internals/useAnimatedPath.d.ts +1 -0
- package/internals/useAnimatedPath.js +38 -0
- package/internals/utils.d.ts +4 -0
- package/internals/utils.js +8 -0
- package/legacy/BarChart/BarChart.js +24 -23
- package/legacy/BarChart/BarElement.js +5 -2
- package/legacy/BarChart/BarPlot.js +18 -4
- package/legacy/BarChart/formatter.js +1 -1
- package/legacy/ChartContainer/ChartContainer.js +187 -0
- package/legacy/ChartContainer/index.js +1 -59
- package/legacy/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/legacy/ChartsOnAxisClickHandler/index.js +1 -0
- package/legacy/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/legacy/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +8 -61
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +9 -58
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
- package/legacy/ChartsTooltip/utils.js +6 -0
- package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +88 -44
- package/legacy/LineChart/AnimatedArea.js +102 -0
- package/legacy/LineChart/AnimatedLine.js +104 -0
- package/legacy/LineChart/AreaElement.js +15 -35
- package/legacy/LineChart/AreaPlot.js +102 -66
- package/legacy/LineChart/LineChart.js +36 -29
- package/legacy/LineChart/LineElement.js +15 -37
- package/legacy/LineChart/LineHighlightElement.js +3 -2
- package/legacy/LineChart/LinePlot.js +97 -63
- package/legacy/LineChart/MarkElement.js +29 -12
- package/legacy/LineChart/MarkPlot.js +83 -53
- package/legacy/LineChart/formatter.js +1 -1
- package/legacy/LineChart/index.js +2 -0
- package/legacy/PieChart/PieArcLabelPlot.js +1 -1
- package/legacy/PieChart/PieArcPlot.js +6 -6
- package/legacy/PieChart/PieChart.js +5 -50
- package/legacy/PieChart/PiePlot.js +4 -4
- package/legacy/ResponsiveChartContainer/ResponsiveChartContainer.js +253 -0
- package/legacy/ResponsiveChartContainer/index.js +1 -123
- package/legacy/ScatterChart/Scatter.js +20 -23
- package/legacy/ScatterChart/ScatterChart.js +12 -22
- package/legacy/ScatterChart/ScatterPlot.js +10 -2
- package/legacy/SparkLineChart/SparkLineChart.js +2 -0
- package/legacy/context/DrawingProvider.js +11 -2
- package/legacy/hooks/useDrawingArea.js +7 -3
- package/legacy/index.js +2 -1
- package/legacy/internals/geometry.js +1 -1
- package/legacy/internals/useAnimatedPath.js +32 -0
- package/legacy/internals/utils.js +7 -0
- package/modern/BarChart/BarChart.js +24 -23
- package/modern/BarChart/BarElement.js +6 -3
- package/modern/BarChart/BarPlot.js +19 -5
- package/modern/BarChart/formatter.js +1 -1
- package/modern/ChartContainer/ChartContainer.js +189 -0
- package/modern/ChartContainer/index.js +1 -61
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +75 -0
- package/modern/ChartsOnAxisClickHandler/index.js +1 -0
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +1 -1
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +1 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +8 -59
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +1 -11
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +8 -58
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +1 -11
- package/modern/ChartsTooltip/utils.js +6 -0
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +92 -44
- package/modern/LineChart/AnimatedArea.js +103 -0
- package/modern/LineChart/AnimatedLine.js +105 -0
- package/modern/LineChart/AreaElement.js +16 -33
- package/modern/LineChart/AreaPlot.js +91 -58
- package/modern/LineChart/LineChart.js +36 -29
- package/modern/LineChart/LineElement.js +16 -35
- package/modern/LineChart/LineHighlightElement.js +3 -2
- package/modern/LineChart/LinePlot.js +89 -56
- package/modern/LineChart/MarkElement.js +26 -13
- package/modern/LineChart/MarkPlot.js +80 -51
- package/modern/LineChart/formatter.js +1 -1
- package/modern/LineChart/index.js +2 -0
- package/modern/PieChart/PieArcLabelPlot.js +1 -1
- package/modern/PieChart/PieArcPlot.js +6 -6
- package/modern/PieChart/PieChart.js +5 -50
- package/modern/PieChart/PiePlot.js +4 -4
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +242 -0
- package/modern/ResponsiveChartContainer/index.js +1 -112
- package/modern/ScatterChart/Scatter.js +18 -23
- package/modern/ScatterChart/ScatterChart.js +12 -22
- package/modern/ScatterChart/ScatterPlot.js +10 -2
- package/modern/SparkLineChart/SparkLineChart.js +2 -0
- package/modern/context/DrawingProvider.js +9 -2
- package/modern/hooks/useDrawingArea.js +7 -3
- package/modern/index.js +2 -1
- package/modern/internals/geometry.js +1 -1
- package/modern/internals/useAnimatedPath.js +29 -0
- package/modern/internals/utils.js +7 -0
- package/package.json +6 -5
package/hooks/useDrawingArea.js
CHANGED
|
@@ -13,12 +13,16 @@ function useDrawingArea() {
|
|
|
13
13
|
left,
|
|
14
14
|
top,
|
|
15
15
|
width,
|
|
16
|
-
height
|
|
16
|
+
height,
|
|
17
|
+
bottom,
|
|
18
|
+
right
|
|
17
19
|
} = React.useContext(_DrawingProvider.DrawingContext);
|
|
18
20
|
return React.useMemo(() => ({
|
|
19
21
|
left,
|
|
20
22
|
top,
|
|
21
23
|
width,
|
|
22
|
-
height
|
|
23
|
-
|
|
24
|
+
height,
|
|
25
|
+
bottom,
|
|
26
|
+
right
|
|
27
|
+
}), [height, left, top, width, bottom, right]);
|
|
24
28
|
}
|
package/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export * from './ChartsTooltip';
|
|
|
13
13
|
export * from './ChartsLegend';
|
|
14
14
|
export * from './ChartsAxisHighlight';
|
|
15
15
|
export * from './ChartsVoronoiHandler';
|
|
16
|
+
export * from './ChartsOnAxisClickHandler';
|
|
16
17
|
export * from './BarChart';
|
|
17
18
|
export * from './LineChart';
|
|
18
19
|
export * from './PieChart';
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @mui/x-charts v7.0.0-
|
|
2
|
+
* @mui/x-charts v7.0.0-beta.1
|
|
3
3
|
*
|
|
4
4
|
* @license MIT
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
@@ -175,6 +175,17 @@ Object.keys(_ChartsVoronoiHandler).forEach(function (key) {
|
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
177
|
});
|
|
178
|
+
var _ChartsOnAxisClickHandler = require("./ChartsOnAxisClickHandler");
|
|
179
|
+
Object.keys(_ChartsOnAxisClickHandler).forEach(function (key) {
|
|
180
|
+
if (key === "default" || key === "__esModule") return;
|
|
181
|
+
if (key in exports && exports[key] === _ChartsOnAxisClickHandler[key]) return;
|
|
182
|
+
Object.defineProperty(exports, key, {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
get: function () {
|
|
185
|
+
return _ChartsOnAxisClickHandler[key];
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
178
189
|
var _BarChart = require("./BarChart");
|
|
179
190
|
Object.keys(_BarChart).forEach(function (key) {
|
|
180
191
|
if (key === "default" || key === "__esModule") return;
|
package/internals/geometry.js
CHANGED
|
@@ -20,7 +20,7 @@ function getMinXTranslation(width, height, angle = 0) {
|
|
|
20
20
|
if (process.env.NODE_ENV !== 'production') {
|
|
21
21
|
if (!warnedOnce && angle > 90 && angle < -90) {
|
|
22
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'));
|
|
23
|
+
console.warn([`MUI X Charts: 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
24
|
}
|
|
25
25
|
}
|
|
26
26
|
const standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useAnimatedPath: (path: string, skipAnimation?: boolean) => import("@react-spring/core").Interpolation<string, any>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAnimatedPath = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _d3Interpolate = require("d3-interpolate");
|
|
9
|
+
var _web = require("@react-spring/web");
|
|
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 usePrevious(value) {
|
|
13
|
+
const ref = React.useRef(null);
|
|
14
|
+
React.useEffect(() => {
|
|
15
|
+
ref.current = value;
|
|
16
|
+
}, [value]);
|
|
17
|
+
return ref.current;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Taken from Nivo
|
|
21
|
+
const useAnimatedPath = (path, skipAnimation) => {
|
|
22
|
+
const previousPath = usePrevious(path);
|
|
23
|
+
const interpolator = React.useMemo(() => previousPath ? (0, _d3Interpolate.interpolateString)(previousPath, path) : () => path, [previousPath, path]);
|
|
24
|
+
const {
|
|
25
|
+
value
|
|
26
|
+
} = (0, _web.useSpring)({
|
|
27
|
+
from: {
|
|
28
|
+
value: 0
|
|
29
|
+
},
|
|
30
|
+
to: {
|
|
31
|
+
value: 1
|
|
32
|
+
},
|
|
33
|
+
reset: true,
|
|
34
|
+
immediate: skipAnimation
|
|
35
|
+
});
|
|
36
|
+
return (0, _web.to)([value], interpolator);
|
|
37
|
+
};
|
|
38
|
+
exports.useAnimatedPath = useAnimatedPath;
|
package/internals/utils.d.ts
CHANGED
|
@@ -17,4 +17,8 @@ export declare function getSVGPoint(svg: SVGSVGElement, event: MouseEvent): DOMP
|
|
|
17
17
|
* @returns The numerical value associated to the provided value.
|
|
18
18
|
*/
|
|
19
19
|
export declare function getPercentageValue(value: number | string, refValue: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Remove spaces to have viable ids
|
|
22
|
+
*/
|
|
23
|
+
export declare function cleanId(id: string): string;
|
|
20
24
|
export {};
|
package/internals/utils.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.cleanId = cleanId;
|
|
6
7
|
exports.getPercentageValue = getPercentageValue;
|
|
7
8
|
exports.getSVGPoint = getSVGPoint;
|
|
8
9
|
exports.getSymbol = getSymbol;
|
|
@@ -50,4 +51,11 @@ function getPercentageValue(value, refValue) {
|
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
throw Error(`MUI-Charts: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Remove spaces to have viable ids
|
|
58
|
+
*/
|
|
59
|
+
function cleanId(id) {
|
|
60
|
+
return id.replace(' ', '_');
|
|
53
61
|
}
|
|
@@ -11,6 +11,7 @@ import { ChartsTooltip } from '../ChartsTooltip';
|
|
|
11
11
|
import { ChartsLegend } from '../ChartsLegend';
|
|
12
12
|
import { ChartsAxisHighlight } from '../ChartsAxisHighlight';
|
|
13
13
|
import { ChartsClipPath } from '../ChartsClipPath';
|
|
14
|
+
import { ChartsOnAxisClickHandler } from '../ChartsOnAxisClickHandler';
|
|
14
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
17
|
/**
|
|
@@ -43,6 +44,8 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
43
44
|
rightAxis = props.rightAxis,
|
|
44
45
|
bottomAxis = props.bottomAxis,
|
|
45
46
|
skipAnimation = props.skipAnimation,
|
|
47
|
+
onItemClick = props.onItemClick,
|
|
48
|
+
onAxisClick = props.onAxisClick,
|
|
46
49
|
children = props.children,
|
|
47
50
|
slots = props.slots,
|
|
48
51
|
slotProps = props.slotProps;
|
|
@@ -88,13 +91,16 @@ var BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
88
91
|
colors: colors,
|
|
89
92
|
dataset: dataset,
|
|
90
93
|
sx: sx,
|
|
91
|
-
disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none',
|
|
92
|
-
children: [/*#__PURE__*/_jsx(
|
|
94
|
+
disableAxisListener: (tooltip == null ? void 0 : tooltip.trigger) !== 'axis' && (axisHighlight == null ? void 0 : axisHighlight.x) === 'none' && (axisHighlight == null ? void 0 : axisHighlight.y) === 'none' && !onAxisClick,
|
|
95
|
+
children: [onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, {
|
|
96
|
+
onAxisClick: onAxisClick
|
|
97
|
+
}), /*#__PURE__*/_jsx("g", {
|
|
93
98
|
clipPath: "url(#".concat(clipPathId, ")"),
|
|
94
99
|
children: /*#__PURE__*/_jsx(BarPlot, {
|
|
95
100
|
slots: slots,
|
|
96
101
|
slotProps: slotProps,
|
|
97
|
-
skipAnimation: skipAnimation
|
|
102
|
+
skipAnimation: skipAnimation,
|
|
103
|
+
onItemClick: onItemClick
|
|
98
104
|
})
|
|
99
105
|
}), /*#__PURE__*/_jsx(ChartsAxis, {
|
|
100
106
|
topAxis: topAxis,
|
|
@@ -234,6 +240,19 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
234
240
|
right: PropTypes.number,
|
|
235
241
|
top: PropTypes.number
|
|
236
242
|
}),
|
|
243
|
+
/**
|
|
244
|
+
* The function called for onClick events.
|
|
245
|
+
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
246
|
+
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
247
|
+
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
248
|
+
*/
|
|
249
|
+
onAxisClick: PropTypes.func,
|
|
250
|
+
/**
|
|
251
|
+
* Callback fired when a bar item is clicked.
|
|
252
|
+
* @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
|
|
253
|
+
* @param {BarItemIdentifier} barItemIdentifier The bar item identifier.
|
|
254
|
+
*/
|
|
255
|
+
onItemClick: PropTypes.func,
|
|
237
256
|
/**
|
|
238
257
|
* Indicate which axis to display the right of the charts.
|
|
239
258
|
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
@@ -261,27 +280,9 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
261
280
|
tickNumber: PropTypes.number,
|
|
262
281
|
tickSize: PropTypes.number
|
|
263
282
|
}), PropTypes.string]),
|
|
264
|
-
series: PropTypes.arrayOf(PropTypes.
|
|
265
|
-
color: PropTypes.string,
|
|
266
|
-
data: PropTypes.arrayOf(PropTypes.number),
|
|
267
|
-
dataKey: PropTypes.string,
|
|
268
|
-
highlightScope: PropTypes.shape({
|
|
269
|
-
faded: PropTypes.oneOf(['global', 'none', 'series']),
|
|
270
|
-
highlighted: PropTypes.oneOf(['item', 'none', 'series'])
|
|
271
|
-
}),
|
|
272
|
-
id: PropTypes.string,
|
|
273
|
-
label: PropTypes.string,
|
|
274
|
-
layout: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
275
|
-
stack: PropTypes.string,
|
|
276
|
-
stackOffset: PropTypes.oneOf(['diverging', 'expand', 'none', 'silhouette', 'wiggle']),
|
|
277
|
-
stackOrder: PropTypes.oneOf(['appearance', 'ascending', 'descending', 'insideOut', 'none', 'reverse']),
|
|
278
|
-
type: PropTypes.oneOf(['bar']),
|
|
279
|
-
valueFormatter: PropTypes.func,
|
|
280
|
-
xAxisKey: PropTypes.string,
|
|
281
|
-
yAxisKey: PropTypes.string
|
|
282
|
-
})).isRequired,
|
|
283
|
+
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
283
284
|
/**
|
|
284
|
-
* If `true`, animations are
|
|
285
|
+
* If `true`, animations are skipped.
|
|
285
286
|
* @default false
|
|
286
287
|
*/
|
|
287
288
|
skipAnimation: PropTypes.bool,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps", "style"];
|
|
3
|
+
var _excluded = ["id", "dataIndex", "classes", "color", "highlightScope", "slots", "slotProps", "style", "onClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
@@ -51,6 +51,7 @@ function BarElement(props) {
|
|
|
51
51
|
slots = props.slots,
|
|
52
52
|
slotProps = props.slotProps,
|
|
53
53
|
style = props.style,
|
|
54
|
+
onClick = props.onClick,
|
|
54
55
|
other = _objectWithoutProperties(props, _excluded);
|
|
55
56
|
var getInteractionItemProps = useInteractionItemProps(highlightScope);
|
|
56
57
|
var _React$useContext = React.useContext(InteractionContext),
|
|
@@ -84,7 +85,9 @@ function BarElement(props) {
|
|
|
84
85
|
dataIndex: dataIndex
|
|
85
86
|
}), {
|
|
86
87
|
style: style,
|
|
87
|
-
className: classes.root
|
|
88
|
+
className: classes.root,
|
|
89
|
+
onClick: onClick,
|
|
90
|
+
cursor: onClick ? 'pointer' : 'unset'
|
|
88
91
|
}),
|
|
89
92
|
ownerState: ownerState
|
|
90
93
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
-
var _excluded = ["skipAnimation"];
|
|
4
|
+
var _excluded = ["skipAnimation", "onItemClick"];
|
|
5
5
|
import * as React from 'react';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
7
|
import { useTransition } from '@react-spring/web';
|
|
@@ -38,7 +38,7 @@ function getBandSize(_ref) {
|
|
|
38
38
|
offset: offset
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
var
|
|
41
|
+
var useAggregatedData = function useAggregatedData() {
|
|
42
42
|
var _React$useContext$bar;
|
|
43
43
|
var seriesData = (_React$useContext$bar = React.useContext(SeriesContext).bar) != null ? _React$useContext$bar : {
|
|
44
44
|
series: {},
|
|
@@ -164,8 +164,9 @@ var getInStyle = function getInStyle(_ref4) {
|
|
|
164
164
|
* - [BarPlot API](https://mui.com/x/api/charts/bar-plot/)
|
|
165
165
|
*/
|
|
166
166
|
function BarPlot(props) {
|
|
167
|
-
var completedData =
|
|
167
|
+
var completedData = useAggregatedData();
|
|
168
168
|
var skipAnimation = props.skipAnimation,
|
|
169
|
+
onItemClick = props.onItemClick,
|
|
169
170
|
other = _objectWithoutProperties(props, _excluded);
|
|
170
171
|
var transition = useTransition(completedData, {
|
|
171
172
|
keys: function keys(bar) {
|
|
@@ -189,6 +190,13 @@ function BarPlot(props) {
|
|
|
189
190
|
highlightScope: highlightScope,
|
|
190
191
|
color: color
|
|
191
192
|
}, other, {
|
|
193
|
+
onClick: onItemClick && function (event) {
|
|
194
|
+
onItemClick(event, {
|
|
195
|
+
type: 'bar',
|
|
196
|
+
seriesId: seriesId,
|
|
197
|
+
dataIndex: dataIndex
|
|
198
|
+
});
|
|
199
|
+
},
|
|
192
200
|
style: style
|
|
193
201
|
}));
|
|
194
202
|
})
|
|
@@ -200,7 +208,13 @@ process.env.NODE_ENV !== "production" ? BarPlot.propTypes = {
|
|
|
200
208
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
201
209
|
// ----------------------------------------------------------------------
|
|
202
210
|
/**
|
|
203
|
-
*
|
|
211
|
+
* Callback fired when a bar item is clicked.
|
|
212
|
+
* @param {React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
|
|
213
|
+
* @param {BarItemIdentifier} barItemIdentifier The bar item identifier.
|
|
214
|
+
*/
|
|
215
|
+
onItemClick: PropTypes.func,
|
|
216
|
+
/**
|
|
217
|
+
* If `true`, animations are skipped.
|
|
204
218
|
* @default false
|
|
205
219
|
*/
|
|
206
220
|
skipAnimation: PropTypes.bool,
|
|
@@ -71,7 +71,7 @@ var formatter = function formatter(params, dataset) {
|
|
|
71
71
|
seriesOrder: seriesOrder,
|
|
72
72
|
stackingGroups: stackingGroups,
|
|
73
73
|
series: defaultizeValueFormatter(completedSeries, function (v) {
|
|
74
|
-
return v
|
|
74
|
+
return v == null ? '' : v.toLocaleString();
|
|
75
75
|
})
|
|
76
76
|
};
|
|
77
77
|
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import useForkRef from '@mui/utils/useForkRef';
|
|
4
|
+
import { DrawingProvider } from '../context/DrawingProvider';
|
|
5
|
+
import { SeriesContextProvider } from '../context/SeriesContextProvider';
|
|
6
|
+
import { InteractionProvider } from '../context/InteractionProvider';
|
|
7
|
+
import { useReducedMotion } from '../hooks/useReducedMotion';
|
|
8
|
+
import { ChartsSurface } from '../ChartsSurface';
|
|
9
|
+
import { CartesianContextProvider } from '../context/CartesianContextProvider';
|
|
10
|
+
import { HighlightProvider } from '../context/HighlightProvider';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
var ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
|
|
13
|
+
var width = props.width,
|
|
14
|
+
height = props.height,
|
|
15
|
+
series = props.series,
|
|
16
|
+
margin = props.margin,
|
|
17
|
+
xAxis = props.xAxis,
|
|
18
|
+
yAxis = props.yAxis,
|
|
19
|
+
colors = props.colors,
|
|
20
|
+
dataset = props.dataset,
|
|
21
|
+
sx = props.sx,
|
|
22
|
+
title = props.title,
|
|
23
|
+
desc = props.desc,
|
|
24
|
+
disableAxisListener = props.disableAxisListener,
|
|
25
|
+
children = props.children;
|
|
26
|
+
var svgRef = React.useRef(null);
|
|
27
|
+
var handleRef = useForkRef(ref, svgRef);
|
|
28
|
+
useReducedMotion(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
|
|
29
|
+
|
|
30
|
+
return /*#__PURE__*/_jsx(DrawingProvider, {
|
|
31
|
+
width: width,
|
|
32
|
+
height: height,
|
|
33
|
+
margin: margin,
|
|
34
|
+
svgRef: svgRef,
|
|
35
|
+
children: /*#__PURE__*/_jsx(SeriesContextProvider, {
|
|
36
|
+
series: series,
|
|
37
|
+
colors: colors,
|
|
38
|
+
dataset: dataset,
|
|
39
|
+
children: /*#__PURE__*/_jsx(CartesianContextProvider, {
|
|
40
|
+
xAxis: xAxis,
|
|
41
|
+
yAxis: yAxis,
|
|
42
|
+
dataset: dataset,
|
|
43
|
+
children: /*#__PURE__*/_jsx(InteractionProvider, {
|
|
44
|
+
children: /*#__PURE__*/_jsx(HighlightProvider, {
|
|
45
|
+
children: /*#__PURE__*/_jsx(ChartsSurface, {
|
|
46
|
+
width: width,
|
|
47
|
+
height: height,
|
|
48
|
+
ref: handleRef,
|
|
49
|
+
sx: sx,
|
|
50
|
+
title: title,
|
|
51
|
+
desc: desc,
|
|
52
|
+
disableAxisListener: disableAxisListener,
|
|
53
|
+
children: children
|
|
54
|
+
})
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
62
|
+
// ----------------------------- Warning --------------------------------
|
|
63
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
64
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
65
|
+
// ----------------------------------------------------------------------
|
|
66
|
+
children: PropTypes.node,
|
|
67
|
+
className: PropTypes.string,
|
|
68
|
+
/**
|
|
69
|
+
* Color palette used to colorize multiple series.
|
|
70
|
+
* @default blueberryTwilightPalette
|
|
71
|
+
*/
|
|
72
|
+
colors: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.func]),
|
|
73
|
+
/**
|
|
74
|
+
* An array of objects that can be used to populate series and axes data using their `dataKey` property.
|
|
75
|
+
*/
|
|
76
|
+
dataset: PropTypes.arrayOf(PropTypes.object),
|
|
77
|
+
desc: PropTypes.string,
|
|
78
|
+
/**
|
|
79
|
+
* If `true`, the charts will not listen to the mouse move event.
|
|
80
|
+
* It might break interactive features, but will improve performance.
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
disableAxisListener: PropTypes.bool,
|
|
84
|
+
/**
|
|
85
|
+
* The height of the chart in px.
|
|
86
|
+
*/
|
|
87
|
+
height: PropTypes.number.isRequired,
|
|
88
|
+
/**
|
|
89
|
+
* The margin between the SVG and the drawing area.
|
|
90
|
+
* It's used for leaving some space for extra information such as the x- and y-axis or legend.
|
|
91
|
+
* Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`.
|
|
92
|
+
* @default object Depends on the charts type.
|
|
93
|
+
*/
|
|
94
|
+
margin: PropTypes.shape({
|
|
95
|
+
bottom: PropTypes.number,
|
|
96
|
+
left: PropTypes.number,
|
|
97
|
+
right: PropTypes.number,
|
|
98
|
+
top: PropTypes.number
|
|
99
|
+
}),
|
|
100
|
+
/**
|
|
101
|
+
* The array of series to display.
|
|
102
|
+
* Each type of series has its own specificity.
|
|
103
|
+
* Please refer to the appropriate docs page to learn more about it.
|
|
104
|
+
*/
|
|
105
|
+
series: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
106
|
+
sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]),
|
|
107
|
+
title: PropTypes.string,
|
|
108
|
+
viewBox: PropTypes.shape({
|
|
109
|
+
height: PropTypes.number,
|
|
110
|
+
width: PropTypes.number,
|
|
111
|
+
x: PropTypes.number,
|
|
112
|
+
y: PropTypes.number
|
|
113
|
+
}),
|
|
114
|
+
/**
|
|
115
|
+
* The width of the chart in px.
|
|
116
|
+
*/
|
|
117
|
+
width: PropTypes.number.isRequired,
|
|
118
|
+
/**
|
|
119
|
+
* The configuration of the x-axes.
|
|
120
|
+
* If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`.
|
|
121
|
+
*/
|
|
122
|
+
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
123
|
+
axisId: PropTypes.string,
|
|
124
|
+
classes: PropTypes.object,
|
|
125
|
+
data: PropTypes.array,
|
|
126
|
+
dataKey: PropTypes.string,
|
|
127
|
+
disableLine: PropTypes.bool,
|
|
128
|
+
disableTicks: PropTypes.bool,
|
|
129
|
+
fill: PropTypes.string,
|
|
130
|
+
hideTooltip: PropTypes.bool,
|
|
131
|
+
id: PropTypes.string,
|
|
132
|
+
label: PropTypes.string,
|
|
133
|
+
labelFontSize: PropTypes.number,
|
|
134
|
+
labelStyle: PropTypes.object,
|
|
135
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
136
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
137
|
+
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
138
|
+
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
139
|
+
slotProps: PropTypes.object,
|
|
140
|
+
slots: PropTypes.object,
|
|
141
|
+
stroke: PropTypes.string,
|
|
142
|
+
tickFontSize: PropTypes.number,
|
|
143
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
144
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
145
|
+
tickLabelStyle: PropTypes.object,
|
|
146
|
+
tickMaxStep: PropTypes.number,
|
|
147
|
+
tickMinStep: PropTypes.number,
|
|
148
|
+
tickNumber: PropTypes.number,
|
|
149
|
+
tickSize: PropTypes.number,
|
|
150
|
+
valueFormatter: PropTypes.func
|
|
151
|
+
})),
|
|
152
|
+
/**
|
|
153
|
+
* The configuration of the y-axes.
|
|
154
|
+
* If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`.
|
|
155
|
+
*/
|
|
156
|
+
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
157
|
+
axisId: PropTypes.string,
|
|
158
|
+
classes: PropTypes.object,
|
|
159
|
+
data: PropTypes.array,
|
|
160
|
+
dataKey: PropTypes.string,
|
|
161
|
+
disableLine: PropTypes.bool,
|
|
162
|
+
disableTicks: PropTypes.bool,
|
|
163
|
+
fill: PropTypes.string,
|
|
164
|
+
hideTooltip: PropTypes.bool,
|
|
165
|
+
id: PropTypes.string,
|
|
166
|
+
label: PropTypes.string,
|
|
167
|
+
labelFontSize: PropTypes.number,
|
|
168
|
+
labelStyle: PropTypes.object,
|
|
169
|
+
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
170
|
+
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
171
|
+
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
172
|
+
scaleType: PropTypes.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']),
|
|
173
|
+
slotProps: PropTypes.object,
|
|
174
|
+
slots: PropTypes.object,
|
|
175
|
+
stroke: PropTypes.string,
|
|
176
|
+
tickFontSize: PropTypes.number,
|
|
177
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
178
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
179
|
+
tickLabelStyle: PropTypes.object,
|
|
180
|
+
tickMaxStep: PropTypes.number,
|
|
181
|
+
tickMinStep: PropTypes.number,
|
|
182
|
+
tickNumber: PropTypes.number,
|
|
183
|
+
tickSize: PropTypes.number,
|
|
184
|
+
valueFormatter: PropTypes.func
|
|
185
|
+
}))
|
|
186
|
+
} : void 0;
|
|
187
|
+
export { ChartContainer };
|
|
@@ -1,59 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import useForkRef from '@mui/utils/useForkRef';
|
|
3
|
-
import { DrawingProvider } from '../context/DrawingProvider';
|
|
4
|
-
import { SeriesContextProvider } from '../context/SeriesContextProvider';
|
|
5
|
-
import { InteractionProvider } from '../context/InteractionProvider';
|
|
6
|
-
import { useReducedMotion } from '../hooks/useReducedMotion';
|
|
7
|
-
import { ChartsSurface } from '../ChartsSurface';
|
|
8
|
-
import { CartesianContextProvider } from '../context/CartesianContextProvider';
|
|
9
|
-
import { HighlightProvider } from '../context/HighlightProvider';
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
export var ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(props, ref) {
|
|
12
|
-
var width = props.width,
|
|
13
|
-
height = props.height,
|
|
14
|
-
series = props.series,
|
|
15
|
-
margin = props.margin,
|
|
16
|
-
xAxis = props.xAxis,
|
|
17
|
-
yAxis = props.yAxis,
|
|
18
|
-
colors = props.colors,
|
|
19
|
-
dataset = props.dataset,
|
|
20
|
-
sx = props.sx,
|
|
21
|
-
title = props.title,
|
|
22
|
-
desc = props.desc,
|
|
23
|
-
disableAxisListener = props.disableAxisListener,
|
|
24
|
-
children = props.children;
|
|
25
|
-
var svgRef = React.useRef(null);
|
|
26
|
-
var handleRef = useForkRef(ref, svgRef);
|
|
27
|
-
useReducedMotion(); // a11y reduce motion (see: https://react-spring.dev/docs/utilities/use-reduced-motion)
|
|
28
|
-
|
|
29
|
-
return /*#__PURE__*/_jsx(DrawingProvider, {
|
|
30
|
-
width: width,
|
|
31
|
-
height: height,
|
|
32
|
-
margin: margin,
|
|
33
|
-
svgRef: svgRef,
|
|
34
|
-
children: /*#__PURE__*/_jsx(SeriesContextProvider, {
|
|
35
|
-
series: series,
|
|
36
|
-
colors: colors,
|
|
37
|
-
dataset: dataset,
|
|
38
|
-
children: /*#__PURE__*/_jsx(CartesianContextProvider, {
|
|
39
|
-
xAxis: xAxis,
|
|
40
|
-
yAxis: yAxis,
|
|
41
|
-
dataset: dataset,
|
|
42
|
-
children: /*#__PURE__*/_jsx(InteractionProvider, {
|
|
43
|
-
children: /*#__PURE__*/_jsx(HighlightProvider, {
|
|
44
|
-
children: /*#__PURE__*/_jsx(ChartsSurface, {
|
|
45
|
-
width: width,
|
|
46
|
-
height: height,
|
|
47
|
-
ref: handleRef,
|
|
48
|
-
sx: sx,
|
|
49
|
-
title: title,
|
|
50
|
-
desc: desc,
|
|
51
|
-
disableAxisListener: disableAxisListener,
|
|
52
|
-
children: children
|
|
53
|
-
})
|
|
54
|
-
})
|
|
55
|
-
})
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
});
|
|
59
|
-
});
|
|
1
|
+
export * from './ChartContainer';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { SVGContext } from '../context/DrawingProvider';
|
|
4
|
+
import { InteractionContext } from '../context/InteractionProvider';
|
|
5
|
+
import { CartesianContext } from '../context/CartesianContextProvider';
|
|
6
|
+
import { SeriesContext } from '../context/SeriesContextProvider';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
function ChartsOnAxisClickHandler(props) {
|
|
9
|
+
var onAxisClick = props.onAxisClick;
|
|
10
|
+
var svgRef = React.useContext(SVGContext);
|
|
11
|
+
var series = React.useContext(SeriesContext);
|
|
12
|
+
var _React$useContext = React.useContext(InteractionContext),
|
|
13
|
+
axis = _React$useContext.axis;
|
|
14
|
+
var _React$useContext2 = React.useContext(CartesianContext),
|
|
15
|
+
xAxisIds = _React$useContext2.xAxisIds,
|
|
16
|
+
xAxis = _React$useContext2.xAxis,
|
|
17
|
+
yAxisIds = _React$useContext2.yAxisIds,
|
|
18
|
+
yAxis = _React$useContext2.yAxis;
|
|
19
|
+
React.useEffect(function () {
|
|
20
|
+
var element = svgRef.current;
|
|
21
|
+
if (element === null || !onAxisClick) {
|
|
22
|
+
return function () {};
|
|
23
|
+
}
|
|
24
|
+
var handleMouseClick = function handleMouseClick(event) {
|
|
25
|
+
var _USED_AXIS_ID$data;
|
|
26
|
+
event.preventDefault();
|
|
27
|
+
var isXaxis = (axis.x && axis.x.index) !== undefined;
|
|
28
|
+
var USED_AXIS_ID = isXaxis ? xAxisIds[0] : yAxisIds[0];
|
|
29
|
+
var dataIndex = isXaxis ? axis.x && axis.x.index : axis.y && axis.y.index;
|
|
30
|
+
if (dataIndex == null) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
var seriesValues = {};
|
|
34
|
+
Object.keys(series).filter(function (seriesType) {
|
|
35
|
+
return ['bar', 'line'].includes(seriesType);
|
|
36
|
+
}).forEach(function (seriesType) {
|
|
37
|
+
var _series$seriesType;
|
|
38
|
+
(_series$seriesType = series[seriesType]) == null || _series$seriesType.seriesOrder.forEach(function (seriesId) {
|
|
39
|
+
var seriesItem = series[seriesType].series[seriesId];
|
|
40
|
+
var axisKey = isXaxis ? seriesItem.xAxisKey : seriesItem.yAxisKey;
|
|
41
|
+
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
42
|
+
seriesValues[seriesId] = seriesItem.data[dataIndex];
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
var axisValue = (_USED_AXIS_ID$data = (isXaxis ? xAxis : yAxis)[USED_AXIS_ID].data) == null ? void 0 : _USED_AXIS_ID$data[dataIndex];
|
|
47
|
+
onAxisClick(event, {
|
|
48
|
+
dataIndex: dataIndex,
|
|
49
|
+
axisValue: axisValue,
|
|
50
|
+
seriesValues: seriesValues
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
element.addEventListener('click', handleMouseClick);
|
|
54
|
+
return function () {
|
|
55
|
+
element.removeEventListener('click', handleMouseClick);
|
|
56
|
+
};
|
|
57
|
+
}, [axis.x, axis.y, onAxisClick, series, svgRef, xAxis, xAxisIds, yAxis, yAxisIds]);
|
|
58
|
+
|
|
59
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
60
|
+
return /*#__PURE__*/_jsx(React.Fragment, {});
|
|
61
|
+
}
|
|
62
|
+
process.env.NODE_ENV !== "production" ? ChartsOnAxisClickHandler.propTypes = {
|
|
63
|
+
// ----------------------------- Warning --------------------------------
|
|
64
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
65
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
66
|
+
// ----------------------------------------------------------------------
|
|
67
|
+
/**
|
|
68
|
+
* The function called for onClick events.
|
|
69
|
+
* The second argument contains information about all line/bar elements at the current mouse position.
|
|
70
|
+
* @param {MouseEvent} event The mouse event recorded on the `<svg/>` element.
|
|
71
|
+
* @param {null | AxisData} data The data about the clicked axis and items associated with it.
|
|
72
|
+
*/
|
|
73
|
+
onAxisClick: PropTypes.func
|
|
74
|
+
} : void 0;
|
|
75
|
+
export { ChartsOnAxisClickHandler };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ChartsOnAxisClickHandler';
|
|
@@ -70,7 +70,7 @@ function ChartsXReferenceLine(props) {
|
|
|
70
70
|
if (process.env.NODE_ENV !== 'production') {
|
|
71
71
|
if (!warnedOnce) {
|
|
72
72
|
warnedOnce = true;
|
|
73
|
-
console.error("MUI X: the value ".concat(x, " does not exist in the data of x axis with id ").concat(axisId, "."));
|
|
73
|
+
console.error("MUI X Charts: the value ".concat(x, " does not exist in the data of x axis with id ").concat(axisId, "."));
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
return null;
|
|
@@ -70,7 +70,7 @@ function ChartsYReferenceLine(props) {
|
|
|
70
70
|
if (process.env.NODE_ENV !== 'production') {
|
|
71
71
|
if (!warnedOnce) {
|
|
72
72
|
warnedOnce = true;
|
|
73
|
-
console.error("MUI X: the value ".concat(y, " does not exist in the data of y axis with id ").concat(axisId, "."));
|
|
73
|
+
console.error("MUI X Charts: the value ".concat(y, " does not exist in the data of y axis with id ").concat(axisId, "."));
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
return null;
|