@x-plat/design-system 0.18.0 → 0.19.0
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/dist/components/Chart/index.cjs +5 -4
- package/dist/components/Chart/index.d.cts +9 -0
- package/dist/components/Chart/index.d.ts +9 -0
- package/dist/components/Chart/index.js +5 -4
- package/dist/components/index.cjs +5 -4
- package/dist/components/index.js +5 -4
- package/dist/index.cjs +5 -4
- package/dist/index.js +5 -4
- package/guidelines/components/chart.md +52 -10
- package/package.json +1 -1
|
@@ -643,9 +643,9 @@ var ChartTooltip = ({ x, y, containerWidth, containerHeight, tooltipType, childr
|
|
|
643
643
|
}
|
|
644
644
|
);
|
|
645
645
|
};
|
|
646
|
-
var ChartLegend = ({ data, labels,
|
|
646
|
+
var ChartLegend = ({ data, labels, shape }) => {
|
|
647
647
|
const entries = Object.entries(data);
|
|
648
|
-
if (
|
|
648
|
+
if (shape === "pie" || shape === "doughnut") {
|
|
649
649
|
const values = entries.flatMap(([, v]) => v);
|
|
650
650
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
651
651
|
const firstKey = entries[0]?.[0] ?? "";
|
|
@@ -682,8 +682,9 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
682
682
|
}) });
|
|
683
683
|
};
|
|
684
684
|
var Chart = import_react.default.memo((props) => {
|
|
685
|
-
const { variant, type, data, labels, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
685
|
+
const { variant, type, data, labels, legend, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
686
686
|
const shape = variant ?? type ?? "line";
|
|
687
|
+
const showLegend = legend ?? (shape === "pie" || shape === "doughnut");
|
|
687
688
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
688
689
|
const { width, height } = useChartSize(containerRef);
|
|
689
690
|
const stableData = import_react.default.useMemo(() => data, [JSON.stringify(data)]);
|
|
@@ -697,7 +698,7 @@ var Chart = import_react.default.memo((props) => {
|
|
|
697
698
|
ready && shape === "bar" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
698
699
|
ready && shape === "pie" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
699
700
|
ready && shape === "doughnut" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onMove: move, onLeave: hide }),
|
|
700
|
-
ready &&
|
|
701
|
+
ready && showLegend && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChartLegend, { data: stableData, labels: stableLabels, shape }),
|
|
701
702
|
tooltip.visible && tooltip.content && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, tooltipType, children: tooltip.content })
|
|
702
703
|
] });
|
|
703
704
|
});
|
|
@@ -13,6 +13,15 @@ interface ChartProps {
|
|
|
13
13
|
data: Record<string, number[]>;
|
|
14
14
|
/** x축 라벨. data 의 값 배열과 길이가 같아야 한다 */
|
|
15
15
|
labels: string[];
|
|
16
|
+
/**
|
|
17
|
+
* 계열 이름·색·합계를 차트 아래에 적는다.
|
|
18
|
+
*
|
|
19
|
+
* 안 주면 **원형·도넛만 켜진다** — 조각에는 제 이름을 적을 데가 없어서다.
|
|
20
|
+
* 선·곡선·막대는 축 라벨이 있어 지금까지 범례 없이 지냈고, 켜면 차트가
|
|
21
|
+
* 범례 높이만큼 길어지므로 기본값을 바꾸지 않는다. 필요한 곳에서 `legend`
|
|
22
|
+
* 를 주면 된다.
|
|
23
|
+
*/
|
|
24
|
+
legend?: boolean;
|
|
16
25
|
/** 마우스를 올렸을 때 값 말풍선을 띄운다 */
|
|
17
26
|
tooltip?: boolean;
|
|
18
27
|
/** 말풍선 배색 */
|
|
@@ -13,6 +13,15 @@ interface ChartProps {
|
|
|
13
13
|
data: Record<string, number[]>;
|
|
14
14
|
/** x축 라벨. data 의 값 배열과 길이가 같아야 한다 */
|
|
15
15
|
labels: string[];
|
|
16
|
+
/**
|
|
17
|
+
* 계열 이름·색·합계를 차트 아래에 적는다.
|
|
18
|
+
*
|
|
19
|
+
* 안 주면 **원형·도넛만 켜진다** — 조각에는 제 이름을 적을 데가 없어서다.
|
|
20
|
+
* 선·곡선·막대는 축 라벨이 있어 지금까지 범례 없이 지냈고, 켜면 차트가
|
|
21
|
+
* 범례 높이만큼 길어지므로 기본값을 바꾸지 않는다. 필요한 곳에서 `legend`
|
|
22
|
+
* 를 주면 된다.
|
|
23
|
+
*/
|
|
24
|
+
legend?: boolean;
|
|
16
25
|
/** 마우스를 올렸을 때 값 말풍선을 띄운다 */
|
|
17
26
|
tooltip?: boolean;
|
|
18
27
|
/** 말풍선 배색 */
|
|
@@ -607,9 +607,9 @@ var ChartTooltip = ({ x, y, containerWidth, containerHeight, tooltipType, childr
|
|
|
607
607
|
}
|
|
608
608
|
);
|
|
609
609
|
};
|
|
610
|
-
var ChartLegend = ({ data, labels,
|
|
610
|
+
var ChartLegend = ({ data, labels, shape }) => {
|
|
611
611
|
const entries = Object.entries(data);
|
|
612
|
-
if (
|
|
612
|
+
if (shape === "pie" || shape === "doughnut") {
|
|
613
613
|
const values = entries.flatMap(([, v]) => v);
|
|
614
614
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
615
615
|
const firstKey = entries[0]?.[0] ?? "";
|
|
@@ -646,8 +646,9 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
646
646
|
}) });
|
|
647
647
|
};
|
|
648
648
|
var Chart = React.memo((props) => {
|
|
649
|
-
const { variant, type, data, labels, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
649
|
+
const { variant, type, data, labels, legend, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
650
650
|
const shape = variant ?? type ?? "line";
|
|
651
|
+
const showLegend = legend ?? (shape === "pie" || shape === "doughnut");
|
|
651
652
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
652
653
|
const { width, height } = useChartSize(containerRef);
|
|
653
654
|
const stableData = React.useMemo(() => data, [JSON.stringify(data)]);
|
|
@@ -661,7 +662,7 @@ var Chart = React.memo((props) => {
|
|
|
661
662
|
ready && shape === "bar" && /* @__PURE__ */ jsx(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
662
663
|
ready && shape === "pie" && /* @__PURE__ */ jsx(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
663
664
|
ready && shape === "doughnut" && /* @__PURE__ */ jsx(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onMove: move, onLeave: hide }),
|
|
664
|
-
ready &&
|
|
665
|
+
ready && showLegend && /* @__PURE__ */ jsx(ChartLegend, { data: stableData, labels: stableLabels, shape }),
|
|
665
666
|
tooltip.visible && tooltip.content && /* @__PURE__ */ jsx(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, tooltipType, children: tooltip.content })
|
|
666
667
|
] });
|
|
667
668
|
});
|
|
@@ -2831,9 +2831,9 @@ var ChartTooltip = ({ x, y, containerWidth, containerHeight, tooltipType, childr
|
|
|
2831
2831
|
}
|
|
2832
2832
|
);
|
|
2833
2833
|
};
|
|
2834
|
-
var ChartLegend = ({ data, labels,
|
|
2834
|
+
var ChartLegend = ({ data, labels, shape }) => {
|
|
2835
2835
|
const entries = Object.entries(data);
|
|
2836
|
-
if (
|
|
2836
|
+
if (shape === "pie" || shape === "doughnut") {
|
|
2837
2837
|
const values = entries.flatMap(([, v]) => v);
|
|
2838
2838
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
2839
2839
|
const firstKey = entries[0]?.[0] ?? "";
|
|
@@ -2870,8 +2870,9 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2870
2870
|
}) });
|
|
2871
2871
|
};
|
|
2872
2872
|
var Chart = import_react6.default.memo((props) => {
|
|
2873
|
-
const { variant, type, data, labels, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
2873
|
+
const { variant, type, data, labels, legend, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
2874
2874
|
const shape = variant ?? type ?? "line";
|
|
2875
|
+
const showLegend = legend ?? (shape === "pie" || shape === "doughnut");
|
|
2875
2876
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
2876
2877
|
const { width, height } = useChartSize(containerRef);
|
|
2877
2878
|
const stableData = import_react6.default.useMemo(() => data, [JSON.stringify(data)]);
|
|
@@ -2885,7 +2886,7 @@ var Chart = import_react6.default.memo((props) => {
|
|
|
2885
2886
|
ready && shape === "bar" && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2886
2887
|
ready && shape === "pie" && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2887
2888
|
ready && shape === "doughnut" && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onMove: move, onLeave: hide }),
|
|
2888
|
-
ready &&
|
|
2889
|
+
ready && showLegend && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(ChartLegend, { data: stableData, labels: stableLabels, shape }),
|
|
2889
2890
|
tooltip.visible && tooltip.content && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, tooltipType, children: tooltip.content })
|
|
2890
2891
|
] });
|
|
2891
2892
|
});
|
package/dist/components/index.js
CHANGED
|
@@ -2728,9 +2728,9 @@ var ChartTooltip = ({ x, y, containerWidth, containerHeight, tooltipType, childr
|
|
|
2728
2728
|
}
|
|
2729
2729
|
);
|
|
2730
2730
|
};
|
|
2731
|
-
var ChartLegend = ({ data, labels,
|
|
2731
|
+
var ChartLegend = ({ data, labels, shape }) => {
|
|
2732
2732
|
const entries = Object.entries(data);
|
|
2733
|
-
if (
|
|
2733
|
+
if (shape === "pie" || shape === "doughnut") {
|
|
2734
2734
|
const values = entries.flatMap(([, v]) => v);
|
|
2735
2735
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
2736
2736
|
const firstKey = entries[0]?.[0] ?? "";
|
|
@@ -2767,8 +2767,9 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
2767
2767
|
}) });
|
|
2768
2768
|
};
|
|
2769
2769
|
var Chart = React6.memo((props) => {
|
|
2770
|
-
const { variant, type, data, labels, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
2770
|
+
const { variant, type, data, labels, legend, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
2771
2771
|
const shape = variant ?? type ?? "line";
|
|
2772
|
+
const showLegend = legend ?? (shape === "pie" || shape === "doughnut");
|
|
2772
2773
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
2773
2774
|
const { width, height } = useChartSize(containerRef);
|
|
2774
2775
|
const stableData = React6.useMemo(() => data, [JSON.stringify(data)]);
|
|
@@ -2782,7 +2783,7 @@ var Chart = React6.memo((props) => {
|
|
|
2782
2783
|
ready && shape === "bar" && /* @__PURE__ */ jsx306(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2783
2784
|
ready && shape === "pie" && /* @__PURE__ */ jsx306(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
2784
2785
|
ready && shape === "doughnut" && /* @__PURE__ */ jsx306(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onMove: move, onLeave: hide }),
|
|
2785
|
-
ready &&
|
|
2786
|
+
ready && showLegend && /* @__PURE__ */ jsx306(ChartLegend, { data: stableData, labels: stableLabels, shape }),
|
|
2786
2787
|
tooltip.visible && tooltip.content && /* @__PURE__ */ jsx306(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, tooltipType, children: tooltip.content })
|
|
2787
2788
|
] });
|
|
2788
2789
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -7230,9 +7230,9 @@ var ChartTooltip = ({ x, y, containerWidth, containerHeight, tooltipType, childr
|
|
|
7230
7230
|
}
|
|
7231
7231
|
);
|
|
7232
7232
|
};
|
|
7233
|
-
var ChartLegend = ({ data, labels,
|
|
7233
|
+
var ChartLegend = ({ data, labels, shape }) => {
|
|
7234
7234
|
const entries = Object.entries(data);
|
|
7235
|
-
if (
|
|
7235
|
+
if (shape === "pie" || shape === "doughnut") {
|
|
7236
7236
|
const values = entries.flatMap(([, v]) => v);
|
|
7237
7237
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
7238
7238
|
const firstKey = entries[0]?.[0] ?? "";
|
|
@@ -7269,8 +7269,9 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
7269
7269
|
}) });
|
|
7270
7270
|
};
|
|
7271
7271
|
var Chart = import_react6.default.memo((props) => {
|
|
7272
|
-
const { variant, type, data, labels, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
7272
|
+
const { variant, type, data, labels, legend, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
7273
7273
|
const shape = variant ?? type ?? "line";
|
|
7274
|
+
const showLegend = legend ?? (shape === "pie" || shape === "doughnut");
|
|
7274
7275
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
7275
7276
|
const { width, height } = useChartSize(containerRef);
|
|
7276
7277
|
const stableData = import_react6.default.useMemo(() => data, [JSON.stringify(data)]);
|
|
@@ -7284,7 +7285,7 @@ var Chart = import_react6.default.memo((props) => {
|
|
|
7284
7285
|
ready && shape === "bar" && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
7285
7286
|
ready && shape === "pie" && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
7286
7287
|
ready && shape === "doughnut" && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onMove: move, onLeave: hide }),
|
|
7287
|
-
ready &&
|
|
7288
|
+
ready && showLegend && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(ChartLegend, { data: stableData, labels: stableLabels, shape }),
|
|
7288
7289
|
tooltip.visible && tooltip.content && /* @__PURE__ */ (0, import_jsx_runtime306.jsx)(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, tooltipType, children: tooltip.content })
|
|
7289
7290
|
] });
|
|
7290
7291
|
});
|
package/dist/index.js
CHANGED
|
@@ -6818,9 +6818,9 @@ var ChartTooltip = ({ x, y, containerWidth, containerHeight, tooltipType, childr
|
|
|
6818
6818
|
}
|
|
6819
6819
|
);
|
|
6820
6820
|
};
|
|
6821
|
-
var ChartLegend = ({ data, labels,
|
|
6821
|
+
var ChartLegend = ({ data, labels, shape }) => {
|
|
6822
6822
|
const entries = Object.entries(data);
|
|
6823
|
-
if (
|
|
6823
|
+
if (shape === "pie" || shape === "doughnut") {
|
|
6824
6824
|
const values = entries.flatMap(([, v]) => v);
|
|
6825
6825
|
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
6826
6826
|
const firstKey = entries[0]?.[0] ?? "";
|
|
@@ -6857,8 +6857,9 @@ var ChartLegend = ({ data, labels, type }) => {
|
|
|
6857
6857
|
}) });
|
|
6858
6858
|
};
|
|
6859
6859
|
var Chart = React6.memo((props) => {
|
|
6860
|
-
const { variant, type, data, labels, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
6860
|
+
const { variant, type, data, labels, legend, tooltip: showTooltip = true, tooltipType = "light" } = props;
|
|
6861
6861
|
const shape = variant ?? type ?? "line";
|
|
6862
|
+
const showLegend = legend ?? (shape === "pie" || shape === "doughnut");
|
|
6862
6863
|
const { tooltip, show, hide, move, containerRef } = useChartTooltip(showTooltip);
|
|
6863
6864
|
const { width, height } = useChartSize(containerRef);
|
|
6864
6865
|
const stableData = React6.useMemo(() => data, [JSON.stringify(data)]);
|
|
@@ -6872,7 +6873,7 @@ var Chart = React6.memo((props) => {
|
|
|
6872
6873
|
ready && shape === "bar" && /* @__PURE__ */ jsx306(BarChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
6873
6874
|
ready && shape === "pie" && /* @__PURE__ */ jsx306(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, onHover: show, onMove: move, onLeave: hide }),
|
|
6874
6875
|
ready && shape === "doughnut" && /* @__PURE__ */ jsx306(PieDonutChart, { data: stableData, labels: stableLabels, width, height, animate, isDoughnut: true, onHover: show, onMove: move, onLeave: hide }),
|
|
6875
|
-
ready &&
|
|
6876
|
+
ready && showLegend && /* @__PURE__ */ jsx306(ChartLegend, { data: stableData, labels: stableLabels, shape }),
|
|
6876
6877
|
tooltip.visible && tooltip.content && /* @__PURE__ */ jsx306(ChartTooltip, { x: tooltip.x, y: tooltip.y, containerWidth: width, containerHeight: height, tooltipType, children: tooltip.content })
|
|
6877
6878
|
] });
|
|
6878
6879
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Chart
|
|
2
2
|
|
|
3
|
-
SVG 기반 차트를 렌더한다. line
|
|
3
|
+
SVG 기반 차트를 렌더한다. `line`·`curve`·`bar`·`pie`·`doughnut` 다섯 모양을 지원한다.
|
|
4
4
|
|
|
5
5
|
```tsx
|
|
6
6
|
import { Chart } from "@x-plat/design-system";
|
|
@@ -8,26 +8,53 @@ import { Chart } from "@x-plat/design-system";
|
|
|
8
8
|
|
|
9
9
|
## Props
|
|
10
10
|
|
|
11
|
+
<!-- props:Chart -->
|
|
11
12
|
| Prop | 타입 | 기본값 | 설명 |
|
|
12
13
|
|------|------|--------|------|
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
14
|
+
| data * | `Record<string, number[]>` | - | 계열 이름 → 값 배열. 키 하나가 선/막대 하나가 된다 |
|
|
15
|
+
| labels * | `string[]` | - | x축 라벨. data 의 값 배열과 길이가 같아야 한다 |
|
|
16
|
+
| variant | `"line" \| "curve" \| "bar" \| "pie" \| "doughnut"` | - | 차트 종류 |
|
|
17
|
+
| type | `"line" \| "curve" \| "bar" \| "pie" \| "doughnut"` | - | **@deprecated** 모양 변형은 `variant` 로 받는다. `type` 은 상태 색 전용이다. 기존 사용처가 깨지지 않도록 계속 받는다 — 둘 다 주면 `variant` 가 이긴다. |
|
|
18
|
+
| legend | `boolean` | - | 계열 이름·색·합계를 차트 아래에 적는다. 안 주면 **원형·도넛만 켜진다** — 조각에는 제 이름을 적을 데가 없어서다. 선·곡선·막대는 축 라벨이 있어 지금까지 범례 없이 지냈고, 켜면 차트가 범례 높이만큼 길어지므로 기본값을 바꾸지 않는다. 필요한 곳에서 `legend` 를 주면 된다. |
|
|
19
|
+
| tooltip | `boolean` | `true` | 마우스를 올렸을 때 값 말풍선을 띄운다 |
|
|
20
|
+
| tooltipType | `"dark" \| "light"` | `"light"` | 말풍선 배색 |
|
|
21
|
+
|
|
22
|
+
`*` = 필수
|
|
23
|
+
<!-- /props:Chart -->
|
|
17
24
|
|
|
18
25
|
## 색상
|
|
19
26
|
|
|
20
|
-
semantic categorical
|
|
27
|
+
semantic categorical 토큰으로 계열마다 색을 자동 배정한다. `line`·`curve`·`bar` 는
|
|
28
|
+
`LINE_BAR_PALETTES`, `pie`·`doughnut` 는 `PIE_COLORS` 를 쓴다.
|
|
29
|
+
|
|
30
|
+
계열 색은 **순번과 계열 이름 해시**로 정해진다 — `getPalette(LINE_BAR_PALETTES, 순번, 키)[2]`.
|
|
31
|
+
이름이 같으면 어느 차트에서든 같은 색이 나온다. 범례 점도 같은 식으로 집으므로
|
|
32
|
+
그림과 어긋나지 않는다.
|
|
33
|
+
|
|
34
|
+
## 범례
|
|
35
|
+
|
|
36
|
+
`legend` 를 주면 계열 이름·색·합계를 차트 아래에 적는다.
|
|
37
|
+
|
|
38
|
+
안 주면 **원형·도넛만 켜진다.** 조각에는 제 이름을 적을 데가 없어서다.
|
|
39
|
+
선·곡선·막대는 축 라벨이 있어 지금까지 범례 없이 지냈고, 켜면 차트가 범례
|
|
40
|
+
높이만큼 길어진다 — 그래서 기본값을 바꾸지 않았다. 필요한 곳에서 켜면 된다.
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
<Chart variant="bar" legend labels={…} data={…} /> {/* 켠다 */}
|
|
44
|
+
<Chart variant="pie" legend={false} labels={…} data={…} /> {/* 끈다 */}
|
|
45
|
+
```
|
|
21
46
|
|
|
22
47
|
---
|
|
23
48
|
|
|
24
49
|
## 사용 예시
|
|
25
50
|
|
|
26
|
-
|
|
51
|
+
> 모양은 `variant` 로 준다. `type` 도 아직 받지만 `@deprecated` 다.
|
|
52
|
+
|
|
53
|
+
### Line / Curve
|
|
27
54
|
|
|
28
55
|
```tsx
|
|
29
56
|
<Chart
|
|
30
|
-
|
|
57
|
+
variant="line"
|
|
31
58
|
labels={["1월", "2월", "3월", "4월"]}
|
|
32
59
|
data={{
|
|
33
60
|
매출: [100, 200, 150, 300],
|
|
@@ -36,23 +63,38 @@ semantic categorical 토큰 기반으로 시리즈별 색상을 자동 배정한
|
|
|
36
63
|
/>
|
|
37
64
|
```
|
|
38
65
|
|
|
66
|
+
`variant="curve"` 는 같은 데이터를 곡선으로 잇는다.
|
|
67
|
+
|
|
39
68
|
### Bar
|
|
40
69
|
|
|
41
70
|
```tsx
|
|
42
71
|
<Chart
|
|
43
|
-
|
|
72
|
+
variant="bar"
|
|
44
73
|
labels={["서울", "부산", "대구"]}
|
|
45
74
|
data={{ 방문자: [500, 300, 200] }}
|
|
46
75
|
/>
|
|
47
76
|
```
|
|
48
77
|
|
|
78
|
+
계열이 여럿이라 어느 막대가 무엇인지 적어야 하면 `legend` 를 켠다.
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
<Chart
|
|
82
|
+
variant="bar"
|
|
83
|
+
legend
|
|
84
|
+
labels={["서울", "부산", "대구"]}
|
|
85
|
+
data={{ 방문자: [500, 300, 200], 가입자: [120, 90, 40] }}
|
|
86
|
+
/>
|
|
87
|
+
```
|
|
88
|
+
|
|
49
89
|
### Pie / Doughnut
|
|
50
90
|
|
|
51
91
|
```tsx
|
|
52
92
|
<Chart
|
|
53
|
-
|
|
93
|
+
variant="doughnut"
|
|
54
94
|
labels={["모바일", "데스크톱", "태블릿"]}
|
|
55
95
|
data={{ 점유율: [60, 30, 10] }}
|
|
56
96
|
tooltip={false}
|
|
57
97
|
/>
|
|
58
98
|
```
|
|
99
|
+
|
|
100
|
+
범례는 기본으로 켜져 있다. `legend={false}` 로 끈다.
|