๋ฐ์ํ
Intro
์๋ ํ์ธ์. ์ด๋ฒ ์๊ฐ์๋ react-apexcharts ์ y์ถ ๋จ์๋ฅผ ์ค์ ํ๋ ๋ฐฉ๋ฒ์ ๋ํด ์์๋ณด๊ฒ ์ต๋๋ค.
How to solve the problem
๊ธฐ์กด chart options ์ฝ๋๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค. ์ ์ ๊ฒฝ์ฐ y์ถ์ด ํํ ๋จ์์๊ธฐ ๋๋ฌธ์ ๋ณด๊ธฐ ์ฝ๊ฒ ์๋ฆฟ์ ํ์๊ฐ ํ์ํ์ต๋๋ค.
const options: any = {
chart: {
height: 250,
type: 'bar',
stacked: false,
toolbar: false,
animations: {
enabled: true,
easing: 'easeinout',
speed: 500,
},
zoom: {
enabled: false,
},
},
...
yaxis: {
axisBorder: {
show: false,
},
axisTicks: {
show: false,
},
labels: {
show: true,
rotate: 0,
style: {
colors: '#666',
fontSize: '11rem',
fontFamily: 'SpoqaHanSans, Helvetica, Arial, sans-serif',
},
},
},
};
์ด๋ฅผ ์ํด formatter์ด๋ผ๋ ์์ฑ์ ํ์ฉํ์์ต๋๋ค. ๋ํ toLocaleString ๋ฅผ ํ์ฉํด commas๊ฐ ๋ถ๋๋ก ์ถ๊ฐํด์ฃผ์์ต๋๋ค. ์๋์ ์ฝ๋ ์ ์ฉ ์ y์ถ(yaxis)์ด ์๋ฆฟ์ ๋ณ๋ก ์ ํ์๊ฐ ๋์์ต๋๋ค.
const options: any = {
chart: {
height: 250,
type: 'bar',
stacked: false,
toolbar: false,
animations: {
enabled: true,
easing: 'easeinout',
speed: 500,
},
zoom: {
enabled: false,
},
},
...
yaxis: {
axisBorder: {
show: false,
},
axisTicks: {
show: false,
},
labels: {
show: true,
rotate: 0,
style: {
colors: '#666',
fontSize: '11rem',
fontFamily: 'SpoqaHanSans, Helvetica, Arial, sans-serif',
},
formatter: (value: number) => {
return value.toLocaleString();
},
},
},
};
๋ฐ์ํ