@mui/x-charts 7.0.0-alpha.2 → 7.0.0-alpha.4
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/BarElement.d.ts +5 -1
- package/BarChart/BarElement.js +24 -1
- package/BarChart/index.d.ts +2 -1
- package/BarChart/index.js +15 -4
- package/CHANGELOG.md +364 -0
- package/ChartsLegend/index.d.ts +1 -0
- package/ChartsLegend/index.js +11 -0
- package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +5 -2
- package/ChartsTooltip/ChartsAxisTooltipContent.js +93 -73
- package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +38 -57
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +7 -0
- package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +174 -0
- package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +8 -0
- package/ChartsTooltip/DefaultChartsItemTooltipContent.js +99 -0
- package/ChartsTooltip/index.d.ts +4 -0
- package/ChartsTooltip/index.js +44 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.d.ts +14 -0
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +174 -0
- package/ChartsVoronoiHandler/index.d.ts +1 -0
- package/ChartsVoronoiHandler/index.js +16 -0
- package/ChartsVoronoiHandler/package.json +6 -0
- package/ChartsYAxis/ChartsYAxis.js +6 -4
- package/LineChart/extremums.js +25 -8
- package/LineChart/index.d.ts +1 -1
- package/LineChart/index.js +11 -11
- package/PieChart/PieArc.d.ts +5 -2
- package/PieChart/PieArc.js +17 -2
- package/PieChart/PieArcLabel.d.ts +1 -1
- package/PieChart/PieArcLabel.js +5 -10
- package/PieChart/PieArcLabelPlot.d.ts +5 -1
- package/PieChart/PieArcLabelPlot.js +91 -3
- package/PieChart/PieArcPlot.d.ts +5 -1
- package/PieChart/PieArcPlot.js +90 -3
- package/PieChart/index.d.ts +3 -1
- package/PieChart/index.js +26 -4
- package/README.md +0 -1
- package/ScatterChart/Scatter.js +15 -6
- package/ScatterChart/ScatterChart.d.ts +7 -1
- package/ScatterChart/ScatterChart.js +18 -1
- package/ScatterChart/index.d.ts +1 -1
- package/ScatterChart/index.js +8 -8
- package/SparkLineChart/SparkLineChart.js +1 -0
- package/context/InteractionProvider.d.ts +10 -0
- package/context/InteractionProvider.js +21 -1
- package/esm/BarChart/BarElement.js +26 -2
- package/esm/BarChart/index.js +2 -1
- package/esm/ChartsLegend/index.js +2 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +95 -75
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
- package/esm/ChartsTooltip/DefaultChartsAxisTooltipContent.js +168 -0
- package/esm/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
- package/esm/ChartsTooltip/index.js +5 -1
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +168 -0
- package/esm/ChartsVoronoiHandler/index.js +1 -0
- package/esm/ChartsYAxis/ChartsYAxis.js +6 -4
- package/esm/LineChart/extremums.js +25 -8
- package/esm/LineChart/index.js +1 -1
- package/esm/PieChart/PieArc.js +18 -2
- package/esm/PieChart/PieArcLabel.js +7 -11
- package/esm/PieChart/PieArcLabelPlot.js +92 -3
- package/esm/PieChart/PieArcPlot.js +91 -3
- package/esm/PieChart/index.js +3 -1
- package/esm/ScatterChart/Scatter.js +15 -6
- package/esm/ScatterChart/ScatterChart.js +18 -1
- package/esm/ScatterChart/index.js +1 -1
- package/esm/SparkLineChart/SparkLineChart.js +1 -0
- package/esm/context/InteractionProvider.js +21 -1
- package/esm/hooks/useAxisEvents.js +20 -27
- package/esm/hooks/useInteractionItemProps.js +4 -1
- package/esm/index.js +1 -0
- package/esm/internals/defaultizeValueFormatter.js +4 -3
- package/esm/internals/utils.js +11 -0
- package/hooks/useAxisEvents.js +20 -27
- package/hooks/useInteractionItemProps.d.ts +2 -2
- package/hooks/useInteractionItemProps.js +4 -1
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/defaultizeColor.d.ts +1 -0
- package/internals/defaultizeValueFormatter.d.ts +3 -1
- package/internals/defaultizeValueFormatter.js +3 -3
- package/internals/utils.d.ts +6 -0
- package/internals/utils.js +12 -0
- package/legacy/BarChart/BarElement.js +26 -2
- package/legacy/BarChart/index.js +2 -1
- package/legacy/ChartsLegend/index.js +2 -1
- package/legacy/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
- package/legacy/ChartsTooltip/ChartsItemTooltipContent.js +40 -55
- package/legacy/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
- package/legacy/ChartsTooltip/DefaultChartsItemTooltipContent.js +89 -0
- package/legacy/ChartsTooltip/index.js +5 -1
- package/legacy/ChartsVoronoiHandler/ChartsVoronoiHandler.js +162 -0
- package/legacy/ChartsVoronoiHandler/index.js +1 -0
- package/legacy/ChartsYAxis/ChartsYAxis.js +6 -4
- package/legacy/LineChart/extremums.js +29 -14
- package/legacy/LineChart/index.js +1 -1
- package/legacy/PieChart/PieArc.js +18 -2
- package/legacy/PieChart/PieArcLabel.js +7 -11
- package/legacy/PieChart/PieArcLabelPlot.js +92 -3
- package/legacy/PieChart/PieArcPlot.js +91 -3
- package/legacy/PieChart/index.js +3 -1
- package/legacy/ScatterChart/Scatter.js +18 -7
- package/legacy/ScatterChart/ScatterChart.js +18 -1
- package/legacy/ScatterChart/index.js +1 -1
- package/legacy/SparkLineChart/SparkLineChart.js +1 -0
- package/legacy/context/InteractionProvider.js +21 -1
- package/legacy/hooks/useAxisEvents.js +20 -27
- package/legacy/hooks/useInteractionItemProps.js +6 -1
- package/legacy/index.js +2 -1
- package/legacy/internals/defaultizeValueFormatter.js +4 -3
- package/legacy/internals/utils.js +11 -0
- package/models/seriesType/config.d.ts +5 -1
- package/models/seriesType/scatter.d.ts +6 -1
- package/modern/BarChart/BarElement.js +26 -2
- package/modern/BarChart/index.js +2 -1
- package/modern/ChartsLegend/index.js +2 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +95 -74
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +40 -58
- package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +167 -0
- package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +92 -0
- package/modern/ChartsTooltip/index.js +5 -1
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +166 -0
- package/modern/ChartsVoronoiHandler/index.js +1 -0
- package/modern/ChartsYAxis/ChartsYAxis.js +6 -4
- package/modern/LineChart/extremums.js +25 -8
- package/modern/LineChart/index.js +1 -1
- package/modern/PieChart/PieArc.js +18 -2
- package/modern/PieChart/PieArcLabel.js +7 -11
- package/modern/PieChart/PieArcLabelPlot.js +92 -3
- package/modern/PieChart/PieArcPlot.js +91 -3
- package/modern/PieChart/index.js +3 -1
- package/modern/ScatterChart/Scatter.js +15 -6
- package/modern/ScatterChart/ScatterChart.js +18 -1
- package/modern/ScatterChart/index.js +1 -1
- package/modern/SparkLineChart/SparkLineChart.js +1 -0
- package/modern/context/InteractionProvider.js +21 -1
- package/modern/hooks/useAxisEvents.js +20 -27
- package/modern/hooks/useInteractionItemProps.js +4 -1
- package/modern/index.js +2 -1
- package/modern/internals/defaultizeValueFormatter.js +3 -3
- package/modern/internals/utils.js +11 -0
- package/package.json +6 -4
package/ChartsTooltip/index.js
CHANGED
|
@@ -24,4 +24,48 @@ Object.keys(_chartsTooltipClasses).forEach(function (key) {
|
|
|
24
24
|
return _chartsTooltipClasses[key];
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
+
});
|
|
28
|
+
var _ChartsAxisTooltipContent = require("./ChartsAxisTooltipContent");
|
|
29
|
+
Object.keys(_ChartsAxisTooltipContent).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _ChartsAxisTooltipContent[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _ChartsAxisTooltipContent[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _ChartsItemTooltipContent = require("./ChartsItemTooltipContent");
|
|
40
|
+
Object.keys(_ChartsItemTooltipContent).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _ChartsItemTooltipContent[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _ChartsItemTooltipContent[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _DefaultChartsAxisTooltipContent = require("./DefaultChartsAxisTooltipContent");
|
|
51
|
+
Object.keys(_DefaultChartsAxisTooltipContent).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _DefaultChartsAxisTooltipContent[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _DefaultChartsAxisTooltipContent[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _DefaultChartsItemTooltipContent = require("./DefaultChartsItemTooltipContent");
|
|
62
|
+
Object.keys(_DefaultChartsItemTooltipContent).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _DefaultChartsItemTooltipContent[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _DefaultChartsItemTooltipContent[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
27
71
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export type ChartsVoronoiHandlerProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
|
|
5
|
+
* If `undefined`, the radius is assumed to be infinite.
|
|
6
|
+
* @default undefined
|
|
7
|
+
*/
|
|
8
|
+
voronoiMaxRadius?: number | undefined;
|
|
9
|
+
};
|
|
10
|
+
declare function ChartsVoronoiHandler(props: ChartsVoronoiHandlerProps): React.JSX.Element;
|
|
11
|
+
declare namespace ChartsVoronoiHandler {
|
|
12
|
+
var propTypes: any;
|
|
13
|
+
}
|
|
14
|
+
export { ChartsVoronoiHandler };
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.ChartsVoronoiHandler = ChartsVoronoiHandler;
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
+
var _d3Delaunay = require("d3-delaunay");
|
|
11
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
12
|
+
var _InteractionProvider = require("../context/InteractionProvider");
|
|
13
|
+
var _CartesianContextProvider = require("../context/CartesianContextProvider");
|
|
14
|
+
var _DrawingProvider = require("../context/DrawingProvider");
|
|
15
|
+
var _SeriesContextProvider = require("../context/SeriesContextProvider");
|
|
16
|
+
var _useScale = require("../hooks/useScale");
|
|
17
|
+
var _utils = require("../internals/utils");
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
function ChartsVoronoiHandler(props) {
|
|
22
|
+
const {
|
|
23
|
+
voronoiMaxRadius
|
|
24
|
+
} = props;
|
|
25
|
+
const svgRef = React.useContext(_DrawingProvider.SVGContext);
|
|
26
|
+
const {
|
|
27
|
+
width,
|
|
28
|
+
height,
|
|
29
|
+
top,
|
|
30
|
+
left
|
|
31
|
+
} = React.useContext(_DrawingProvider.DrawingContext);
|
|
32
|
+
const {
|
|
33
|
+
xAxis,
|
|
34
|
+
yAxis,
|
|
35
|
+
xAxisIds,
|
|
36
|
+
yAxisIds
|
|
37
|
+
} = React.useContext(_CartesianContextProvider.CartesianContext);
|
|
38
|
+
const {
|
|
39
|
+
dispatch
|
|
40
|
+
} = React.useContext(_InteractionProvider.InteractionContext);
|
|
41
|
+
const {
|
|
42
|
+
series,
|
|
43
|
+
seriesOrder
|
|
44
|
+
} = React.useContext(_SeriesContextProvider.SeriesContext).scatter ?? {};
|
|
45
|
+
const voronoiRef = React.useRef({});
|
|
46
|
+
const defaultXAxisId = xAxisIds[0];
|
|
47
|
+
const defaultYAxisId = yAxisIds[0];
|
|
48
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
49
|
+
dispatch({
|
|
50
|
+
type: 'updateVoronoiUsage',
|
|
51
|
+
useVoronoiInteraction: true
|
|
52
|
+
});
|
|
53
|
+
return () => {
|
|
54
|
+
dispatch({
|
|
55
|
+
type: 'updateVoronoiUsage',
|
|
56
|
+
useVoronoiInteraction: false
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
}, [dispatch]);
|
|
60
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
61
|
+
if (seriesOrder === undefined || series === undefined) {
|
|
62
|
+
// If there is no scatter chart series
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
voronoiRef.current = {};
|
|
66
|
+
let points = [];
|
|
67
|
+
seriesOrder.forEach(seriesId => {
|
|
68
|
+
const {
|
|
69
|
+
data,
|
|
70
|
+
xAxisKey,
|
|
71
|
+
yAxisKey
|
|
72
|
+
} = series[seriesId];
|
|
73
|
+
const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
|
|
74
|
+
const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
|
|
75
|
+
const getXPosition = (0, _useScale.getValueToPositionMapper)(xScale);
|
|
76
|
+
const getYPosition = (0, _useScale.getValueToPositionMapper)(yScale);
|
|
77
|
+
const seriesPoints = data.flatMap(({
|
|
78
|
+
x,
|
|
79
|
+
y
|
|
80
|
+
}) => [getXPosition(x), getYPosition(y)]);
|
|
81
|
+
voronoiRef.current[seriesId] = {
|
|
82
|
+
startIndex: points.length,
|
|
83
|
+
endIndex: points.length + seriesPoints.length
|
|
84
|
+
};
|
|
85
|
+
points = points.concat(seriesPoints);
|
|
86
|
+
});
|
|
87
|
+
voronoiRef.current.delauney = new _d3Delaunay.Delaunay(points);
|
|
88
|
+
}, [defaultXAxisId, defaultYAxisId, series, seriesOrder, xAxis, yAxis]);
|
|
89
|
+
React.useEffect(() => {
|
|
90
|
+
const element = svgRef.current;
|
|
91
|
+
if (element === null) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
const handleMouseOut = () => {
|
|
95
|
+
dispatch({
|
|
96
|
+
type: 'exitChart'
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// TODO: A perf optimisation of voronoi could be to use the last point as the intial point for the next search.
|
|
101
|
+
const handleMouseMove = event => {
|
|
102
|
+
// Get mouse coordinate in global SVG space
|
|
103
|
+
const svgPoint = (0, _utils.getSVGPoint)(svgRef.current, event);
|
|
104
|
+
const outsideX = svgPoint.x < left || svgPoint.x > left + width;
|
|
105
|
+
const outsideY = svgPoint.y < top || svgPoint.y > top + height;
|
|
106
|
+
if (outsideX || outsideY) {
|
|
107
|
+
dispatch({
|
|
108
|
+
type: 'exitChart'
|
|
109
|
+
});
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (!voronoiRef.current.delauney) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const closestPointIndex = voronoiRef.current.delauney?.find(svgPoint.x, svgPoint.y);
|
|
116
|
+
if (closestPointIndex !== undefined) {
|
|
117
|
+
const seriesId = Object.keys(voronoiRef.current).find(id => {
|
|
118
|
+
if (id === 'delauney') {
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return 2 * closestPointIndex >= voronoiRef.current[id].startIndex && 2 * closestPointIndex < voronoiRef.current[id].endIndex;
|
|
122
|
+
});
|
|
123
|
+
if (seriesId === undefined) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const dataIndex = (2 * closestPointIndex - voronoiRef.current[seriesId].startIndex) / 2;
|
|
127
|
+
if (voronoiMaxRadius !== undefined) {
|
|
128
|
+
const pointX = voronoiRef.current.delauney.points[2 * closestPointIndex];
|
|
129
|
+
const pointY = voronoiRef.current.delauney.points[2 * closestPointIndex + 1];
|
|
130
|
+
const dist2 = (pointX - svgPoint.x) ** 2 + (pointY - svgPoint.y) ** 2;
|
|
131
|
+
if (dist2 > voronoiMaxRadius ** 2) {
|
|
132
|
+
// The closest point is too far to be considered.
|
|
133
|
+
dispatch({
|
|
134
|
+
type: 'leaveItem',
|
|
135
|
+
data: {
|
|
136
|
+
type: 'scatter',
|
|
137
|
+
seriesId,
|
|
138
|
+
dataIndex
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
dispatch({
|
|
145
|
+
type: 'enterItem',
|
|
146
|
+
data: {
|
|
147
|
+
type: 'scatter',
|
|
148
|
+
seriesId,
|
|
149
|
+
dataIndex
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
element.addEventListener('mouseout', handleMouseOut);
|
|
155
|
+
element.addEventListener('mousemove', handleMouseMove);
|
|
156
|
+
return () => {
|
|
157
|
+
element.removeEventListener('mouseout', handleMouseOut);
|
|
158
|
+
element.removeEventListener('mousemove', handleMouseMove);
|
|
159
|
+
};
|
|
160
|
+
}, [svgRef, dispatch, left, width, top, height, yAxis, xAxis, voronoiMaxRadius]);
|
|
161
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {}); // Workaround to fix docs scripts
|
|
162
|
+
}
|
|
163
|
+
process.env.NODE_ENV !== "production" ? ChartsVoronoiHandler.propTypes = {
|
|
164
|
+
// ----------------------------- Warning --------------------------------
|
|
165
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
166
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
167
|
+
// ----------------------------------------------------------------------
|
|
168
|
+
/**
|
|
169
|
+
* Defines the maximal distance between a scatter point and the pointer that triggers the interaction.
|
|
170
|
+
* If `undefined`, the radius is assumed to be infinite.
|
|
171
|
+
* @default undefined
|
|
172
|
+
*/
|
|
173
|
+
voronoiMaxRadius: _propTypes.default.number
|
|
174
|
+
} : void 0;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ChartsVoronoiHandler';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _ChartsVoronoiHandler = require("./ChartsVoronoiHandler");
|
|
7
|
+
Object.keys(_ChartsVoronoiHandler).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _ChartsVoronoiHandler[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _ChartsVoronoiHandler[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -82,6 +82,8 @@ function ChartsYAxis(inProps) {
|
|
|
82
82
|
tickFontSize,
|
|
83
83
|
label,
|
|
84
84
|
labelFontSize,
|
|
85
|
+
labelStyle,
|
|
86
|
+
tickLabelStyle,
|
|
85
87
|
tickSize: tickSizeProp,
|
|
86
88
|
valueFormatter,
|
|
87
89
|
slots,
|
|
@@ -116,11 +118,11 @@ function ChartsYAxis(inProps) {
|
|
|
116
118
|
elementType: TickLabel,
|
|
117
119
|
externalSlotProps: slotProps?.axisTickLabel,
|
|
118
120
|
additionalProps: {
|
|
119
|
-
style: {
|
|
121
|
+
style: (0, _extends2.default)({
|
|
120
122
|
fontSize: tickFontSize,
|
|
121
123
|
textAnchor: position === 'right' ? 'start' : 'end',
|
|
122
124
|
dominantBaseline: 'central'
|
|
123
|
-
},
|
|
125
|
+
}, tickLabelStyle),
|
|
124
126
|
className: classes.tickLabel
|
|
125
127
|
},
|
|
126
128
|
ownerState: {}
|
|
@@ -129,12 +131,12 @@ function ChartsYAxis(inProps) {
|
|
|
129
131
|
elementType: Label,
|
|
130
132
|
externalSlotProps: slotProps?.axisLabel,
|
|
131
133
|
additionalProps: {
|
|
132
|
-
style: {
|
|
134
|
+
style: (0, _extends2.default)({
|
|
133
135
|
fontSize: labelFontSize,
|
|
134
136
|
angle: positionSign * 90,
|
|
135
137
|
textAnchor: 'middle',
|
|
136
138
|
dominantBaseline: 'auto'
|
|
137
|
-
}
|
|
139
|
+
}, labelStyle)
|
|
138
140
|
},
|
|
139
141
|
ownerState: {}
|
|
140
142
|
});
|
package/LineChart/extremums.js
CHANGED
|
@@ -13,6 +13,18 @@ const getExtremumX = params => {
|
|
|
13
13
|
return [minX, maxX];
|
|
14
14
|
};
|
|
15
15
|
exports.getExtremumX = getExtremumX;
|
|
16
|
+
function getSeriesExtremums(getValues, stackedData) {
|
|
17
|
+
if (stackedData.length === 0) {
|
|
18
|
+
return [null, null];
|
|
19
|
+
}
|
|
20
|
+
return stackedData.reduce((seriesAcc, stackedValue) => {
|
|
21
|
+
const [base, value] = getValues(stackedValue);
|
|
22
|
+
if (seriesAcc[0] === null) {
|
|
23
|
+
return [Math.min(base, value), Math.max(base, value)];
|
|
24
|
+
}
|
|
25
|
+
return [Math.min(base, value, seriesAcc[0]), Math.max(base, value, seriesAcc[1])];
|
|
26
|
+
}, getValues(stackedData[0]));
|
|
27
|
+
}
|
|
16
28
|
const getExtremumY = params => {
|
|
17
29
|
const {
|
|
18
30
|
series,
|
|
@@ -20,16 +32,21 @@ const getExtremumY = params => {
|
|
|
20
32
|
isDefaultAxis
|
|
21
33
|
} = params;
|
|
22
34
|
return Object.keys(series).filter(seriesId => series[seriesId].yAxisKey === axis.id || isDefaultAxis && series[seriesId].yAxisKey === undefined).reduce((acc, seriesId) => {
|
|
23
|
-
const
|
|
24
|
-
|
|
35
|
+
const {
|
|
36
|
+
area,
|
|
37
|
+
stackedData
|
|
38
|
+
} = series[seriesId];
|
|
39
|
+
const isArea = area !== undefined;
|
|
40
|
+
const getValues = isArea ? d => d : d => [d[1], d[1]]; // Since this series is not used to display an area, we do not consider the base (the d[0]).
|
|
25
41
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return
|
|
29
|
-
}
|
|
30
|
-
if (
|
|
31
|
-
return
|
|
42
|
+
const seriesExtremums = getSeriesExtremums(getValues, stackedData);
|
|
43
|
+
if (acc[0] === null) {
|
|
44
|
+
return seriesExtremums;
|
|
45
|
+
}
|
|
46
|
+
if (seriesExtremums[0] === null) {
|
|
47
|
+
return acc;
|
|
32
48
|
}
|
|
49
|
+
const [seriesMin, seriesMax] = seriesExtremums;
|
|
33
50
|
return [Math.min(seriesMin, acc[0]), Math.max(seriesMax, acc[1])];
|
|
34
51
|
}, [null, null]);
|
|
35
52
|
};
|
package/LineChart/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
export * from './LineChart';
|
|
1
2
|
export * from './LinePlot';
|
|
2
3
|
export * from './AreaPlot';
|
|
3
4
|
export * from './MarkPlot';
|
|
4
5
|
export * from './LineHighlightPlot';
|
|
5
|
-
export * from './LineChart';
|
|
6
6
|
export * from './AreaElement';
|
|
7
7
|
export * from './LineElement';
|
|
8
8
|
export * from './MarkElement';
|
package/LineChart/index.js
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _LineChart = require("./LineChart");
|
|
7
|
+
Object.keys(_LineChart).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _LineChart[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _LineChart[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
6
17
|
var _LinePlot = require("./LinePlot");
|
|
7
18
|
Object.keys(_LinePlot).forEach(function (key) {
|
|
8
19
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -47,17 +58,6 @@ Object.keys(_LineHighlightPlot).forEach(function (key) {
|
|
|
47
58
|
}
|
|
48
59
|
});
|
|
49
60
|
});
|
|
50
|
-
var _LineChart = require("./LineChart");
|
|
51
|
-
Object.keys(_LineChart).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _LineChart[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _LineChart[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
61
|
var _AreaElement = require("./AreaElement");
|
|
62
62
|
Object.keys(_AreaElement).forEach(function (key) {
|
|
63
63
|
if (key === "default" || key === "__esModule") return;
|
package/PieChart/PieArc.d.ts
CHANGED
|
@@ -30,5 +30,8 @@ export type PieArcProps = PieArcOwnerState & React.ComponentPropsWithoutRef<'pat
|
|
|
30
30
|
highlightScope?: Partial<HighlightScope>;
|
|
31
31
|
onClick?: (event: React.MouseEvent<SVGPathElement, MouseEvent>) => void;
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
declare function PieArc(props: PieArcProps): React.JSX.Element;
|
|
34
|
+
declare namespace PieArc {
|
|
35
|
+
var propTypes: any;
|
|
36
|
+
}
|
|
37
|
+
export { PieArc };
|
package/PieChart/PieArc.js
CHANGED
|
@@ -4,12 +4,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.PieArc = PieArc;
|
|
8
8
|
exports.getPieArcUtilityClass = getPieArcUtilityClass;
|
|
9
9
|
exports.pieArcClasses = void 0;
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
14
|
var _d3Shape = require("d3-shape");
|
|
14
15
|
var _web = require("@react-spring/web");
|
|
15
16
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
@@ -93,4 +94,18 @@ function PieArc(props) {
|
|
|
93
94
|
seriesId: id,
|
|
94
95
|
dataIndex
|
|
95
96
|
})));
|
|
96
|
-
}
|
|
97
|
+
}
|
|
98
|
+
process.env.NODE_ENV !== "production" ? PieArc.propTypes = {
|
|
99
|
+
// ----------------------------- Warning --------------------------------
|
|
100
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
101
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
102
|
+
// ----------------------------------------------------------------------
|
|
103
|
+
classes: _propTypes.default.object,
|
|
104
|
+
dataIndex: _propTypes.default.number.isRequired,
|
|
105
|
+
highlightScope: _propTypes.default.shape({
|
|
106
|
+
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
107
|
+
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
108
|
+
}),
|
|
109
|
+
isFaded: _propTypes.default.bool.isRequired,
|
|
110
|
+
isHighlighted: _propTypes.default.bool.isRequired
|
|
111
|
+
} : void 0;
|
package/PieChart/PieArcLabel.js
CHANGED
|
@@ -4,15 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.PieArcLabel = PieArcLabel;
|
|
8
8
|
exports.getPieArcLabelUtilityClass = getPieArcLabelUtilityClass;
|
|
9
9
|
exports.pieArcLabelClasses = void 0;
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
14
|
var _web = require("@react-spring/web");
|
|
14
15
|
var _d3Shape = require("d3-shape");
|
|
15
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
16
|
var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
|
|
17
17
|
var _generateUtilityClass = _interopRequireDefault(require("@mui/utils/generateUtilityClass"));
|
|
18
18
|
var _styles = require("@mui/material/styles");
|
|
@@ -109,12 +109,7 @@ process.env.NODE_ENV !== "production" ? PieArcLabel.propTypes = {
|
|
|
109
109
|
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
110
110
|
// ----------------------------------------------------------------------
|
|
111
111
|
classes: _propTypes.default.object,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
116
|
-
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
117
|
-
}),
|
|
118
|
-
innerRadius: _propTypes.default.number,
|
|
119
|
-
outerRadius: _propTypes.default.number.isRequired
|
|
112
|
+
formattedArcLabel: _propTypes.default.string,
|
|
113
|
+
isFaded: _propTypes.default.bool.isRequired,
|
|
114
|
+
isHighlighted: _propTypes.default.bool.isRequired
|
|
120
115
|
} : void 0;
|
|
@@ -25,4 +25,8 @@ export interface PieArcLabelPlotProps extends DefaultizedProps<Pick<DefaultizedP
|
|
|
25
25
|
*/
|
|
26
26
|
skipAnimation?: boolean;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
declare function PieArcLabelPlot(props: PieArcLabelPlotProps): React.JSX.Element | null;
|
|
29
|
+
declare namespace PieArcLabelPlot {
|
|
30
|
+
var propTypes: any;
|
|
31
|
+
}
|
|
32
|
+
export { PieArcLabelPlot };
|
|
@@ -8,10 +8,11 @@ exports.PieArcLabelPlot = PieArcLabelPlot;
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
12
|
var _web = require("@react-spring/web");
|
|
12
13
|
var _transition = require("./dataTransform/transition");
|
|
13
14
|
var _useTransformData = require("./dataTransform/useTransformData");
|
|
14
|
-
var _PieArcLabel =
|
|
15
|
+
var _PieArcLabel = require("./PieArcLabel");
|
|
15
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
17
|
const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlightScope", "highlighted", "faded", "data", "arcLabel", "arcLabelMinAngle", "skipAnimation"],
|
|
17
18
|
_excluded2 = ["startAngle", "endAngle", "paddingAngle", "innerRadius", "outerRadius", "cornerRadius"];
|
|
@@ -68,7 +69,7 @@ function PieArcLabelPlot(props) {
|
|
|
68
69
|
if (data.length === 0) {
|
|
69
70
|
return null;
|
|
70
71
|
}
|
|
71
|
-
const ArcLabel = slots?.pieArcLabel ?? _PieArcLabel.
|
|
72
|
+
const ArcLabel = slots?.pieArcLabel ?? _PieArcLabel.PieArcLabel;
|
|
72
73
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("g", (0, _extends2.default)({}, other, {
|
|
73
74
|
children: transition((_ref, item) => {
|
|
74
75
|
let {
|
|
@@ -96,4 +97,91 @@ function PieArcLabelPlot(props) {
|
|
|
96
97
|
}, slotProps?.pieArcLabel));
|
|
97
98
|
})
|
|
98
99
|
}));
|
|
99
|
-
}
|
|
100
|
+
}
|
|
101
|
+
process.env.NODE_ENV !== "production" ? PieArcLabelPlot.propTypes = {
|
|
102
|
+
// ----------------------------- Warning --------------------------------
|
|
103
|
+
// | These PropTypes are generated from the TypeScript type definitions |
|
|
104
|
+
// | To update them edit the TypeScript types and run "yarn proptypes" |
|
|
105
|
+
// ----------------------------------------------------------------------
|
|
106
|
+
/**
|
|
107
|
+
* The label displayed into the arc.
|
|
108
|
+
*/
|
|
109
|
+
arcLabel: _propTypes.default.oneOfType([_propTypes.default.oneOf(['formattedValue', 'label', 'value']), _propTypes.default.func]),
|
|
110
|
+
/**
|
|
111
|
+
* The minimal angle required to display the arc label.
|
|
112
|
+
*/
|
|
113
|
+
arcLabelMinAngle: _propTypes.default.number,
|
|
114
|
+
/**
|
|
115
|
+
* The radius applied to arc corners (similar to border radius).
|
|
116
|
+
* @default 0
|
|
117
|
+
*/
|
|
118
|
+
cornerRadius: _propTypes.default.number,
|
|
119
|
+
data: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
120
|
+
color: _propTypes.default.string.isRequired,
|
|
121
|
+
endAngle: _propTypes.default.number.isRequired,
|
|
122
|
+
formattedValue: _propTypes.default.string.isRequired,
|
|
123
|
+
id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired,
|
|
124
|
+
index: _propTypes.default.number.isRequired,
|
|
125
|
+
label: _propTypes.default.string,
|
|
126
|
+
padAngle: _propTypes.default.number.isRequired,
|
|
127
|
+
startAngle: _propTypes.default.number.isRequired,
|
|
128
|
+
value: _propTypes.default.number.isRequired
|
|
129
|
+
})).isRequired,
|
|
130
|
+
/**
|
|
131
|
+
* Override the arc attibutes when it is faded.
|
|
132
|
+
*/
|
|
133
|
+
faded: _propTypes.default.shape({
|
|
134
|
+
additionalRadius: _propTypes.default.number,
|
|
135
|
+
color: _propTypes.default.string,
|
|
136
|
+
cornerRadius: _propTypes.default.number,
|
|
137
|
+
innerRadius: _propTypes.default.number,
|
|
138
|
+
outerRadius: _propTypes.default.number,
|
|
139
|
+
paddingAngle: _propTypes.default.number
|
|
140
|
+
}),
|
|
141
|
+
/**
|
|
142
|
+
* Override the arc attibutes when it is highlighted.
|
|
143
|
+
*/
|
|
144
|
+
highlighted: _propTypes.default.shape({
|
|
145
|
+
additionalRadius: _propTypes.default.number,
|
|
146
|
+
color: _propTypes.default.string,
|
|
147
|
+
cornerRadius: _propTypes.default.number,
|
|
148
|
+
innerRadius: _propTypes.default.number,
|
|
149
|
+
outerRadius: _propTypes.default.number,
|
|
150
|
+
paddingAngle: _propTypes.default.number
|
|
151
|
+
}),
|
|
152
|
+
highlightScope: _propTypes.default.shape({
|
|
153
|
+
faded: _propTypes.default.oneOf(['global', 'none', 'series']),
|
|
154
|
+
highlighted: _propTypes.default.oneOf(['item', 'none', 'series'])
|
|
155
|
+
}),
|
|
156
|
+
id: _propTypes.default.string.isRequired,
|
|
157
|
+
/**
|
|
158
|
+
* The radius between circle center and the begining of the arc.
|
|
159
|
+
* @default 0
|
|
160
|
+
*/
|
|
161
|
+
innerRadius: _propTypes.default.number,
|
|
162
|
+
/**
|
|
163
|
+
* The radius between circle center and the end of the arc.
|
|
164
|
+
* @default R_max The maximal radius that fit into the drawing area.
|
|
165
|
+
*/
|
|
166
|
+
outerRadius: _propTypes.default.number.isRequired,
|
|
167
|
+
/**
|
|
168
|
+
* The padding angle (deg) between two arcs.
|
|
169
|
+
* @default 0
|
|
170
|
+
*/
|
|
171
|
+
paddingAngle: _propTypes.default.number,
|
|
172
|
+
/**
|
|
173
|
+
* If `true`, animations are skiped.
|
|
174
|
+
* @default false
|
|
175
|
+
*/
|
|
176
|
+
skipAnimation: _propTypes.default.bool,
|
|
177
|
+
/**
|
|
178
|
+
* The props used for each component slot.
|
|
179
|
+
* @default {}
|
|
180
|
+
*/
|
|
181
|
+
slotProps: _propTypes.default.object,
|
|
182
|
+
/**
|
|
183
|
+
* Overridable component slots.
|
|
184
|
+
* @default {}
|
|
185
|
+
*/
|
|
186
|
+
slots: _propTypes.default.object
|
|
187
|
+
} : void 0;
|
package/PieChart/PieArcPlot.d.ts
CHANGED
|
@@ -32,4 +32,8 @@ export interface PieArcPlotProps extends DefaultizedProps<Pick<DefaultizedPieSer
|
|
|
32
32
|
*/
|
|
33
33
|
skipAnimation?: boolean;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
declare function PieArcPlot(props: PieArcPlotProps): React.JSX.Element | null;
|
|
36
|
+
declare namespace PieArcPlot {
|
|
37
|
+
var propTypes: any;
|
|
38
|
+
}
|
|
39
|
+
export { PieArcPlot };
|