Skip to content

Commit 2f4ecec

Browse files
committed
refactor : BarChart1 Constant 처리 개선
1 parent 53c6c33 commit 2f4ecec

File tree

2 files changed

+54
-57
lines changed

2 files changed

+54
-57
lines changed

src/chart/BarChartComparison.tsx

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,5 @@
1-
import { ChartOptions } from "chart.js";
21
import { Bar } from "react-chartjs-2";
3-
import { formatNumberWithCommas } from "../utils/numberUtils";
4-
5-
const data = {
6-
labels: ["202208", "202209", "202210", "202211", "202212"],
7-
datasets: [
8-
{
9-
label: "가용자본",
10-
data: [
11-
5000000000000, 8200000000000, 5400000000000, 9600000000000,
12-
5800000000000,
13-
],
14-
backgroundColor: "rgba(184, 239, 239, 0.5)",
15-
// borderColor: "rgba(75, 192, 192, 1)",
16-
borderWidth: 1,
17-
},
18-
{
19-
label: "요구자본",
20-
data: [
21-
4000000000000, 5500000000000, 4100000000000, 6700000000000,
22-
14600000000000,
23-
],
24-
backgroundColor: "rgba(183, 152, 197, 0.5)",
25-
// borderColor: "rgba(255, 99, 132, 1)",
26-
borderWidth: 1,
27-
},
28-
],
29-
};
30-
31-
const options: ChartOptions<"bar"> = {
32-
plugins: {
33-
legend: {
34-
position: "top",
35-
},
36-
title: {
37-
display: true,
38-
text: "RBC비율 추이",
39-
},
40-
},
41-
scales: {
42-
y: {
43-
beginAtZero: true,
44-
min: 0,
45-
max: 15000000000000,
46-
ticks: {
47-
stepSize: 5000000000000,
48-
callback: function (value) {
49-
const numValue = value as number;
50-
return formatNumberWithCommas(numValue / 100000000) + "억";
51-
},
52-
font: {
53-
size: 12,
54-
},
55-
},
56-
},
57-
},
58-
};
2+
import { data, options } from "../data/BarChartComparisonConstant";
593

604
const BarChartComparison = ({
615
chartRef,
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { ChartOptions } from "chart.js";
2+
import { formatNumberWithCommas } from "../utils/numberUtils";
3+
4+
export const data = {
5+
labels: ["2023 Q1", "2023 Q2", "2023 Q3", "2023 Q4", "2024 Q1"],
6+
datasets: [
7+
{
8+
label: "Available Capital",
9+
data: [5000000, 6000000, 7000000, 8000000, 9000000],
10+
backgroundColor: "rgba(184, 239, 239, 0.5)",
11+
// borderColor: "rgba(54, 162, 235, 1)",
12+
borderWidth: 1,
13+
},
14+
{
15+
label: "Required Capital",
16+
data: [4500000, 5500000, 6500000, 7500000, 8500000],
17+
backgroundColor: "rgba(183, 152, 197, 0.5)",
18+
// borderColor: "rgba(255, 99, 132, 1)",
19+
borderWidth: 1,
20+
},
21+
],
22+
};
23+
24+
export const options: ChartOptions<"bar"> = {
25+
responsive: true,
26+
plugins: {
27+
legend: {
28+
display: true,
29+
position: "top",
30+
},
31+
title: {
32+
display: true,
33+
text: "Capital Comparison Over Quarters",
34+
},
35+
},
36+
scales: {
37+
y: {
38+
beginAtZero: true,
39+
min: 0,
40+
max: 15000000,
41+
ticks: {
42+
stepSize: 5000000,
43+
callback: function (value) {
44+
const numValue = value as number;
45+
return `${formatNumberWithCommas(numValue / 1000000)}M`;
46+
},
47+
font: {
48+
size: 12,
49+
},
50+
},
51+
},
52+
},
53+
};

0 commit comments

Comments
 (0)