@weing-dev/ui-kit-primitive 0.5.0 → 0.5.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/README.md +86 -49
- package/dist/chart.d.ts +2 -1
- package/dist/chart.js +614 -442
- package/dist/components/Chart/Chart.gradient.d.ts +10 -0
- package/dist/components/Chart/Chart.options.d.ts +7 -2
- package/dist/components/Chart/Chart.type.d.ts +51 -4
- package/dist/components/Chart/charts/RadarChart.d.ts +3 -0
- package/dist/entry/chart.d.ts +2 -1
- package/docs/ui-kit-agent-guide.md +574 -0
- package/package.json +3 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Color, Scriptable, ScriptableContext } from 'chart.js';
|
|
2
|
+
/**
|
|
3
|
+
* canvas gradient 는 chartArea(레이아웃 결과)가 있어야 만들 수 있어 정적 색으로 못 박는다.
|
|
4
|
+
* chart.js 의 scriptable backgroundColor(렌더 시 ctx 주입)로 lazy 생성한다 —
|
|
5
|
+
* 순수함수 빌더 안에서도 함수만 반환하면 되고 plugin/useEffect 가 불필요하다.
|
|
6
|
+
*
|
|
7
|
+
* 색 토큰을 canvas 가 직접 못 읽는 것과 같은 제약을 같은 패턴(런타임 해석)으로 푼다.
|
|
8
|
+
*/
|
|
9
|
+
/** 세로 방향 그라데이션(상단 from → 하단 to). chartArea 미정(레이아웃 전)이면 from 단색으로 폴백. */
|
|
10
|
+
export declare const verticalGradient: (from: string, to: string) => Scriptable<Color, ScriptableContext<"line">>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChartData, ChartOptions } from 'chart.js';
|
|
2
|
-
import { CategoricalData, ChartBaseProps, ChartKind, PointStyle, ProportionData } from './Chart.type';
|
|
2
|
+
import { AxisConfig, CategoricalData, ChartBaseProps, ChartKind, PointStyle, ProportionData } from './Chart.type';
|
|
3
3
|
import { ChartAxisTokens } from './Chart.palette';
|
|
4
4
|
import { StyleSources } from './Chart.style';
|
|
5
5
|
export declare const deepMerge: <T>(base: T, over?: Partial<T>) => T;
|
|
@@ -18,7 +18,12 @@ type BuildOptionArgs = {
|
|
|
18
18
|
tokens: ChartAxisTokens;
|
|
19
19
|
/** 종류별 추가 옵션 (indexAxis, cutout, scales stacked 등). 차트별 전용 키 허용 위해 느슨한 타입 */
|
|
20
20
|
extra?: Record<string, unknown>;
|
|
21
|
+
/** 직교좌표 y축 설정 (max/min/단위 포맷). y1 정의 시 우측 보조축(듀얼축) 생성 */
|
|
22
|
+
axes?: {
|
|
23
|
+
y?: AxisConfig;
|
|
24
|
+
y1?: AxisConfig;
|
|
25
|
+
};
|
|
21
26
|
};
|
|
22
27
|
/** 프리셋 → L2(options deep-merge) → L3(rawOptions 통째 대체) */
|
|
23
|
-
export declare const buildOptions: ({ kind, base, tokens, extra }: BuildOptionArgs) => ChartOptions;
|
|
28
|
+
export declare const buildOptions: ({ kind, base, tokens, extra, axes }: BuildOptionArgs) => ChartOptions;
|
|
24
29
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChartOptions } from 'chart.js';
|
|
1
|
+
import { ChartOptions, Plugin } from 'chart.js';
|
|
2
2
|
import { default as React } from 'react';
|
|
3
3
|
/** 단일 시리즈 간편 입력: bar/pie/doughnut 한 줄짜리 */
|
|
4
4
|
export type SimpleDatum = {
|
|
@@ -10,9 +10,24 @@ export type SimpleDatum = {
|
|
|
10
10
|
/** 다중 시리즈 한 줄 */
|
|
11
11
|
export type ChartSeries = {
|
|
12
12
|
name: string;
|
|
13
|
-
|
|
13
|
+
/** null = 데이터 없는 구간(선 끊김). spanGaps 로 이을지 제어 */
|
|
14
|
+
values: (number | null)[];
|
|
14
15
|
/** 이 시리즈만 색 강제 — cascade [2] */
|
|
15
16
|
color?: string;
|
|
17
|
+
/** 이 시리즈가 참조할 y축 id. 보조축 연결 시 "y1" (듀얼축) */
|
|
18
|
+
yAxisID?: string;
|
|
19
|
+
/** 점선 패턴 (예: [4,4]). line 전용 */
|
|
20
|
+
borderDash?: number[];
|
|
21
|
+
/** null 값 구간을 선으로 이을지 여부 (기본 chart.js 기본값=false 동작) */
|
|
22
|
+
spanGaps?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* 면적 gradient 채우기 (line 전용). true=시리즈 색 기반 자동 alpha,
|
|
25
|
+
* {from,to}=명시 색. 켜면 fill 자동 활성.
|
|
26
|
+
*/
|
|
27
|
+
gradient?: boolean | {
|
|
28
|
+
from?: string;
|
|
29
|
+
to?: string;
|
|
30
|
+
};
|
|
16
31
|
};
|
|
17
32
|
/** 다중 시리즈 입력 */
|
|
18
33
|
export type SeriesData = {
|
|
@@ -44,9 +59,18 @@ export type ChartThemeValue = {
|
|
|
44
59
|
defaults?: ChartStyleDefaults;
|
|
45
60
|
presets?: ChartPreset;
|
|
46
61
|
};
|
|
47
|
-
export type ChartKind = "bar" | "line" | "pie" | "doughnut";
|
|
62
|
+
export type ChartKind = "bar" | "line" | "pie" | "doughnut" | "radar";
|
|
48
63
|
export type LegendOption = boolean | "top" | "bottom" | "left" | "right";
|
|
49
64
|
export type PointStyle = "circle" | "rect" | "triangle" | false;
|
|
65
|
+
/** 직교좌표(bar/line) 축 설정. 듀얼축·단위 포맷 노출 */
|
|
66
|
+
export type AxisConfig = {
|
|
67
|
+
max?: number;
|
|
68
|
+
min?: number;
|
|
69
|
+
/** 눈금 단위 포맷터 (예: (v) => `${v}건`) → ticks.callback */
|
|
70
|
+
tickFormat?: (value: number) => string;
|
|
71
|
+
/** 축 제목 */
|
|
72
|
+
title?: string;
|
|
73
|
+
};
|
|
50
74
|
export type ChartBaseProps = {
|
|
51
75
|
title?: string;
|
|
52
76
|
/** true=top, false=숨김, 또는 위치 지정 */
|
|
@@ -73,6 +97,11 @@ export type ChartBaseProps = {
|
|
|
73
97
|
options?: ChartOptions;
|
|
74
98
|
/** L3: 프리셋 무시하고 raw 통째 대체 */
|
|
75
99
|
rawOptions?: ChartOptions;
|
|
100
|
+
/**
|
|
101
|
+
* 커스텀 chart.js 플러그인 (인스턴스 한정 주입). afterDraw/beforeDatasetsDraw 등으로
|
|
102
|
+
* 캔버스에 직접 드로잉. 플러그인 옵션은 L2 `options.plugins.<id>` 로 전달.
|
|
103
|
+
*/
|
|
104
|
+
plugins?: Plugin[];
|
|
76
105
|
};
|
|
77
106
|
export type BarChartProps = ChartBaseProps & {
|
|
78
107
|
data: CategoricalData;
|
|
@@ -81,6 +110,10 @@ export type BarChartProps = ChartBaseProps & {
|
|
|
81
110
|
/** L0 승격 스타일: 막대 모서리 둥글기 */
|
|
82
111
|
barRadius?: number;
|
|
83
112
|
barThickness?: number;
|
|
113
|
+
/** 주 y축 설정 (max/min/단위 포맷) */
|
|
114
|
+
yAxis?: AxisConfig;
|
|
115
|
+
/** 보조 y축 (우측). 정의 시 생성 — 시리즈 `yAxisID:"y1"` 로 연결 (듀얼축) */
|
|
116
|
+
y1Axis?: AxisConfig;
|
|
84
117
|
};
|
|
85
118
|
export type LineChartProps = ChartBaseProps & {
|
|
86
119
|
data: CategoricalData;
|
|
@@ -91,6 +124,10 @@ export type LineChartProps = ChartBaseProps & {
|
|
|
91
124
|
/** L0 승격 스타일 */
|
|
92
125
|
pointStyle?: PointStyle;
|
|
93
126
|
lineWidth?: number;
|
|
127
|
+
/** 주 y축 설정 (max/min/단위 포맷) */
|
|
128
|
+
yAxis?: AxisConfig;
|
|
129
|
+
/** 보조 y축 (우측). 정의 시 생성 — 시리즈 `yAxisID:"y1"` 로 연결 (듀얼축) */
|
|
130
|
+
y1Axis?: AxisConfig;
|
|
94
131
|
};
|
|
95
132
|
export type PieChartProps = ChartBaseProps & {
|
|
96
133
|
data: ProportionData;
|
|
@@ -102,6 +139,14 @@ export type DoughnutChartProps = ChartBaseProps & {
|
|
|
102
139
|
/** 0~1, 도넛 구멍 크기 (기본 0.6) */
|
|
103
140
|
cutout?: number;
|
|
104
141
|
};
|
|
142
|
+
export type RadarChartProps = ChartBaseProps & {
|
|
143
|
+
/** 단일 시리즈(labels+values) 또는 다중 시리즈 모두 허용 */
|
|
144
|
+
data: CategoricalData;
|
|
145
|
+
/** 방사축 최댓값 (suggestedMax). 미지정 시 자동 */
|
|
146
|
+
max?: number;
|
|
147
|
+
/** 다각형 면적 채우기 (기본 true) */
|
|
148
|
+
fill?: boolean;
|
|
149
|
+
};
|
|
105
150
|
/** ChartRenderer가 받는 통합 타입. type으로 좁히면 data가 자동 결정 → `as` 캐스팅 제거 */
|
|
106
151
|
export type AnyChartProps = ({
|
|
107
152
|
type: "bar";
|
|
@@ -111,4 +156,6 @@ export type AnyChartProps = ({
|
|
|
111
156
|
type: "pie";
|
|
112
157
|
} & PieChartProps) | ({
|
|
113
158
|
type: "doughnut";
|
|
114
|
-
} & DoughnutChartProps)
|
|
159
|
+
} & DoughnutChartProps) | ({
|
|
160
|
+
type: "radar";
|
|
161
|
+
} & RadarChartProps);
|
package/dist/entry/chart.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ export { default as BarChart } from '../components/Chart/charts/BarChart';
|
|
|
2
2
|
export { default as LineChart } from '../components/Chart/charts/LineChart';
|
|
3
3
|
export { default as PieChart } from '../components/Chart/charts/PieChart';
|
|
4
4
|
export { default as DoughnutChart } from '../components/Chart/charts/DoughnutChart';
|
|
5
|
+
export { default as RadarChart } from '../components/Chart/charts/RadarChart';
|
|
5
6
|
export { ChartThemeProvider } from '../components/Chart/Chart.theme';
|
|
6
|
-
export type { BarChartProps, LineChartProps, PieChartProps, DoughnutChartProps, ChartBaseProps, ChartThemeValue, ChartPreset, ChartStyleDefaults, SimpleDatum, ChartSeries, SeriesData, CategoricalData, ProportionData, PaletteInput, } from '../components/Chart/Chart.type';
|
|
7
|
+
export type { BarChartProps, LineChartProps, PieChartProps, DoughnutChartProps, RadarChartProps, ChartBaseProps, AxisConfig, ChartThemeValue, ChartPreset, ChartStyleDefaults, SimpleDatum, ChartSeries, SeriesData, CategoricalData, ProportionData, PaletteInput, } from '../components/Chart/Chart.type';
|