Skip to content

Commit 2fadbf8

Browse files
Fix useIsHydrated. Add visual regression test.
1 parent 9898b1c commit 2fadbf8

File tree

4 files changed

+32
-320
lines changed

4 files changed

+32
-320
lines changed

docs/data/charts/axis/XAxisTickLabelOverflow.js

-263
This file was deleted.

docs/data/charts/axis/axis.md

-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ To avoid this, you can use the `margin` property to increase the space between t
234234

235235
{{"demo": "MarginAndLabelPosition.js"}}
236236

237-
{{"demo": "XAxisTickLabelOverflow.js"}}
238-
239237
### Rendering
240238

241239
Axes rendering can be further customized. Below is an interactive demonstration of the axis props.

docs/data/charts/axis/XAxisTickLabelOverflow.tsx docs/data/visual-regression-tests/YAxisTickLabelOverflow.tsx

+28-51
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,44 @@
11
import * as React from 'react';
22
import { BarChartPro } from '@mui/x-charts-pro/BarChartPro';
3+
import { BarChartProps } from '@mui/x-charts/BarChart';
34

4-
const defaultXAxis = {
5-
id: 'angle0',
5+
const defaultYAxis = {
66
scaleType: 'band',
77
dataKey: 'code',
8-
position: 'bottom',
9-
zoom: true,
10-
height: 80,
8+
width: 100,
119
valueFormatter: (value: any) =>
1210
usAirportPassengers.find((item) => item.code === value)!.fullName,
1311
label: '0deg Axis Title',
1412
} as const;
1513

14+
const degrees = [-180, -135, -90, -45, 0, 45, 90, 135, 180];
15+
16+
type AxisPosition = NonNullable<BarChartProps['yAxis']>[number]['position'];
17+
18+
const yAxes = degrees
19+
.map((angle) => ({
20+
...defaultYAxis,
21+
position: 'left' as AxisPosition,
22+
id: `angle${angle}`,
23+
label: `${angle}deg Axis Title`,
24+
tickLabelStyle: { angle },
25+
}))
26+
.concat(
27+
degrees.map((angle) => ({
28+
...defaultYAxis,
29+
id: `right-angle${angle}`,
30+
label: `${angle}deg Axis Title`,
31+
position: 'right',
32+
tickLabelStyle: { angle },
33+
})),
34+
) satisfies BarChartProps['yAxis'];
35+
1636
export default function XAxisTickLabelOverflow() {
1737
return (
1838
<BarChartPro
19-
xAxis={[
20-
{
21-
...defaultXAxis,
22-
id: 'angle-90',
23-
label: '-90deg Axis Title',
24-
tickLabelStyle: {
25-
angle: -90,
26-
textAnchor: 'end',
27-
dominantBaseline: 'central',
28-
},
29-
},
30-
31-
{
32-
...defaultXAxis,
33-
id: 'angle-45',
34-
label: '-45deg Axis Title',
35-
tickLabelStyle: {
36-
angle: -45,
37-
textAnchor: 'end',
38-
dominantBaseline: 'central',
39-
},
40-
},
41-
defaultXAxis,
42-
{
43-
...defaultXAxis,
44-
id: 'angle45',
45-
label: '45deg Axis Title',
46-
tickLabelStyle: {
47-
angle: 45,
48-
textAnchor: 'start',
49-
},
50-
},
51-
{
52-
...defaultXAxis,
53-
id: 'angle90',
54-
label: '90deg Axis Title',
55-
tickLabelStyle: {
56-
angle: 90,
57-
textAnchor: 'start',
58-
dominantBaseline: 'central',
59-
},
60-
},
61-
]}
39+
yAxis={yAxes}
6240
// Other props
63-
height={600}
41+
width={1600}
6442
dataset={usAirportPassengers}
6543
series={[
6644
{ dataKey: '2018', label: '2018' },
@@ -70,10 +48,9 @@ export default function XAxisTickLabelOverflow() {
7048
{ dataKey: '2022', label: '2022' },
7149
]}
7250
hideLegend
73-
yAxis={[
51+
xAxis={[
7452
{
7553
valueFormatter: (value) => `${(value / 1000).toLocaleString()}k`,
76-
width: 40,
7754
},
7855
]}
7956
/>

0 commit comments

Comments
 (0)