@mui/x-charts 6.0.0-alpha.15 → 6.0.0-alpha.16
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 +13 -2
- package/BarChart/BarChart.js +45 -3
- package/BarChart/BarElement.d.ts +1318 -3
- package/BarChart/BarElement.js +10 -8
- package/BarChart/BarPlot.d.ts +17 -1
- package/BarChart/BarPlot.js +152 -66
- package/CHANGELOG.md +65 -0
- package/ChartContainer/index.js +5 -2
- package/ChartsAxis/ChartsAxis.js +18 -2
- package/ChartsAxis/axisClasses.d.ts +1 -1
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +2 -2
- package/ChartsClipPath/ChartsClipPath.js +2 -2
- package/ChartsLegend/ChartsLegend.d.ts +2 -1
- package/ChartsLegend/ChartsLegend.js +12 -8
- package/ChartsSurface.js +2 -2
- package/ChartsTooltip/ChartsAxisTooltipContent.js +2 -2
- package/ChartsTooltip/ChartsItemTooltipContent.js +2 -2
- package/ChartsTooltip/ChartsTooltip.js +2 -2
- package/ChartsTooltip/utils.js +2 -2
- package/ChartsXAxis/ChartsXAxis.js +123 -35
- package/ChartsYAxis/ChartsYAxis.js +38 -16
- package/LineChart/AreaElement.d.ts +10 -0
- package/LineChart/AreaElement.js +12 -2
- package/LineChart/AreaPlot.d.ts +11 -0
- package/LineChart/AreaPlot.js +13 -2
- package/LineChart/LineChart.d.ts +10 -0
- package/LineChart/LineChart.js +36 -2
- package/LineChart/LineElement.d.ts +10 -0
- package/LineChart/LineElement.js +12 -2
- package/LineChart/LineHighlightElement.d.ts +10 -0
- package/LineChart/LineHighlightElement.js +12 -2
- package/LineChart/LineHighlightPlot.d.ts +10 -0
- package/LineChart/LineHighlightPlot.js +12 -2
- package/LineChart/LinePlot.d.ts +10 -0
- package/LineChart/LinePlot.js +12 -2
- package/LineChart/MarkElement.d.ts +10 -0
- package/LineChart/MarkElement.js +12 -2
- package/LineChart/MarkPlot.d.ts +10 -0
- package/LineChart/MarkPlot.js +12 -2
- package/PieChart/PieArc.js +2 -2
- package/PieChart/PieArcLabel.js +2 -2
- package/PieChart/PieChart.d.ts +10 -0
- package/PieChart/PieChart.js +37 -2
- package/PieChart/PiePlot.d.ts +10 -0
- package/PieChart/PiePlot.js +12 -2
- package/ResponsiveChartContainer/index.js +4 -4
- package/ScatterChart/Scatter.d.ts +10 -0
- package/ScatterChart/Scatter.js +12 -2
- package/ScatterChart/ScatterChart.d.ts +10 -0
- package/ScatterChart/ScatterChart.js +36 -2
- package/ScatterChart/ScatterPlot.d.ts +10 -0
- package/ScatterChart/ScatterPlot.js +12 -2
- package/SparkLineChart/SparkLineChart.d.ts +9 -0
- package/SparkLineChart/SparkLineChart.js +16 -2
- package/context/CartesianContextProvider.js +10 -2
- package/context/DrawingProvider.js +2 -2
- package/context/HighlightProvider.js +2 -2
- package/context/InteractionProvider.js +2 -2
- package/context/SeriesContextProvider.js +2 -2
- package/esm/BarChart/BarChart.js +43 -1
- package/esm/BarChart/BarElement.js +7 -4
- package/esm/BarChart/BarPlot.js +152 -67
- package/esm/ChartContainer/index.js +3 -0
- package/esm/ChartsAxis/ChartsAxis.js +16 -0
- package/esm/ChartsLegend/ChartsLegend.js +10 -6
- package/esm/ChartsXAxis/ChartsXAxis.js +122 -34
- package/esm/ChartsYAxis/ChartsYAxis.js +36 -14
- package/esm/LineChart/AreaElement.js +10 -0
- package/esm/LineChart/AreaPlot.js +11 -0
- package/esm/LineChart/LineChart.js +34 -0
- package/esm/LineChart/LineElement.js +10 -0
- package/esm/LineChart/LineHighlightElement.js +10 -0
- package/esm/LineChart/LineHighlightPlot.js +10 -0
- package/esm/LineChart/LinePlot.js +10 -0
- package/esm/LineChart/MarkElement.js +10 -0
- package/esm/LineChart/MarkPlot.js +10 -0
- package/esm/PieChart/PieChart.js +35 -0
- package/esm/PieChart/PiePlot.js +10 -0
- package/esm/ResponsiveChartContainer/index.js +2 -2
- package/esm/ScatterChart/Scatter.js +10 -0
- package/esm/ScatterChart/ScatterChart.js +34 -0
- package/esm/ScatterChart/ScatterPlot.js +10 -0
- package/esm/SparkLineChart/SparkLineChart.js +14 -0
- package/esm/context/CartesianContextProvider.js +8 -0
- package/esm/hooks/useMounted.js +16 -0
- package/esm/hooks/useReducedMotion.js +27 -0
- package/esm/hooks/useTicks.js +12 -6
- package/esm/internals/components/ChartsText.js +17 -13
- package/esm/internals/geometry.js +36 -0
- package/hooks/useAxisEvents.js +2 -2
- package/hooks/useChartDimensions.js +2 -2
- package/hooks/useDrawingArea.js +2 -2
- package/hooks/useInteractionItemProps.js +2 -2
- package/hooks/useMounted.d.ts +1 -0
- package/hooks/useMounted.js +25 -0
- package/hooks/useReducedMotion.d.ts +8 -0
- package/hooks/useReducedMotion.js +33 -0
- package/hooks/useScale.d.ts +2 -2
- package/hooks/useScale.js +2 -2
- package/hooks/useTicks.d.ts +18 -9
- package/hooks/useTicks.js +14 -8
- package/index.js +1 -1
- package/internals/components/ChartsText.d.ts +11 -8
- package/internals/components/ChartsText.js +19 -15
- package/internals/defaultizeColor.d.ts +1 -1
- package/internals/domUtils.d.ts +0 -1
- package/internals/geometry.d.ts +9 -0
- package/internals/geometry.js +42 -0
- package/legacy/BarChart/BarChart.js +43 -1
- package/legacy/BarChart/BarElement.js +6 -3
- package/legacy/BarChart/BarPlot.js +151 -63
- package/legacy/ChartContainer/index.js +3 -0
- package/legacy/ChartsAxis/ChartsAxis.js +16 -0
- package/legacy/ChartsLegend/ChartsLegend.js +14 -7
- package/legacy/ChartsXAxis/ChartsXAxis.js +126 -36
- package/legacy/ChartsYAxis/ChartsYAxis.js +36 -14
- package/legacy/LineChart/AreaElement.js +10 -0
- package/legacy/LineChart/AreaPlot.js +11 -0
- package/legacy/LineChart/LineChart.js +34 -0
- package/legacy/LineChart/LineElement.js +10 -0
- package/legacy/LineChart/LineHighlightElement.js +10 -0
- package/legacy/LineChart/LineHighlightPlot.js +10 -0
- package/legacy/LineChart/LinePlot.js +10 -0
- package/legacy/LineChart/MarkElement.js +10 -0
- package/legacy/LineChart/MarkPlot.js +10 -0
- package/legacy/PieChart/PieChart.js +35 -0
- package/legacy/PieChart/PiePlot.js +10 -0
- package/legacy/ResponsiveChartContainer/index.js +2 -2
- package/legacy/ScatterChart/Scatter.js +10 -0
- package/legacy/ScatterChart/ScatterChart.js +34 -0
- package/legacy/ScatterChart/ScatterPlot.js +10 -0
- package/legacy/SparkLineChart/SparkLineChart.js +14 -0
- package/legacy/context/CartesianContextProvider.js +8 -0
- package/legacy/hooks/useMounted.js +21 -0
- package/legacy/hooks/useReducedMotion.js +27 -0
- package/legacy/hooks/useTicks.js +13 -6
- package/legacy/index.js +1 -1
- package/legacy/internals/components/ChartsText.js +15 -15
- package/legacy/internals/geometry.js +37 -0
- package/models/axis.d.ts +19 -2
- package/models/seriesType/line.d.ts +2 -2
- package/modern/BarChart/BarChart.js +43 -1
- package/modern/BarChart/BarElement.js +7 -4
- package/modern/BarChart/BarPlot.js +149 -65
- package/modern/ChartContainer/index.js +3 -0
- package/modern/ChartsAxis/ChartsAxis.js +16 -0
- package/modern/ChartsLegend/ChartsLegend.js +10 -6
- package/modern/ChartsXAxis/ChartsXAxis.js +122 -34
- package/modern/ChartsYAxis/ChartsYAxis.js +36 -14
- package/modern/LineChart/AreaElement.js +10 -0
- package/modern/LineChart/AreaPlot.js +11 -0
- package/modern/LineChart/LineChart.js +34 -0
- package/modern/LineChart/LineElement.js +10 -0
- package/modern/LineChart/LineHighlightElement.js +10 -0
- package/modern/LineChart/LineHighlightPlot.js +10 -0
- package/modern/LineChart/LinePlot.js +10 -0
- package/modern/LineChart/MarkElement.js +10 -0
- package/modern/LineChart/MarkPlot.js +10 -0
- package/modern/PieChart/PieChart.js +35 -0
- package/modern/PieChart/PiePlot.js +10 -0
- package/modern/ResponsiveChartContainer/index.js +2 -2
- package/modern/ScatterChart/Scatter.js +10 -0
- package/modern/ScatterChart/ScatterChart.js +34 -0
- package/modern/ScatterChart/ScatterPlot.js +10 -0
- package/modern/SparkLineChart/SparkLineChart.js +14 -0
- package/modern/context/CartesianContextProvider.js +8 -0
- package/modern/hooks/useMounted.js +16 -0
- package/modern/hooks/useReducedMotion.js +27 -0
- package/modern/hooks/useTicks.js +12 -6
- package/modern/index.js +1 -1
- package/modern/internals/components/ChartsText.js +17 -13
- package/modern/internals/geometry.js +36 -0
- package/package.json +5 -3
|
@@ -15,6 +15,16 @@ const SPARKLINE_DEFAULT_MARGIN = {
|
|
|
15
15
|
left: 5,
|
|
16
16
|
right: 5
|
|
17
17
|
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Demos:
|
|
21
|
+
*
|
|
22
|
+
* - [SparkLine](https://mui.com/x/react-charts/sparkline/)
|
|
23
|
+
*
|
|
24
|
+
* API:
|
|
25
|
+
*
|
|
26
|
+
* - [SparkLineChart API](https://mui.com/x/api/charts/spark-line-chart/)
|
|
27
|
+
*/
|
|
18
28
|
const SparkLineChart = /*#__PURE__*/React.forwardRef(function SparkLineChart(props, ref) {
|
|
19
29
|
const {
|
|
20
30
|
xAxis,
|
|
@@ -195,6 +205,7 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
195
205
|
id: PropTypes.string,
|
|
196
206
|
label: PropTypes.string,
|
|
197
207
|
labelFontSize: PropTypes.number,
|
|
208
|
+
labelStyle: PropTypes.object,
|
|
198
209
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
199
210
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
200
211
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
@@ -203,6 +214,9 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
203
214
|
slots: PropTypes.object,
|
|
204
215
|
stroke: PropTypes.string,
|
|
205
216
|
tickFontSize: PropTypes.number,
|
|
217
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
218
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
219
|
+
tickLabelStyle: PropTypes.object,
|
|
206
220
|
tickMaxStep: PropTypes.number,
|
|
207
221
|
tickMinStep: PropTypes.number,
|
|
208
222
|
tickNumber: PropTypes.number,
|
|
@@ -222,6 +222,7 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
222
222
|
id: PropTypes.string,
|
|
223
223
|
label: PropTypes.string,
|
|
224
224
|
labelFontSize: PropTypes.number,
|
|
225
|
+
labelStyle: PropTypes.object,
|
|
225
226
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
226
227
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
227
228
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
@@ -230,6 +231,9 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
230
231
|
slots: PropTypes.object,
|
|
231
232
|
stroke: PropTypes.string,
|
|
232
233
|
tickFontSize: PropTypes.number,
|
|
234
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
235
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
236
|
+
tickLabelStyle: PropTypes.object,
|
|
233
237
|
tickMaxStep: PropTypes.number,
|
|
234
238
|
tickMinStep: PropTypes.number,
|
|
235
239
|
tickNumber: PropTypes.number,
|
|
@@ -248,6 +252,7 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
248
252
|
id: PropTypes.string,
|
|
249
253
|
label: PropTypes.string,
|
|
250
254
|
labelFontSize: PropTypes.number,
|
|
255
|
+
labelStyle: PropTypes.object,
|
|
251
256
|
max: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
252
257
|
min: PropTypes.oneOfType([PropTypes.instanceOf(Date), PropTypes.number]),
|
|
253
258
|
position: PropTypes.oneOf(['bottom', 'left', 'right', 'top']),
|
|
@@ -256,6 +261,9 @@ process.env.NODE_ENV !== "production" ? CartesianContextProvider.propTypes = {
|
|
|
256
261
|
slots: PropTypes.object,
|
|
257
262
|
stroke: PropTypes.string,
|
|
258
263
|
tickFontSize: PropTypes.number,
|
|
264
|
+
tickInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.array, PropTypes.func]),
|
|
265
|
+
tickLabelInterval: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.func]),
|
|
266
|
+
tickLabelStyle: PropTypes.object,
|
|
259
267
|
tickMaxStep: PropTypes.number,
|
|
260
268
|
tickMinStep: PropTypes.number,
|
|
261
269
|
tickNumber: PropTypes.number,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
3
|
+
export function useMounted(defer = false) {
|
|
4
|
+
const [mountedState, setMountedState] = React.useState(false);
|
|
5
|
+
useEnhancedEffect(() => {
|
|
6
|
+
if (!defer) {
|
|
7
|
+
setMountedState(true);
|
|
8
|
+
}
|
|
9
|
+
}, [defer]);
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
if (defer) {
|
|
12
|
+
setMountedState(true);
|
|
13
|
+
}
|
|
14
|
+
}, [defer]);
|
|
15
|
+
return mountedState;
|
|
16
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useIsomorphicLayoutEffect, Globals } from '@react-spring/web';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Returns `boolean` or `null`, used to automatically
|
|
5
|
+
* set skipAnimations to the value of the user's
|
|
6
|
+
* `prefers-reduced-motion` query.
|
|
7
|
+
*
|
|
8
|
+
* The return value, post-effect, is the value of their prefered setting
|
|
9
|
+
*/
|
|
10
|
+
export const useReducedMotion = () => {
|
|
11
|
+
// Taken from: https://github.com/pmndrs/react-spring/blob/02ec877bbfab0df46da0e4a47d5f68d3e731206a/packages/shared/src/hooks/useReducedMotion.ts#L13
|
|
12
|
+
|
|
13
|
+
useIsomorphicLayoutEffect(() => {
|
|
14
|
+
const mql = window.matchMedia('(prefers-reduced-motion)');
|
|
15
|
+
const handleMediaChange = e => {
|
|
16
|
+
Globals.assign({
|
|
17
|
+
// Modification such the react-spring implementation such that this hook can remove animation but never activate animation.
|
|
18
|
+
skipAnimation: e.matches || undefined
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
handleMediaChange(mql);
|
|
22
|
+
mql.addEventListener('change', handleMediaChange);
|
|
23
|
+
return () => {
|
|
24
|
+
mql.removeEventListener('change', handleMediaChange);
|
|
25
|
+
};
|
|
26
|
+
}, []);
|
|
27
|
+
};
|
package/modern/hooks/useTicks.js
CHANGED
|
@@ -17,7 +17,8 @@ function useTicks(options) {
|
|
|
17
17
|
const {
|
|
18
18
|
scale,
|
|
19
19
|
tickNumber,
|
|
20
|
-
valueFormatter
|
|
20
|
+
valueFormatter,
|
|
21
|
+
tickInterval
|
|
21
22
|
} = options;
|
|
22
23
|
return React.useMemo(() => {
|
|
23
24
|
// band scale
|
|
@@ -26,7 +27,8 @@ function useTicks(options) {
|
|
|
26
27
|
if (scale.bandwidth() > 0) {
|
|
27
28
|
// scale type = 'band'
|
|
28
29
|
return [...domain.map(value => ({
|
|
29
|
-
|
|
30
|
+
value,
|
|
31
|
+
formattedValue: valueFormatter?.(value) ?? `${value}`,
|
|
30
32
|
offset: scale(value) - (scale.step() - scale.bandwidth()) / 2,
|
|
31
33
|
labelOffset: scale.step() / 2
|
|
32
34
|
})), {
|
|
@@ -37,17 +39,21 @@ function useTicks(options) {
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
// scale type = 'point'
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const filteredDomain = typeof tickInterval === 'function' && domain.filter(tickInterval) || typeof tickInterval === 'object' && tickInterval || domain;
|
|
43
|
+
return filteredDomain.map(value => ({
|
|
44
|
+
value,
|
|
45
|
+
formattedValue: valueFormatter?.(value) ?? `${value}`,
|
|
42
46
|
offset: scale(value),
|
|
43
47
|
labelOffset: 0
|
|
44
48
|
}));
|
|
45
49
|
}
|
|
46
|
-
|
|
50
|
+
const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
|
|
51
|
+
return ticks.map(value => ({
|
|
52
|
+
value,
|
|
47
53
|
formattedValue: valueFormatter?.(value) ?? scale.tickFormat(tickNumber)(value),
|
|
48
54
|
offset: scale(value),
|
|
49
55
|
labelOffset: 0
|
|
50
56
|
}));
|
|
51
|
-
}, [tickNumber, scale, valueFormatter]);
|
|
57
|
+
}, [tickNumber, scale, valueFormatter, tickInterval]);
|
|
52
58
|
}
|
|
53
59
|
export default useTicks;
|
package/modern/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
|
-
const _excluded = ["x", "y", "
|
|
3
|
+
const _excluded = ["x", "y", "style", "text", "ownerState"],
|
|
4
|
+
_excluded2 = ["angle", "textAnchor", "dominantBaseline"];
|
|
4
5
|
import * as React from 'react';
|
|
5
6
|
import { getStringSize } from '../domUtils';
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -20,12 +21,17 @@ export function ChartsText(props) {
|
|
|
20
21
|
const {
|
|
21
22
|
x,
|
|
22
23
|
y,
|
|
23
|
-
|
|
24
|
-
dominantBaseline = 'central',
|
|
25
|
-
style,
|
|
24
|
+
style: styleProps,
|
|
26
25
|
text
|
|
27
26
|
} = props,
|
|
28
27
|
textProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
28
|
+
const _ref = styleProps ?? {},
|
|
29
|
+
{
|
|
30
|
+
angle,
|
|
31
|
+
textAnchor,
|
|
32
|
+
dominantBaseline
|
|
33
|
+
} = _ref,
|
|
34
|
+
style = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
29
35
|
const wordsByLines = React.useMemo(() => getWordsByLines({
|
|
30
36
|
style,
|
|
31
37
|
needsComputation: text.includes('\n'),
|
|
@@ -43,19 +49,17 @@ export function ChartsText(props) {
|
|
|
43
49
|
startDy = (wordsByLines.length - 1) * -wordsByLines[0].height;
|
|
44
50
|
break;
|
|
45
51
|
}
|
|
46
|
-
|
|
47
|
-
// const transforms = [];
|
|
52
|
+
const transforms = [];
|
|
48
53
|
// if (scaleToFit) {
|
|
49
54
|
// const lineWidth = wordsByLines[0].width;
|
|
50
55
|
// transforms.push(`scale(${(isNumber(width as number) ? (width as number) / lineWidth : 1) / lineWidth})`);
|
|
51
56
|
// }
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
if (angle) {
|
|
58
|
+
transforms.push(`rotate(${angle}, ${x}, ${y})`);
|
|
59
|
+
}
|
|
60
|
+
if (transforms.length) {
|
|
61
|
+
textProps.transform = transforms.join(' ');
|
|
62
|
+
}
|
|
59
63
|
return /*#__PURE__*/_jsx("text", _extends({}, textProps, {
|
|
60
64
|
x: x,
|
|
61
65
|
y: y,
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const ANGLE_APPROX = 5; // Angle (in deg) for which we approximate the rectangle as perfectly horizontal/vertical
|
|
2
|
+
|
|
3
|
+
let warnedOnce = false;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Return the minimal translation along the x-axis to avoid overflow of a rectangle of a given width, height, and rotation.
|
|
7
|
+
* This assumes that all rectangles have the same height and angle between -90 and 90.
|
|
8
|
+
* Otherwise it would be problematic because you need the height/width of the next rectangle to do the correct computation.
|
|
9
|
+
* @param width the side along the x axis.
|
|
10
|
+
* @param height the side along the y axis.
|
|
11
|
+
* @param angle the rotation in degrees.
|
|
12
|
+
*/
|
|
13
|
+
export function getMinXTranslation(width, height, angle = 0) {
|
|
14
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
15
|
+
if (!warnedOnce && angle > 90 && angle < -90) {
|
|
16
|
+
warnedOnce = true;
|
|
17
|
+
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'));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
|
|
21
|
+
|
|
22
|
+
if (standardAngle < ANGLE_APPROX) {
|
|
23
|
+
// It's nearly horizontal
|
|
24
|
+
return width;
|
|
25
|
+
}
|
|
26
|
+
if (standardAngle > 90 - ANGLE_APPROX) {
|
|
27
|
+
// It's nearly vertical
|
|
28
|
+
return height;
|
|
29
|
+
}
|
|
30
|
+
const radAngle = standardAngle * Math.PI / 180;
|
|
31
|
+
const angleSwich = Math.atan2(height, width);
|
|
32
|
+
if (radAngle < angleSwich) {
|
|
33
|
+
return width / Math.cos(radAngle);
|
|
34
|
+
}
|
|
35
|
+
return height / Math.sin(radAngle);
|
|
36
|
+
}
|
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.16",
|
|
4
4
|
"description": "The community edition of the charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -27,8 +27,10 @@
|
|
|
27
27
|
"directory": "packages/x-charts"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@babel/runtime": "^7.23.
|
|
31
|
-
"@mui/base": "^5.0.0-beta.
|
|
30
|
+
"@babel/runtime": "^7.23.2",
|
|
31
|
+
"@mui/base": "^5.0.0-beta.20",
|
|
32
|
+
"@react-spring/rafz": "^9.7.3",
|
|
33
|
+
"@react-spring/web": "^9.7.3",
|
|
32
34
|
"clsx": "^2.0.0",
|
|
33
35
|
"d3-color": "^3.1.0",
|
|
34
36
|
"d3-scale": "^4.0.2",
|