@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
|
@@ -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/modern/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.5",
|
|
4
4
|
"description": "The community edition of the charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -27,10 +27,7 @@
|
|
|
27
27
|
"directory": "packages/x-charts"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@babel/runtime": "^7.22.
|
|
31
|
-
"@types/d3-color": "^3.1.0",
|
|
32
|
-
"@types/d3-scale": "^4.0.3",
|
|
33
|
-
"@types/d3-shape": "^3.1.1",
|
|
30
|
+
"@babel/runtime": "^7.22.6",
|
|
34
31
|
"clsx": "^1.2.1",
|
|
35
32
|
"d3-color": "^3.1.0",
|
|
36
33
|
"d3-scale": "^4.0.2",
|
|
@@ -38,11 +35,31 @@
|
|
|
38
35
|
"prop-types": "^15.8.1"
|
|
39
36
|
},
|
|
40
37
|
"peerDependencies": {
|
|
38
|
+
"@emotion/react": "^11.9.0",
|
|
39
|
+
"@emotion/styled": "^11.8.1",
|
|
41
40
|
"@mui/material": "^5.4.1",
|
|
42
41
|
"@mui/system": "^5.4.1",
|
|
43
42
|
"react": "^17.0.0 || ^18.0.0",
|
|
44
43
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
45
44
|
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"@emotion/react": {
|
|
47
|
+
"optional": true
|
|
48
|
+
},
|
|
49
|
+
"@emotion/styled": {
|
|
50
|
+
"optional": true
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"exports": {
|
|
54
|
+
".": {
|
|
55
|
+
"require": "./index.js",
|
|
56
|
+
"import": "./esm/index.js"
|
|
57
|
+
},
|
|
58
|
+
"./*": {
|
|
59
|
+
"require": "./*",
|
|
60
|
+
"import": "./esm/*"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
46
63
|
"setupFiles": [
|
|
47
64
|
"<rootDir>/src/setupTests.js"
|
|
48
65
|
],
|