@keneth80/k-chart 1.10.0 → 1.11.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.
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "kchart-korea-region-map-basic",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite --host 0.0.0.0",
8
+ "build": "vite build",
9
+ "preview": "vite preview --host 0.0.0.0"
10
+ },
11
+ "dependencies": {
12
+ "@keneth80/k-chart": "^1.11.0",
13
+ "typescript": "^6.0.3",
14
+ "vite": "^7.1.12"
15
+ },
16
+ "devDependencies": {}
17
+ }
@@ -0,0 +1,90 @@
1
+ import { createGeoRegionMapSeries, createKChart } from "@keneth80/k-chart";
2
+ import "./style.css";
3
+
4
+ type RegionDatum = {
5
+ name: string;
6
+ value: number;
7
+ color: string;
8
+ note: string;
9
+ };
10
+
11
+ const koreaRegions = {
12
+ type: "FeatureCollection",
13
+ features: [
14
+ { type: "Feature", properties: { name: "강원도" }, geometry: { type: "Polygon", coordinates: [[[127.35, 38.55], [129.42, 38.42], [129.35, 37.05], [128.45, 36.75], [127.25, 37.05], [127.35, 38.55]]] } },
15
+ { type: "Feature", properties: { name: "경기도" }, geometry: { type: "Polygon", coordinates: [[[126.34, 38.18], [127.68, 38.05], [127.72, 37.05], [126.92, 36.82], [126.32, 37.24], [126.34, 38.18]]] } },
16
+ { type: "Feature", properties: { name: "서울특별시" }, geometry: { type: "Polygon", coordinates: [[[126.78, 37.72], [127.18, 37.70], [127.18, 37.42], [126.80, 37.42], [126.78, 37.72]]] } },
17
+ { type: "Feature", properties: { name: "충청북도" }, geometry: { type: "Polygon", coordinates: [[[127.25, 37.15], [128.32, 36.9], [128.2, 36.1], [127.15, 35.92], [126.9, 36.72], [127.25, 37.15]]] } },
18
+ { type: "Feature", properties: { name: "충청남도" }, geometry: { type: "Polygon", coordinates: [[[126.1, 36.95], [127.1, 36.78], [127.2, 35.92], [126.15, 35.72], [125.8, 36.45], [126.1, 36.95]]] } },
19
+ { type: "Feature", properties: { name: "대전광역시" }, geometry: { type: "Polygon", coordinates: [[[127.25, 36.48], [127.55, 36.46], [127.55, 36.22], [127.24, 36.22], [127.25, 36.48]]] } },
20
+ { type: "Feature", properties: { name: "경상북도" }, geometry: { type: "Polygon", coordinates: [[[128.2, 36.85], [129.35, 36.95], [129.55, 35.55], [128.45, 35.25], [127.95, 36.05], [128.2, 36.85]]] } },
21
+ { type: "Feature", properties: { name: "대구광역시" }, geometry: { type: "Polygon", coordinates: [[[128.45, 35.98], [128.78, 35.95], [128.78, 35.72], [128.44, 35.72], [128.45, 35.98]]] } },
22
+ { type: "Feature", properties: { name: "전라북도" }, geometry: { type: "Polygon", coordinates: [[[126.35, 35.8], [127.65, 35.82], [127.75, 35.1], [126.35, 34.92], [126.0, 35.42], [126.35, 35.8]]] } },
23
+ { type: "Feature", properties: { name: "전라남도" }, geometry: { type: "Polygon", coordinates: [[[125.85, 35.0], [127.35, 35.05], [127.15, 34.22], [126.08, 33.95], [125.75, 34.48], [125.85, 35.0]]] } },
24
+ { type: "Feature", properties: { name: "광주광역시" }, geometry: { type: "Polygon", coordinates: [[[126.73, 35.28], [127.0, 35.26], [127.0, 35.06], [126.73, 35.06], [126.73, 35.28]]] } },
25
+ { type: "Feature", properties: { name: "경상남도" }, geometry: { type: "Polygon", coordinates: [[[127.55, 35.22], [128.88, 35.36], [129.25, 34.75], [128.1, 34.48], [127.35, 34.72], [127.55, 35.22]]] } },
26
+ { type: "Feature", properties: { name: "부산광역시" }, geometry: { type: "Polygon", coordinates: [[[129.0, 35.28], [129.28, 35.24], [129.28, 35.02], [129.02, 34.98], [129.0, 35.28]]] } },
27
+ { type: "Feature", properties: { name: "울산광역시" }, geometry: { type: "Polygon", coordinates: [[[129.18, 35.7], [129.48, 35.66], [129.48, 35.42], [129.18, 35.42], [129.18, 35.7]]] } },
28
+ { type: "Feature", properties: { name: "제주특별자치도" }, geometry: { type: "Polygon", coordinates: [[[126.1, 33.62], [126.95, 33.62], [126.95, 33.22], [126.1, 33.22], [126.1, 33.62]]] } }
29
+ ]
30
+ };
31
+
32
+ const data: RegionDatum[] = [
33
+ { name: "서울특별시", value: 92, color: "#2f73b8", note: "Capital area" },
34
+ { name: "경기도", value: 85, color: "#35995a", note: "Largest population" },
35
+ { name: "강원도", value: 48, color: "#e0005c", note: "Mountain tourism" },
36
+ { name: "충청북도", value: 52, color: "#65b946", note: "Inland region" },
37
+ { name: "충청남도", value: 58, color: "#41b434", note: "West coast" },
38
+ { name: "대전광역시", value: 66, color: "#2e9f68", note: "Science city" },
39
+ { name: "경상북도", value: 69, color: "#f05a1a", note: "Heritage route" },
40
+ { name: "대구광역시", value: 74, color: "#f36b21", note: "Metro city" },
41
+ { name: "전라북도", value: 57, color: "#8a1194", note: "Food route" },
42
+ { name: "전라남도", value: 63, color: "#38a6e8", note: "Island route" },
43
+ { name: "광주광역시", value: 61, color: "#36a8ee", note: "Culture city" },
44
+ { name: "경상남도", value: 71, color: "#55c2d6", note: "South coast" },
45
+ { name: "부산광역시", value: 82, color: "#202b84", note: "Harbor city" },
46
+ { name: "울산광역시", value: 67, color: "#5ecce0", note: "Industrial city" },
47
+ { name: "제주특별자치도", value: 79, color: "#72e4ff", note: "Island destination" }
48
+ ];
49
+
50
+ createKChart<RegionDatum>({
51
+ selector: "#chart",
52
+ data,
53
+ width: 1080,
54
+ height: 640,
55
+ margin: { top: 62, right: 36, bottom: 28, left: 36 },
56
+ title: { text: "Korea region choropleth", align: "left", fontSize: 15 },
57
+ grid: { visible: false },
58
+ legend: { visible: false },
59
+ tooltip: { visible: true },
60
+ axes: [],
61
+ series: [
62
+ createGeoRegionMapSeries<RegionDatum>({
63
+ selector: "korea-region",
64
+ displayName: "Korea Regions",
65
+ geoJson: koreaRegions,
66
+ dataKey: "name",
67
+ featureKey: "name",
68
+ labelKey: "name",
69
+ valueField: "value",
70
+ colorField: "color",
71
+ fitPadding: 44,
72
+ backgroundFill: "rgba(11, 16, 23, 0.26)",
73
+ stroke: "rgba(248, 251, 255, 0.92)",
74
+ strokeWidth: 1.4,
75
+ hoverStrokeWidth: 2.4,
76
+ labels: {
77
+ visible: true,
78
+ mode: "callout",
79
+ fill: "#edf3f8",
80
+ fontSize: 11,
81
+ offset: 18,
82
+ formatter: ({ label }) => label.replace("광역시", "").replace("특별시", "")
83
+ },
84
+ tooltip: {
85
+ formatter: ({ label, data: item, value }) =>
86
+ `<strong>${label}</strong><br/>score: ${value}<br/>${item?.note ?? ""}`
87
+ }
88
+ })
89
+ ]
90
+ }).render();
@@ -0,0 +1,57 @@
1
+ :root {
2
+ color-scheme: dark;
3
+ font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
4
+ background: #0b1017;
5
+ color: #edf3f8;
6
+ }
7
+
8
+ * {
9
+ box-sizing: border-box;
10
+ }
11
+
12
+ body {
13
+ margin: 0;
14
+ min-height: 100vh;
15
+ background:
16
+ radial-gradient(circle at 20% 10%, rgba(93, 184, 255, 0.16), transparent 30%),
17
+ linear-gradient(180deg, #17202b 0%, #0b1017 70%);
18
+ }
19
+
20
+ main {
21
+ min-height: 100vh;
22
+ display: grid;
23
+ place-items: center;
24
+ padding: 28px;
25
+ }
26
+
27
+ section {
28
+ width: min(1120px, 100%);
29
+ border: 1px solid rgba(219, 232, 242, 0.16);
30
+ border-radius: 12px;
31
+ background: rgba(21, 28, 38, 0.82);
32
+ box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
33
+ overflow: hidden;
34
+ }
35
+
36
+ section > div:first-child {
37
+ padding: 24px 28px 0;
38
+ }
39
+
40
+ p {
41
+ margin: 0 0 8px;
42
+ color: #8ea0ad;
43
+ font-size: 12px;
44
+ font-weight: 800;
45
+ text-transform: uppercase;
46
+ }
47
+
48
+ h1 {
49
+ margin: 0;
50
+ font-size: 26px;
51
+ }
52
+
53
+ #chart {
54
+ width: 100%;
55
+ min-height: 640px;
56
+ padding: 10px 16px 22px;
57
+ }
@@ -0,0 +1,20 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>KChart World Country Map</title>
7
+ </head>
8
+ <body>
9
+ <main>
10
+ <section>
11
+ <div>
12
+ <p>KChart SVG region map</p>
13
+ <h1>World country map</h1>
14
+ </div>
15
+ <div id="chart"></div>
16
+ </section>
17
+ </main>
18
+ <script type="module" src="/src/main.ts"></script>
19
+ </body>
20
+ </html>