@mui/x-charts 6.0.0-alpha.3 → 6.0.0-alpha.5
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.js +4 -4
- package/CHANGELOG.md +136 -3
- package/ChartsAxis/ChartsAxis.d.ts +4 -4
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/LineChart/LineChart.js +4 -4
- package/LineChart/extremums.js +2 -2
- package/PieChart/PieChart.js +4 -4
- package/ResponsiveChartContainer/index.js +2 -2
- package/ScatterChart/Scatter.js +39 -53
- package/ScatterChart/ScatterChart.js +4 -4
- package/context/DrawingProvider.d.ts +1 -1
- package/context/DrawingProvider.js +1 -1
- package/esm/BarChart/BarChart.js +4 -4
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/LineChart/LineChart.js +4 -4
- package/esm/LineChart/extremums.js +2 -2
- package/esm/PieChart/PieChart.js +4 -4
- package/esm/ResponsiveChartContainer/index.js +2 -2
- package/esm/ScatterChart/Scatter.js +39 -53
- package/esm/ScatterChart/ScatterChart.js +4 -4
- package/esm/context/DrawingProvider.js +1 -1
- package/index.js +1 -1
- package/legacy/BarChart/BarChart.js +4 -4
- package/legacy/ChartsAxis/ChartsAxis.js +4 -4
- package/legacy/LineChart/LineChart.js +4 -4
- package/legacy/LineChart/extremums.js +3 -3
- package/legacy/PieChart/PieChart.js +4 -4
- package/legacy/ResponsiveChartContainer/index.js +2 -2
- package/legacy/ScatterChart/Scatter.js +35 -46
- package/legacy/ScatterChart/ScatterChart.js +4 -4
- package/legacy/context/DrawingProvider.js +1 -1
- package/legacy/index.js +1 -1
- package/modern/BarChart/BarChart.js +4 -4
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/LineChart/LineChart.js +4 -4
- package/modern/LineChart/extremums.js +2 -2
- package/modern/PieChart/PieChart.js +4 -4
- package/modern/ResponsiveChartContainer/index.js +2 -2
- package/modern/ScatterChart/Scatter.js +39 -53
- package/modern/ScatterChart/ScatterChart.js +4 -4
- package/modern/context/DrawingProvider.js +1 -1
- package/modern/index.js +1 -1
- package/package.json +22 -5
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -82,7 +82,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
82
82
|
}),
|
|
83
83
|
/**
|
|
84
84
|
* Indicate which axis to display the bottom of the charts.
|
|
85
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
85
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
86
86
|
* @default xAxisIds[0] The id of the first provided axis
|
|
87
87
|
*/
|
|
88
88
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -109,7 +109,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
109
109
|
height: PropTypes.number,
|
|
110
110
|
/**
|
|
111
111
|
* Indicate which axis to display the left of the charts.
|
|
112
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
112
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
113
113
|
* @default yAxisIds[0] The id of the first provided axis
|
|
114
114
|
*/
|
|
115
115
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -149,7 +149,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
149
149
|
}),
|
|
150
150
|
/**
|
|
151
151
|
* Indicate which axis to display the right of the charts.
|
|
152
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
152
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
153
153
|
* @default null
|
|
154
154
|
*/
|
|
155
155
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -214,7 +214,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
214
214
|
}),
|
|
215
215
|
/**
|
|
216
216
|
* Indicate which axis to display the top of the charts.
|
|
217
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
217
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
218
218
|
* @default null
|
|
219
219
|
*/
|
|
220
220
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -21,8 +21,8 @@ const useChartDimensions = (inWidth, inHeight) => {
|
|
|
21
21
|
}
|
|
22
22
|
const win = ownerWindow(mainEl);
|
|
23
23
|
const computedStyle = win.getComputedStyle(mainEl);
|
|
24
|
-
const newHeight = parseFloat(computedStyle.height) || 0;
|
|
25
|
-
const newWidth = parseFloat(computedStyle.width) || 0;
|
|
24
|
+
const newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
|
|
25
|
+
const newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
|
|
26
26
|
setWidth(newWidth);
|
|
27
27
|
setHeight(newHeight);
|
|
28
28
|
}, []);
|
|
@@ -16,62 +16,48 @@ function Scatter(props) {
|
|
|
16
16
|
const {
|
|
17
17
|
item
|
|
18
18
|
} = React.useContext(InteractionContext);
|
|
19
|
-
const getXPosition = getValueToPositionMapper(xScale);
|
|
20
|
-
const getYPosition = getValueToPositionMapper(yScale);
|
|
21
19
|
const getInteractionItemProps = useInteractionItemProps(series.highlightScope);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
x,
|
|
39
|
-
y,
|
|
40
|
-
id
|
|
41
|
-
}, index) => ({
|
|
42
|
-
x: getXPosition(x),
|
|
43
|
-
y: getYPosition(y),
|
|
44
|
-
id,
|
|
45
|
-
dataIndex: index
|
|
46
|
-
})).filter(isInRange).map(({
|
|
47
|
-
x,
|
|
48
|
-
y,
|
|
49
|
-
id,
|
|
50
|
-
dataIndex
|
|
51
|
-
}) => {
|
|
52
|
-
const isHighlighted = getIsHighlighted(item, {
|
|
53
|
-
type: 'scatter',
|
|
54
|
-
seriesId: series.id,
|
|
55
|
-
dataIndex
|
|
56
|
-
}, series.highlightScope);
|
|
57
|
-
const isFaded = !isHighlighted && getIsFaded(item, {
|
|
20
|
+
const cleanData = React.useMemo(() => {
|
|
21
|
+
const getXPosition = getValueToPositionMapper(xScale);
|
|
22
|
+
const getYPosition = getValueToPositionMapper(yScale);
|
|
23
|
+
const xRange = xScale.range();
|
|
24
|
+
const yRange = yScale.range();
|
|
25
|
+
const minXRange = Math.min(...xRange);
|
|
26
|
+
const maxXRange = Math.max(...xRange);
|
|
27
|
+
const minYRange = Math.min(...yRange);
|
|
28
|
+
const maxYRange = Math.max(...yRange);
|
|
29
|
+
const temp = [];
|
|
30
|
+
for (let i = 0; i < series.data.length; i += 1) {
|
|
31
|
+
const scatterPoint = series.data[i];
|
|
32
|
+
const x = getXPosition(scatterPoint.x);
|
|
33
|
+
const y = getYPosition(scatterPoint.y);
|
|
34
|
+
const isInRange = x >= minXRange && x <= maxXRange && y >= minYRange && y <= maxYRange;
|
|
35
|
+
const pointCtx = {
|
|
58
36
|
type: 'scatter',
|
|
59
37
|
seriesId: series.id,
|
|
60
|
-
dataIndex
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
38
|
+
dataIndex: i
|
|
39
|
+
};
|
|
40
|
+
if (isInRange) {
|
|
41
|
+
temp.push({
|
|
42
|
+
x,
|
|
43
|
+
y,
|
|
44
|
+
isFaded: !getIsHighlighted(item, pointCtx, series.highlightScope) && getIsFaded(item, pointCtx, series.highlightScope),
|
|
45
|
+
interactionProps: getInteractionItemProps(pointCtx),
|
|
46
|
+
id: scatterPoint.id
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return temp;
|
|
51
|
+
}, [yScale, xScale, getInteractionItemProps, item, series.data, series.highlightScope, series.id]);
|
|
52
|
+
return /*#__PURE__*/_jsx("g", {
|
|
53
|
+
children: cleanData.map(dataPoint => /*#__PURE__*/_jsx("circle", _extends({
|
|
54
|
+
cx: 0,
|
|
55
|
+
cy: 0,
|
|
56
|
+
r: markerSize,
|
|
57
|
+
transform: `translate(${dataPoint.x}, ${dataPoint.y})`,
|
|
58
|
+
fill: color,
|
|
59
|
+
opacity: dataPoint.isFaded && 0.3 || 1
|
|
60
|
+
}, dataPoint.interactionProps), dataPoint.id))
|
|
75
61
|
});
|
|
76
62
|
}
|
|
77
63
|
process.env.NODE_ENV !== "production" ? Scatter.propTypes = {
|
|
@@ -64,7 +64,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
64
64
|
}),
|
|
65
65
|
/**
|
|
66
66
|
* Indicate which axis to display the bottom of the charts.
|
|
67
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
67
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
68
68
|
* @default xAxisIds[0] The id of the first provided axis
|
|
69
69
|
*/
|
|
70
70
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -91,7 +91,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
91
91
|
height: PropTypes.number,
|
|
92
92
|
/**
|
|
93
93
|
* Indicate which axis to display the left of the charts.
|
|
94
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
94
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
95
95
|
* @default yAxisIds[0] The id of the first provided axis
|
|
96
96
|
*/
|
|
97
97
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -131,7 +131,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
131
131
|
}),
|
|
132
132
|
/**
|
|
133
133
|
* Indicate which axis to display the right of the charts.
|
|
134
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
134
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
135
135
|
* @default null
|
|
136
136
|
*/
|
|
137
137
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -176,7 +176,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
176
176
|
}),
|
|
177
177
|
/**
|
|
178
178
|
* Indicate which axis to display the top of the charts.
|
|
179
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
179
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
180
180
|
* @default null
|
|
181
181
|
*/
|
|
182
182
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import useChartDimensions from '../hooks/useChartDimensions';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Defines the area in which it is possible to draw the charts
|
|
6
|
+
* Defines the area in which it is possible to draw the charts.
|
|
7
7
|
*/
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
export const DrawingContext = /*#__PURE__*/React.createContext({
|
package/index.js
CHANGED
|
@@ -83,7 +83,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
83
83
|
}),
|
|
84
84
|
/**
|
|
85
85
|
* Indicate which axis to display the bottom of the charts.
|
|
86
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
86
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
87
87
|
* @default xAxisIds[0] The id of the first provided axis
|
|
88
88
|
*/
|
|
89
89
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -110,7 +110,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
110
110
|
height: PropTypes.number,
|
|
111
111
|
/**
|
|
112
112
|
* Indicate which axis to display the left of the charts.
|
|
113
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
113
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
114
114
|
* @default yAxisIds[0] The id of the first provided axis
|
|
115
115
|
*/
|
|
116
116
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -150,7 +150,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
150
150
|
}),
|
|
151
151
|
/**
|
|
152
152
|
* Indicate which axis to display the right of the charts.
|
|
153
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
153
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
154
154
|
* @default null
|
|
155
155
|
*/
|
|
156
156
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -193,7 +193,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
193
193
|
}),
|
|
194
194
|
/**
|
|
195
195
|
* Indicate which axis to display the top of the charts.
|
|
196
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
196
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
197
197
|
* @default null
|
|
198
198
|
*/
|
|
199
199
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -69,7 +69,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
69
69
|
// ----------------------------------------------------------------------
|
|
70
70
|
/**
|
|
71
71
|
* Indicate which axis to display the bottom of the charts.
|
|
72
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
72
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
73
73
|
* @default xAxisIds[0] The id of the first provided axis
|
|
74
74
|
*/
|
|
75
75
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -87,7 +87,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
87
87
|
}), PropTypes.string]),
|
|
88
88
|
/**
|
|
89
89
|
* Indicate which axis to display the left of the charts.
|
|
90
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
90
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
91
91
|
* @default yAxisIds[0] The id of the first provided axis
|
|
92
92
|
*/
|
|
93
93
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -105,7 +105,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
105
105
|
}), PropTypes.string]),
|
|
106
106
|
/**
|
|
107
107
|
* Indicate which axis to display the right of the charts.
|
|
108
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
108
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
109
109
|
* @default null
|
|
110
110
|
*/
|
|
111
111
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -123,7 +123,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
123
123
|
}), PropTypes.string]),
|
|
124
124
|
/**
|
|
125
125
|
* Indicate which axis to display the top of the charts.
|
|
126
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
126
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
127
127
|
* @default null
|
|
128
128
|
*/
|
|
129
129
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -86,7 +86,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
86
86
|
}),
|
|
87
87
|
/**
|
|
88
88
|
* Indicate which axis to display the bottom of the charts.
|
|
89
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
89
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
90
90
|
* @default xAxisIds[0] The id of the first provided axis
|
|
91
91
|
*/
|
|
92
92
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -113,7 +113,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
113
113
|
height: PropTypes.number,
|
|
114
114
|
/**
|
|
115
115
|
* Indicate which axis to display the left of the charts.
|
|
116
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
116
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
117
117
|
* @default yAxisIds[0] The id of the first provided axis
|
|
118
118
|
*/
|
|
119
119
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -153,7 +153,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
153
153
|
}),
|
|
154
154
|
/**
|
|
155
155
|
* Indicate which axis to display the right of the charts.
|
|
156
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
156
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
157
157
|
* @default null
|
|
158
158
|
*/
|
|
159
159
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -198,7 +198,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
198
198
|
}),
|
|
199
199
|
/**
|
|
200
200
|
* Indicate which axis to display the top of the charts.
|
|
201
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
201
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
202
202
|
* @default null
|
|
203
203
|
*/
|
|
204
204
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -24,9 +24,9 @@ export var getExtremumY = function getExtremumY(params) {
|
|
|
24
24
|
var _series$seriesId$stac = series[seriesId].stackedData.reduce(function (seriesAcc, stackedValue) {
|
|
25
25
|
var _getValues = getValues(stackedValue),
|
|
26
26
|
_getValues2 = _slicedToArray(_getValues, 2),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return [Math.min(
|
|
27
|
+
base = _getValues2[0],
|
|
28
|
+
value = _getValues2[1];
|
|
29
|
+
return [Math.min(base, value, seriesAcc[0]), Math.max(base, value, seriesAcc[1])];
|
|
30
30
|
}, getValues(series[seriesId].stackedData[0])),
|
|
31
31
|
_series$seriesId$stac2 = _slicedToArray(_series$seriesId$stac, 2),
|
|
32
32
|
seriesMin = _series$seriesId$stac2[0],
|
|
@@ -94,7 +94,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
94
94
|
}),
|
|
95
95
|
/**
|
|
96
96
|
* Indicate which axis to display the bottom of the charts.
|
|
97
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
97
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
98
98
|
* @default xAxisIds[0] The id of the first provided axis
|
|
99
99
|
*/
|
|
100
100
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -121,7 +121,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
121
121
|
height: PropTypes.number,
|
|
122
122
|
/**
|
|
123
123
|
* Indicate which axis to display the left of the charts.
|
|
124
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
124
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
125
125
|
* @default yAxisIds[0] The id of the first provided axis
|
|
126
126
|
*/
|
|
127
127
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -161,7 +161,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
161
161
|
}),
|
|
162
162
|
/**
|
|
163
163
|
* Indicate which axis to display the right of the charts.
|
|
164
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
164
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
165
165
|
* @default null
|
|
166
166
|
*/
|
|
167
167
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -226,7 +226,7 @@ process.env.NODE_ENV !== "production" ? PieChart.propTypes = {
|
|
|
226
226
|
}),
|
|
227
227
|
/**
|
|
228
228
|
* Indicate which axis to display the top of the charts.
|
|
229
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
229
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
230
230
|
* @default null
|
|
231
231
|
*/
|
|
232
232
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -28,8 +28,8 @@ var useChartDimensions = function useChartDimensions(inWidth, inHeight) {
|
|
|
28
28
|
}
|
|
29
29
|
var win = ownerWindow(mainEl);
|
|
30
30
|
var computedStyle = win.getComputedStyle(mainEl);
|
|
31
|
-
var newHeight = parseFloat(computedStyle.height) || 0;
|
|
32
|
-
var newWidth = parseFloat(computedStyle.width) || 0;
|
|
31
|
+
var newHeight = Math.floor(parseFloat(computedStyle.height)) || 0;
|
|
32
|
+
var newWidth = Math.floor(parseFloat(computedStyle.width)) || 0;
|
|
33
33
|
setWidth(newWidth);
|
|
34
34
|
setHeight(newHeight);
|
|
35
35
|
}, []);
|
|
@@ -14,60 +14,49 @@ function Scatter(props) {
|
|
|
14
14
|
markerSize = props.markerSize;
|
|
15
15
|
var _React$useContext = React.useContext(InteractionContext),
|
|
16
16
|
item = _React$useContext.item;
|
|
17
|
-
var getXPosition = getValueToPositionMapper(xScale);
|
|
18
|
-
var getYPosition = getValueToPositionMapper(yScale);
|
|
19
17
|
var getInteractionItemProps = useInteractionItemProps(series.highlightScope);
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
y = _ref2.y,
|
|
37
|
-
id = _ref2.id;
|
|
38
|
-
return {
|
|
39
|
-
x: getXPosition(x),
|
|
40
|
-
y: getYPosition(y),
|
|
41
|
-
id: id,
|
|
42
|
-
dataIndex: index
|
|
43
|
-
};
|
|
44
|
-
}).filter(isInRange).map(function (_ref3) {
|
|
45
|
-
var x = _ref3.x,
|
|
46
|
-
y = _ref3.y,
|
|
47
|
-
id = _ref3.id,
|
|
48
|
-
dataIndex = _ref3.dataIndex;
|
|
49
|
-
var isHighlighted = getIsHighlighted(item, {
|
|
50
|
-
type: 'scatter',
|
|
51
|
-
seriesId: series.id,
|
|
52
|
-
dataIndex: dataIndex
|
|
53
|
-
}, series.highlightScope);
|
|
54
|
-
var isFaded = !isHighlighted && getIsFaded(item, {
|
|
18
|
+
var cleanData = React.useMemo(function () {
|
|
19
|
+
var getXPosition = getValueToPositionMapper(xScale);
|
|
20
|
+
var getYPosition = getValueToPositionMapper(yScale);
|
|
21
|
+
var xRange = xScale.range();
|
|
22
|
+
var yRange = yScale.range();
|
|
23
|
+
var minXRange = Math.min.apply(Math, _toConsumableArray(xRange));
|
|
24
|
+
var maxXRange = Math.max.apply(Math, _toConsumableArray(xRange));
|
|
25
|
+
var minYRange = Math.min.apply(Math, _toConsumableArray(yRange));
|
|
26
|
+
var maxYRange = Math.max.apply(Math, _toConsumableArray(yRange));
|
|
27
|
+
var temp = [];
|
|
28
|
+
for (var i = 0; i < series.data.length; i += 1) {
|
|
29
|
+
var scatterPoint = series.data[i];
|
|
30
|
+
var x = getXPosition(scatterPoint.x);
|
|
31
|
+
var y = getYPosition(scatterPoint.y);
|
|
32
|
+
var isInRange = x >= minXRange && x <= maxXRange && y >= minYRange && y <= maxYRange;
|
|
33
|
+
var pointCtx = {
|
|
55
34
|
type: 'scatter',
|
|
56
35
|
seriesId: series.id,
|
|
57
|
-
dataIndex:
|
|
58
|
-
}
|
|
36
|
+
dataIndex: i
|
|
37
|
+
};
|
|
38
|
+
if (isInRange) {
|
|
39
|
+
temp.push({
|
|
40
|
+
x: x,
|
|
41
|
+
y: y,
|
|
42
|
+
isFaded: !getIsHighlighted(item, pointCtx, series.highlightScope) && getIsFaded(item, pointCtx, series.highlightScope),
|
|
43
|
+
interactionProps: getInteractionItemProps(pointCtx),
|
|
44
|
+
id: scatterPoint.id
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return temp;
|
|
49
|
+
}, [yScale, xScale, getInteractionItemProps, item, series.data, series.highlightScope, series.id]);
|
|
50
|
+
return /*#__PURE__*/_jsx("g", {
|
|
51
|
+
children: cleanData.map(function (dataPoint) {
|
|
59
52
|
return /*#__PURE__*/_jsx("circle", _extends({
|
|
60
53
|
cx: 0,
|
|
61
54
|
cy: 0,
|
|
62
55
|
r: markerSize,
|
|
63
|
-
transform: "translate(".concat(x, ", ").concat(y, ")"),
|
|
56
|
+
transform: "translate(".concat(dataPoint.x, ", ").concat(dataPoint.y, ")"),
|
|
64
57
|
fill: color,
|
|
65
|
-
opacity: isFaded && 0.3 || 1
|
|
66
|
-
},
|
|
67
|
-
type: 'scatter',
|
|
68
|
-
seriesId: series.id,
|
|
69
|
-
dataIndex: dataIndex
|
|
70
|
-
})), id);
|
|
58
|
+
opacity: dataPoint.isFaded && 0.3 || 1
|
|
59
|
+
}, dataPoint.interactionProps), dataPoint.id);
|
|
71
60
|
})
|
|
72
61
|
});
|
|
73
62
|
}
|
|
@@ -64,7 +64,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
64
64
|
}),
|
|
65
65
|
/**
|
|
66
66
|
* Indicate which axis to display the bottom of the charts.
|
|
67
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
67
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
68
68
|
* @default xAxisIds[0] The id of the first provided axis
|
|
69
69
|
*/
|
|
70
70
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -91,7 +91,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
91
91
|
height: PropTypes.number,
|
|
92
92
|
/**
|
|
93
93
|
* Indicate which axis to display the left of the charts.
|
|
94
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
94
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
95
95
|
* @default yAxisIds[0] The id of the first provided axis
|
|
96
96
|
*/
|
|
97
97
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -131,7 +131,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
131
131
|
}),
|
|
132
132
|
/**
|
|
133
133
|
* Indicate which axis to display the right of the charts.
|
|
134
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
134
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
135
135
|
* @default null
|
|
136
136
|
*/
|
|
137
137
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -176,7 +176,7 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
176
176
|
}),
|
|
177
177
|
/**
|
|
178
178
|
* Indicate which axis to display the top of the charts.
|
|
179
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
179
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
180
180
|
* @default null
|
|
181
181
|
*/
|
|
182
182
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import useChartDimensions from '../hooks/useChartDimensions';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Defines the area in which it is possible to draw the charts
|
|
6
|
+
* Defines the area in which it is possible to draw the charts.
|
|
7
7
|
*/
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
export var DrawingContext = /*#__PURE__*/React.createContext({
|
package/legacy/index.js
CHANGED
|
@@ -78,7 +78,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
78
78
|
}),
|
|
79
79
|
/**
|
|
80
80
|
* Indicate which axis to display the bottom of the charts.
|
|
81
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
81
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
82
82
|
* @default xAxisIds[0] The id of the first provided axis
|
|
83
83
|
*/
|
|
84
84
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -105,7 +105,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
105
105
|
height: PropTypes.number,
|
|
106
106
|
/**
|
|
107
107
|
* Indicate which axis to display the left of the charts.
|
|
108
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
108
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
109
109
|
* @default yAxisIds[0] The id of the first provided axis
|
|
110
110
|
*/
|
|
111
111
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -145,7 +145,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
145
145
|
}),
|
|
146
146
|
/**
|
|
147
147
|
* Indicate which axis to display the right of the charts.
|
|
148
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
148
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
149
149
|
* @default null
|
|
150
150
|
*/
|
|
151
151
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -188,7 +188,7 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
188
188
|
}),
|
|
189
189
|
/**
|
|
190
190
|
* Indicate which axis to display the top of the charts.
|
|
191
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
191
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
192
192
|
* @default null
|
|
193
193
|
*/
|
|
194
194
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -71,7 +71,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
71
71
|
// ----------------------------------------------------------------------
|
|
72
72
|
/**
|
|
73
73
|
* Indicate which axis to display the bottom of the charts.
|
|
74
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
74
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
75
75
|
* @default xAxisIds[0] The id of the first provided axis
|
|
76
76
|
*/
|
|
77
77
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -89,7 +89,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
89
89
|
}), PropTypes.string]),
|
|
90
90
|
/**
|
|
91
91
|
* Indicate which axis to display the left of the charts.
|
|
92
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
92
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
93
93
|
* @default yAxisIds[0] The id of the first provided axis
|
|
94
94
|
*/
|
|
95
95
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -107,7 +107,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
107
107
|
}), PropTypes.string]),
|
|
108
108
|
/**
|
|
109
109
|
* Indicate which axis to display the right of the charts.
|
|
110
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
110
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
111
111
|
* @default null
|
|
112
112
|
*/
|
|
113
113
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -125,7 +125,7 @@ process.env.NODE_ENV !== "production" ? ChartsAxis.propTypes = {
|
|
|
125
125
|
}), PropTypes.string]),
|
|
126
126
|
/**
|
|
127
127
|
* Indicate which axis to display the top of the charts.
|
|
128
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
128
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
129
129
|
* @default null
|
|
130
130
|
*/
|
|
131
131
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -80,7 +80,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
80
80
|
}),
|
|
81
81
|
/**
|
|
82
82
|
* Indicate which axis to display the bottom of the charts.
|
|
83
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
83
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
84
84
|
* @default xAxisIds[0] The id of the first provided axis
|
|
85
85
|
*/
|
|
86
86
|
bottomAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -107,7 +107,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
107
107
|
height: PropTypes.number,
|
|
108
108
|
/**
|
|
109
109
|
* Indicate which axis to display the left of the charts.
|
|
110
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
110
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
111
111
|
* @default yAxisIds[0] The id of the first provided axis
|
|
112
112
|
*/
|
|
113
113
|
leftAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -147,7 +147,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
147
147
|
}),
|
|
148
148
|
/**
|
|
149
149
|
* Indicate which axis to display the right of the charts.
|
|
150
|
-
* Can be a string (the id of the axis) or an object `ChartsYAxisProps
|
|
150
|
+
* Can be a string (the id of the axis) or an object `ChartsYAxisProps`.
|
|
151
151
|
* @default null
|
|
152
152
|
*/
|
|
153
153
|
rightAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -192,7 +192,7 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
192
192
|
}),
|
|
193
193
|
/**
|
|
194
194
|
* Indicate which axis to display the top of the charts.
|
|
195
|
-
* Can be a string (the id of the axis) or an object `ChartsXAxisProps
|
|
195
|
+
* Can be a string (the id of the axis) or an object `ChartsXAxisProps`.
|
|
196
196
|
* @default null
|
|
197
197
|
*/
|
|
198
198
|
topAxis: PropTypes.oneOfType([PropTypes.shape({
|
|
@@ -17,8 +17,8 @@ export const getExtremumY = params => {
|
|
|
17
17
|
const getValues = isArea ? d => d : d => [d[1], d[1]]; // Id area should go from bottom to top, without area should only consider the top
|
|
18
18
|
|
|
19
19
|
const [seriesMin, seriesMax] = series[seriesId].stackedData.reduce((seriesAcc, stackedValue) => {
|
|
20
|
-
const [
|
|
21
|
-
return [Math.min(
|
|
20
|
+
const [base, value] = getValues(stackedValue);
|
|
21
|
+
return [Math.min(base, value, seriesAcc[0]), Math.max(base, value, seriesAcc[1])];
|
|
22
22
|
}, getValues(series[seriesId].stackedData[0]));
|
|
23
23
|
if (acc[0] === null || acc[1] === null) {
|
|
24
24
|
return [seriesMin, seriesMax];
|