Skip to content

Commit 0747a89

Browse files
Fix lint and types
1 parent 2fadbf8 commit 0747a89

File tree

2 files changed

+239
-1
lines changed

2 files changed

+239
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
import * as React from 'react';
2+
import { BarChartPro } from '@mui/x-charts-pro/BarChartPro';
3+
4+
const defaultYAxis = {
5+
scaleType: 'band',
6+
dataKey: 'code',
7+
width: 100,
8+
valueFormatter: (value) =>
9+
usAirportPassengers.find((item) => item.code === value).fullName,
10+
label: '0deg Axis Title',
11+
};
12+
13+
const degrees = [-180, -135, -90, -45, 0, 45, 90, 135, 180];
14+
15+
const yAxes = degrees
16+
.map((angle) => ({
17+
...defaultYAxis,
18+
position: 'left',
19+
id: `angle${angle}`,
20+
label: `${angle}deg Axis Title`,
21+
tickLabelStyle: { angle },
22+
}))
23+
.concat(
24+
degrees.map((angle) => ({
25+
...defaultYAxis,
26+
id: `right-angle${angle}`,
27+
label: `${angle}deg Axis Title`,
28+
position: 'right',
29+
tickLabelStyle: { angle },
30+
})),
31+
);
32+
33+
export default function YAxisTickLabelOverflow() {
34+
return (
35+
<BarChartPro
36+
yAxis={yAxes}
37+
// Other props
38+
width={1600}
39+
dataset={usAirportPassengers}
40+
series={[
41+
{ dataKey: '2018', label: '2018' },
42+
{ dataKey: '2019', label: '2019' },
43+
{ dataKey: '2020', label: '2020' },
44+
{ dataKey: '2021', label: '2021' },
45+
{ dataKey: '2022', label: '2022' },
46+
]}
47+
hideLegend
48+
xAxis={[
49+
{
50+
valueFormatter: (value) => `${(value / 1000).toLocaleString()}k`,
51+
},
52+
]}
53+
/>
54+
);
55+
}
56+
57+
const usAirportPassengers = [
58+
{
59+
fullName: 'Hartsfield–Jackson Atlanta International Airport',
60+
code: 'ATL',
61+
2022: 45396001,
62+
2021: 36676010,
63+
2020: 20559866,
64+
2019: 53505795,
65+
2018: 51865797,
66+
},
67+
{
68+
fullName: 'Dallas/Fort Worth International Airport',
69+
code: 'DFW',
70+
2022: 35345138,
71+
2021: 30005266,
72+
2020: 18593421,
73+
2019: 35778573,
74+
2018: 32821799,
75+
},
76+
{
77+
fullName: 'Denver International Airport',
78+
code: 'DEN',
79+
2022: 33773832,
80+
2021: 28645527,
81+
2020: 16243216,
82+
2019: 33592945,
83+
2018: 31362941,
84+
},
85+
{
86+
fullName: "O'Hare International Airport",
87+
code: 'ORD',
88+
2022: 33120474,
89+
2021: 26350976,
90+
2020: 14606034,
91+
2019: 40871223,
92+
2018: 39873927,
93+
},
94+
{
95+
fullName: 'Los Angeles International Airport',
96+
code: 'LAX',
97+
2022: 32326616,
98+
2021: 23663410,
99+
2020: 14055777,
100+
2019: 42939104,
101+
2018: 42624050,
102+
},
103+
{
104+
fullName: 'John F. Kennedy International Airport',
105+
code: 'JFK',
106+
2022: 26919982,
107+
2021: 15273342,
108+
2020: 8269819,
109+
2019: 31036655,
110+
2018: 30620769,
111+
},
112+
{
113+
fullName: 'Harry Reid International Airport',
114+
code: 'LAS',
115+
2022: 25480500,
116+
2021: 19160342,
117+
2020: 10584059,
118+
2019: 24728361,
119+
2018: 23795012,
120+
},
121+
{
122+
fullName: 'Orlando International Airport',
123+
code: 'MCO',
124+
2022: 24469733,
125+
2021: 19618838,
126+
2020: 10467728,
127+
2019: 24562271,
128+
2018: 23202480,
129+
},
130+
{
131+
fullName: 'Miami International Airport',
132+
code: 'MIA',
133+
2022: 23949892,
134+
2021: 17500096,
135+
2020: 8786007,
136+
2019: 21421031,
137+
2018: 21021640,
138+
},
139+
{
140+
fullName: 'Charlotte Douglas International Airport',
141+
code: 'CLT',
142+
2022: 23100300,
143+
2021: 20900875,
144+
2020: 12952869,
145+
2019: 24199688,
146+
2018: 22281949,
147+
},
148+
{
149+
fullName: 'Seattle–Tacoma International Airport',
150+
code: 'SEA',
151+
2022: 22157862,
152+
2021: 17430195,
153+
2020: 9462411,
154+
2019: 25001762,
155+
2018: 24024908,
156+
},
157+
{
158+
fullName: 'Phoenix Sky Harbor International Airport',
159+
code: 'PHX',
160+
2022: 21852586,
161+
2021: 18940287,
162+
2020: 10531436,
163+
2019: 22433552,
164+
2018: 21622580,
165+
},
166+
{
167+
fullName: 'Newark Liberty International Airport',
168+
code: 'EWR',
169+
2022: 21572147,
170+
2021: 14514049,
171+
2020: 7985474,
172+
2019: 23160763,
173+
2018: 22797602,
174+
},
175+
{
176+
fullName: 'San Francisco International Airport',
177+
code: 'SFO',
178+
2022: 20411420,
179+
2021: 11725347,
180+
2020: 7745057,
181+
2019: 27779230,
182+
2018: 27790717,
183+
},
184+
{
185+
fullName: 'George Bush Intercontinental Airport',
186+
code: 'IAH',
187+
2022: 19814052,
188+
2021: 16242821,
189+
2020: 8682558,
190+
2019: 21905309,
191+
2018: 21157398,
192+
},
193+
{
194+
fullName: 'Logan International Airport',
195+
code: 'BOS',
196+
2022: 17443775,
197+
2021: 10909817,
198+
2020: 6035452,
199+
2019: 20699377,
200+
2018: 20006521,
201+
},
202+
{
203+
fullName: 'Fort Lauderdale–Hollywood International Airport',
204+
code: 'FLL',
205+
2022: 15370165,
206+
2021: 13598994,
207+
2020: 8015744,
208+
2019: 17950989,
209+
2018: 17612331,
210+
},
211+
{
212+
fullName: 'Minneapolis–Saint Paul International Airport',
213+
code: 'MSP',
214+
2022: 15242089,
215+
2021: 12211409,
216+
2020: 7069720,
217+
2019: 19192917,
218+
2018: 18361942,
219+
},
220+
{
221+
fullName: 'LaGuardia Airport',
222+
code: 'LGA',
223+
2022: 14367463,
224+
2021: 7827307,
225+
2020: 4147116,
226+
2019: 15393601,
227+
2018: 15058501,
228+
},
229+
{
230+
fullName: 'Detroit Metropolitan Airport',
231+
code: 'DTW',
232+
2022: 13751197,
233+
2021: 11517696,
234+
2020: 6822324,
235+
2019: 18143040,
236+
2018: 17436837,
237+
},
238+
];

docs/data/visual-regression-tests/YAxisTickLabelOverflow.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const yAxes = degrees
3333
})),
3434
) satisfies BarChartProps['yAxis'];
3535

36-
export default function XAxisTickLabelOverflow() {
36+
export default function YAxisTickLabelOverflow() {
3737
return (
3838
<BarChartPro
3939
yAxis={yAxes}

0 commit comments

Comments
 (0)