@uniai-fe/chart-legacy 0.1.1
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/LICENSE +27 -0
- package/README.md +3 -0
- package/package.json +74 -0
- package/src/chart.scss +13 -0
- package/src/components/Contents.tsx +17 -0
- package/src/components/control/Button.tsx +39 -0
- package/src/components/control/Container.tsx +27 -0
- package/src/components/control/Provider.tsx +117 -0
- package/src/components/control/index.tsx +12 -0
- package/src/components/custom/ActivePieSector.tsx +29 -0
- package/src/components/graphs/ArcGauge.tsx +58 -0
- package/src/components/graphs/ArcMeter.tsx +112 -0
- package/src/components/graphs/Area.tsx +132 -0
- package/src/components/graphs/Bar.tsx +179 -0
- package/src/components/graphs/Doughnut.tsx +90 -0
- package/src/components/graphs/Line.tsx +123 -0
- package/src/components/graphs/index.tsx +17 -0
- package/src/components/ticks/XAxis.tsx +39 -0
- package/src/components/ticks/index.tsx +7 -0
- package/src/components.tsx +17 -0
- package/src/icon/Control.tsx +40 -0
- package/src/icon/index.tsx +7 -0
- package/src/index.tsx +3 -0
- package/src/styled.tsx +7 -0
- package/src/styles/scss/arc-gauge.scss +11 -0
- package/src/styles/scss/arc-meter.scss +6 -0
- package/src/styles/scss/control.scss +34 -0
- package/src/styles/scss/filter.scss +0 -0
- package/src/styles/scss/graph.scss +3 -0
- package/src/styles/scss/icon.scss +3 -0
- package/src/styles/scss/legend.scss +35 -0
- package/src/styles/scss/level.color.scss +7 -0
- package/src/styles/scss/tick.scss +48 -0
- package/src/styles/scss/tooltip.scss +70 -0
- package/src/styles/styled/arc-gauge.ts +65 -0
- package/src/styles/styled/arc-meter.ts +42 -0
- package/src/styles/styled/common.ts +14 -0
- package/src/styles/styled/control.ts +31 -0
- package/src/styles/styled/icon.ts +17 -0
- package/src/styles/styled/legend.ts +11 -0
- package/src/svg/control/pan-left.svg +4 -0
- package/src/svg/control/pan-right.svg +4 -0
- package/src/svg/control/zoom-in.svg +4 -0
- package/src/svg/control/zoom-out.svg +4 -0
- package/src/svg/gauge-track.min.svg +1 -0
- package/src/types/axis.d.ts +15 -0
- package/src/types/control.d.ts +109 -0
- package/src/types/data.d.ts +41 -0
- package/src/types/dot.d.ts +3 -0
- package/src/types/index.d.ts +7 -0
- package/src/types/legend.d.ts +124 -0
- package/src/types/props.d.ts +271 -0
- package/src/types/tick.d.ts +30 -0
- package/src/utils/getLevel.ts +23 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import type { TooltipProps, XAxisProps, YAxisProps } from "recharts";
|
|
2
|
+
import type { CategoricalChartProps } from "recharts/types/chart/generateCategoricalChart";
|
|
3
|
+
import type {
|
|
4
|
+
NameType,
|
|
5
|
+
ValueType,
|
|
6
|
+
} from "recharts/types/component/DefaultTooltipContent";
|
|
7
|
+
import type { Props as ResponsiveContainerProps } from "recharts/types/component/ResponsiveContainer";
|
|
8
|
+
|
|
9
|
+
import type { ChartYAxisDataType } from "./axis";
|
|
10
|
+
import type { ChartCoreDataAxisType, ChartCoreDataSingleType } from "./data";
|
|
11
|
+
import type { AreaGradientProps, ChartLegendBaseType } from "./legend";
|
|
12
|
+
import type { Props as PieProps } from "recharts/types/polar/Pie";
|
|
13
|
+
import type { Props as LineProps } from "recharts/types/cartesian/Line";
|
|
14
|
+
import type { Props as BarProps } from "recharts/types/cartesian/Bar";
|
|
15
|
+
import type { Props as CellProps } from "recharts/types/component/Cell";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 차트 Props; 1차원 차트 데이터
|
|
19
|
+
* @property {ChartCoreDataSingleType[]} chartData - 차트 렌더링 데이터
|
|
20
|
+
*/
|
|
21
|
+
export type ChartDataSingleProps = {
|
|
22
|
+
/**
|
|
23
|
+
* 차트 렌더링 데이터
|
|
24
|
+
* @property {string | number | null} 임의 데이터
|
|
25
|
+
* @property {string} name - 데이터 명칭
|
|
26
|
+
* @property {string} value - 데이터 값
|
|
27
|
+
* @property {string} unit - 데이터 단위
|
|
28
|
+
* @property {string} fill - 데이터 색상
|
|
29
|
+
*/
|
|
30
|
+
chartData: ChartCoreDataSingleType[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 차트 Props; 2차원 차트 데이터
|
|
35
|
+
* @property {ChartCoreDataAxisType[]} chartData - 차트 렌더링 데이터
|
|
36
|
+
*/
|
|
37
|
+
export type ChartDataAxisProps = {
|
|
38
|
+
/**
|
|
39
|
+
* 차트 렌더링 데이터
|
|
40
|
+
* @property {string | number | null} 데이터
|
|
41
|
+
*/
|
|
42
|
+
chartData: ChartCoreDataAxisType[];
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 차트 Props; 레전드 데이터
|
|
47
|
+
* - 레전드 항목수 대로 <Line />, <Bar /> 등을 렌더링
|
|
48
|
+
* @property {ChartLegendBaseType[]} legendData - 차트 레전드 데이터
|
|
49
|
+
*/
|
|
50
|
+
export type ChartDataLegendDefaultProps = {
|
|
51
|
+
/**
|
|
52
|
+
* 차트 레전드 데이터
|
|
53
|
+
* @property {string} key - 렌더링 키
|
|
54
|
+
* @property {string} axisCategory - y축 id
|
|
55
|
+
* @property {string} code - 데이터 키
|
|
56
|
+
* @property {string} name - 데이터 명칭
|
|
57
|
+
* @property {string} unit - 데이터 단위
|
|
58
|
+
* @property {string} color - 데이터 컬러
|
|
59
|
+
* @property {boolean} active - 데이터 활성화 여부 (레전드 토글 등)
|
|
60
|
+
* @property {boolean} [highlight] - 포커스 구분
|
|
61
|
+
*/
|
|
62
|
+
legendData: ChartLegendBaseType[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 차트 Props; Y축 렌더링 데이터
|
|
67
|
+
* @property {ChartYAxisDataType[]} yAxisData - y축 카테고리별 생성 데이터
|
|
68
|
+
*/
|
|
69
|
+
export type ChartDataYAxisProps = {
|
|
70
|
+
/**
|
|
71
|
+
* y축 카테고리별 생성 데이터
|
|
72
|
+
* @property {string} key - 렌더링 키
|
|
73
|
+
* @property {string} axisCategory - y축 id
|
|
74
|
+
*/
|
|
75
|
+
yAxisData: ChartYAxisDataType[];
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 차트 Props; recharts 렌더링 공통 옵션
|
|
80
|
+
* @property {CategoricalChartProps} chartLayoutOptions - 형태별 차트 렌더링 옵션
|
|
81
|
+
* @property {TooltipProps<ValueType, NameType>} tooltipOptions - 툴팁 렌더링 옵션
|
|
82
|
+
* @property {ResponsiveContainerProps} containerOptions - <ResponsiveContainer /> 렌더링 옵션
|
|
83
|
+
* @property {React.ReactNode} children - 추가 차트요소
|
|
84
|
+
*/
|
|
85
|
+
export type ChartOptionCommonProps = Partial<{
|
|
86
|
+
/**
|
|
87
|
+
* 차트 렌더링 옵션
|
|
88
|
+
* <LineChart />, <BarChart /> 등 차트 속성에 적용
|
|
89
|
+
* @type {CategoricalChartProps}
|
|
90
|
+
*/
|
|
91
|
+
chartLayoutOptions: CategoricalChartProps;
|
|
92
|
+
/**
|
|
93
|
+
* 툴팁 렌더링 옵션
|
|
94
|
+
* @type {TooltipProps<ValueType, NameType>}
|
|
95
|
+
*/
|
|
96
|
+
tooltipOptions: TooltipProps<ValueType, NameType>;
|
|
97
|
+
/**
|
|
98
|
+
* <ResponsiveContainer /> 렌더링 옵션
|
|
99
|
+
* @type {ResponsiveContainerProps}
|
|
100
|
+
*/
|
|
101
|
+
containerOptions: Omit<ResponsiveContainerProps, "children">;
|
|
102
|
+
/**
|
|
103
|
+
* DOM ClassName
|
|
104
|
+
*/
|
|
105
|
+
className: string;
|
|
106
|
+
/**
|
|
107
|
+
* 추가 차트요소
|
|
108
|
+
* @type {React.ReactNode}
|
|
109
|
+
*/
|
|
110
|
+
children: React.ReactNode;
|
|
111
|
+
}>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* 차트 Props; recharts axis 렌더링 옵션
|
|
115
|
+
* @property {XAxisProps} [xAxisOptions] - x축 렌더링 옵션
|
|
116
|
+
* @property {YAxisProps} [yAxisOptions] - y축 렌더링 옵션
|
|
117
|
+
* @property {boolean} [isHideGrid] - 그리드 숨김 옵션
|
|
118
|
+
*/
|
|
119
|
+
export type ChartOptionAxisProps = Partial<{
|
|
120
|
+
/**
|
|
121
|
+
* x축 렌더링 옵션
|
|
122
|
+
* @type {XAxisProps}
|
|
123
|
+
*/
|
|
124
|
+
xAxisOptions: XAxisProps;
|
|
125
|
+
/**
|
|
126
|
+
* y축 렌더링 옵션
|
|
127
|
+
* @type {YAxisProps}
|
|
128
|
+
*/
|
|
129
|
+
yAxisOptions: YAxisProps;
|
|
130
|
+
/**
|
|
131
|
+
* 그리드 렌더링 여부
|
|
132
|
+
* - 기본값 undefined
|
|
133
|
+
*/
|
|
134
|
+
isHideGrid: boolean;
|
|
135
|
+
}>;
|
|
136
|
+
|
|
137
|
+
export type ChartAreaDataLegendProps = ChartLegendBaseType &
|
|
138
|
+
Partial<{
|
|
139
|
+
/**
|
|
140
|
+
* <Area /> 차트 컬러 - 단식
|
|
141
|
+
*/
|
|
142
|
+
areaColor: string;
|
|
143
|
+
/**
|
|
144
|
+
* <Area /> 차트 컬러 - 그라디언트
|
|
145
|
+
*/
|
|
146
|
+
areaGradient: AreaGradientProps;
|
|
147
|
+
}>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 차트 Props; 레전드 데이터; <Area /> 레전드
|
|
151
|
+
* @property {ChartAreaDataLegendProps[]} legendData - 차트 레전드 데이터
|
|
152
|
+
*/
|
|
153
|
+
export type ChartDataLegendAreaProps = {
|
|
154
|
+
/**
|
|
155
|
+
* 차트 레전드 데이터
|
|
156
|
+
* @property {string} key - 렌더링 키
|
|
157
|
+
* @property {string} axisCategory - y축 id
|
|
158
|
+
* @property {string} code - 데이터 키
|
|
159
|
+
* @property {string} name - 데이터 명칭
|
|
160
|
+
* @property {string} unit - 데이터 단위
|
|
161
|
+
* @property {string} color - 데이터 컬러
|
|
162
|
+
* @property {boolean} active - 데이터 활성화 여부 (레전드 토글 등)
|
|
163
|
+
* @property {boolean} [highlight] - 포커스 구분
|
|
164
|
+
* @property {string} [areaColor] - <Area /> 차트 컬러 - 단색
|
|
165
|
+
* @property {AreaGradientProps} [areaGradient] - <Area /> 차트 컬러 - 그라디언트
|
|
166
|
+
*/
|
|
167
|
+
legendData: ChartAreaDataLegendProps[];
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* 차트 Props; 영역 차트
|
|
172
|
+
*/
|
|
173
|
+
export type ChartAreaProps = ChartDataAxisProps &
|
|
174
|
+
ChartDataLegendAreaProps &
|
|
175
|
+
ChartDataYAxisProps &
|
|
176
|
+
ChartOptionCommonProps &
|
|
177
|
+
ChartOptionAxisProps;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Recharts Props; Line
|
|
181
|
+
*/
|
|
182
|
+
export type RechartLineProps = LineProps;
|
|
183
|
+
/**
|
|
184
|
+
* 차트 Props; <Line /> 옵션
|
|
185
|
+
*/
|
|
186
|
+
export type ChartLineOptions = Partial<{ lineOptions: RechartLineProps }>;
|
|
187
|
+
/**
|
|
188
|
+
* 차트 Props; 라인 차트
|
|
189
|
+
*/
|
|
190
|
+
export type ChartLineProps = ChartDataAxisProps &
|
|
191
|
+
ChartDataLegendAreaProps &
|
|
192
|
+
ChartDataYAxisProps &
|
|
193
|
+
ChartOptionCommonProps &
|
|
194
|
+
ChartOptionAxisProps &
|
|
195
|
+
ChartLineOptions;
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Recharts Props; Bar
|
|
199
|
+
*/
|
|
200
|
+
export type RechartsBarProps = Partial<BarProps>;
|
|
201
|
+
/**
|
|
202
|
+
* Recharts Props; Cell
|
|
203
|
+
*/
|
|
204
|
+
export type RechartsCellProps = Partial<CellProps>;
|
|
205
|
+
/**
|
|
206
|
+
* 차트 Props; <Bar /> 옵션
|
|
207
|
+
*/
|
|
208
|
+
export type ChartBarOptions = Partial<{
|
|
209
|
+
barOptions: RechartsBarProps;
|
|
210
|
+
cellOptions: RechartsCellProps;
|
|
211
|
+
}>;
|
|
212
|
+
/**
|
|
213
|
+
* 차트 Props; 막대 차트
|
|
214
|
+
*/
|
|
215
|
+
export type ChartBarProps = ChartDataAxisProps &
|
|
216
|
+
ChartDataLegendAreaProps &
|
|
217
|
+
ChartDataYAxisProps &
|
|
218
|
+
ChartOptionCommonProps &
|
|
219
|
+
ChartOptionAxisProps &
|
|
220
|
+
Partial<{
|
|
221
|
+
/**
|
|
222
|
+
* 막대 너비
|
|
223
|
+
*/
|
|
224
|
+
barSize: number;
|
|
225
|
+
/**
|
|
226
|
+
* 서로 다른 x축 분포를 나타내는 경우
|
|
227
|
+
*/
|
|
228
|
+
isUseCell: boolean;
|
|
229
|
+
}> &
|
|
230
|
+
ChartBarOptions;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* 차트 Props; 도넛차트 렌더링 옵션
|
|
234
|
+
*/
|
|
235
|
+
export type ChartOptionDoughnutProps = Partial<{
|
|
236
|
+
/**
|
|
237
|
+
* 도넛차트 width
|
|
238
|
+
*/
|
|
239
|
+
width: number;
|
|
240
|
+
/**
|
|
241
|
+
* 도넛차트 height
|
|
242
|
+
*/
|
|
243
|
+
height: number;
|
|
244
|
+
/**
|
|
245
|
+
* 도넛차트 두께
|
|
246
|
+
*/
|
|
247
|
+
thickness: number;
|
|
248
|
+
/**
|
|
249
|
+
* 도넛차트 시작 각도
|
|
250
|
+
*/
|
|
251
|
+
startAngle: number;
|
|
252
|
+
/**
|
|
253
|
+
* 도넛차트 종료 각도
|
|
254
|
+
*/
|
|
255
|
+
endAngle: number;
|
|
256
|
+
}>;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* 차트 Props; <Pie /> 렌더링 옵션
|
|
260
|
+
*/
|
|
261
|
+
export type ChartOptionPieProps = Partial<{
|
|
262
|
+
pieOptions: PieProps;
|
|
263
|
+
}>;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 차트 Props; 도넛 차트
|
|
267
|
+
*/
|
|
268
|
+
export type ChartDoughnutProps = ChartDataSingleProps &
|
|
269
|
+
ChartOptionCommonProps &
|
|
270
|
+
ChartOptionDoughnutProps &
|
|
271
|
+
ChartOptionPieProps;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { XAxisProps } from "recharts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* recharts XAxis Tick 커스텀 Props
|
|
5
|
+
*/
|
|
6
|
+
export type RechartsXAxisTickProps = XAxisProps & {
|
|
7
|
+
// <text> 기본 속성
|
|
8
|
+
verticalAnchor: "start" | "middle" | "end";
|
|
9
|
+
// 추가 기본 정보; width, height, index, visibleTicksCount,
|
|
10
|
+
index: number;
|
|
11
|
+
// payload - 각 x의 y 데이터; coordinate, value, index, offset, tickCoord, isShow
|
|
12
|
+
payload: {
|
|
13
|
+
coordinate: number;
|
|
14
|
+
value: number | string | null;
|
|
15
|
+
index: number;
|
|
16
|
+
offset: number;
|
|
17
|
+
tickCoord: number;
|
|
18
|
+
isShow: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type ChartTickXAxisProps = {
|
|
23
|
+
xAxisProps: RechartsXAxisTickProps;
|
|
24
|
+
} & Partial<{
|
|
25
|
+
className: string;
|
|
26
|
+
children: React.ReactNode;
|
|
27
|
+
tSpanPos: React.SVGProps<SVGTSpanElement>;
|
|
28
|
+
customValue: React.ReactNode;
|
|
29
|
+
groupProps: React.SVGProps<SVGGElement>;
|
|
30
|
+
}>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 스코어 레벨 추출 (4단계)
|
|
3
|
+
* @param {number | ""} value
|
|
4
|
+
* @param {number} [max] 최대값 (기본값 100)
|
|
5
|
+
*/
|
|
6
|
+
export default function getChartLevel(
|
|
7
|
+
value: number | "",
|
|
8
|
+
max: number = 100,
|
|
9
|
+
): number {
|
|
10
|
+
if (value === "") return 0;
|
|
11
|
+
|
|
12
|
+
const stepAmount = max / 4;
|
|
13
|
+
const danger = stepAmount;
|
|
14
|
+
const warning = stepAmount * 2;
|
|
15
|
+
const caution = stepAmount * 3;
|
|
16
|
+
|
|
17
|
+
if (value < danger) return 1;
|
|
18
|
+
else if (danger <= value && value < caution) return 2;
|
|
19
|
+
else if (caution <= value && value < warning) return 3;
|
|
20
|
+
else if (value >= warning) return 4;
|
|
21
|
+
|
|
22
|
+
return 0;
|
|
23
|
+
}
|