@keneth80/k-chart 1.10.0 → 1.12.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/CHANGELOG.md +32 -0
- package/README.md +4 -0
- package/docs/configuration-reference.md +21 -0
- package/docs/functional-api.md +71 -0
- package/examples/stackblitz-korea-region-map-basic/index.html +20 -0
- package/examples/stackblitz-korea-region-map-basic/package-lock.json +1434 -0
- package/examples/stackblitz-korea-region-map-basic/package.json +17 -0
- package/examples/stackblitz-korea-region-map-basic/src/main.ts +99 -0
- package/examples/stackblitz-korea-region-map-basic/src/style.css +57 -0
- package/examples/stackblitz-world-country-map-basic/index.html +20 -0
- package/examples/stackblitz-world-country-map-basic/package-lock.json +1434 -0
- package/examples/stackblitz-world-country-map-basic/package.json +17 -0
- package/examples/stackblitz-world-country-map-basic/src/main.ts +64 -0
- package/examples/stackblitz-world-country-map-basic/src/style.css +57 -0
- package/lib/core/contracts.d.ts +64 -0
- package/lib/core/contracts.d.ts.map +1 -1
- package/lib/series/index.d.ts +1 -0
- package/lib/series/index.d.ts.map +1 -1
- package/lib/series/index.js +1 -0
- package/lib/series/index.js.map +1 -1
- package/lib/series/svg-region-map.d.ts +4 -0
- package/lib/series/svg-region-map.d.ts.map +1 -0
- package/lib/series/svg-region-map.js +507 -0
- package/lib/series/svg-region-map.js.map +1 -0
- package/package.json +1 -1
|
@@ -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,99 @@
|
|
|
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: 112, color: "#9f1239", note: "Capital area" },
|
|
34
|
+
{ name: "경기도", value: 111, color: "#be123c", note: "Largest population" },
|
|
35
|
+
{ name: "강원도", value: 104, color: "#fb7185", note: "Mountain tourism" },
|
|
36
|
+
{ name: "충청북도", value: 107, color: "#f43f5e", note: "Inland region" },
|
|
37
|
+
{ name: "충청남도", value: 109, color: "#e11d48", note: "West coast" },
|
|
38
|
+
{ name: "대전광역시", value: 106, color: "#fb7185", note: "Science city" },
|
|
39
|
+
{ name: "경상북도", value: 106, color: "#fb7185", note: "Heritage route" },
|
|
40
|
+
{ name: "대구광역시", value: 103, color: "#fda4af", note: "Metro city" },
|
|
41
|
+
{ name: "전라북도", value: 107, color: "#f43f5e", note: "Food route" },
|
|
42
|
+
{ name: "전라남도", value: 107, color: "#f43f5e", note: "Island route" },
|
|
43
|
+
{ name: "광주광역시", value: 104, color: "#fb7185", note: "Culture city" },
|
|
44
|
+
{ name: "경상남도", value: 105, color: "#fb7185", note: "South coast" },
|
|
45
|
+
{ name: "부산광역시", value: 105, color: "#fb7185", note: "Harbor city" },
|
|
46
|
+
{ name: "울산광역시", value: 110, color: "#e11d48", note: "Industrial city" },
|
|
47
|
+
{ name: "제주특별자치도", value: 103, color: "#fda4af", 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
|
+
zoom: {
|
|
77
|
+
enabled: true,
|
|
78
|
+
wheel: true,
|
|
79
|
+
pan: true,
|
|
80
|
+
scaleExtent: [1, 7],
|
|
81
|
+
controls: { visible: true, x: 10, y: 10, step: 0.3 }
|
|
82
|
+
},
|
|
83
|
+
labels: {
|
|
84
|
+
visible: true,
|
|
85
|
+
mode: "centroid",
|
|
86
|
+
fill: "#edf3f8",
|
|
87
|
+
fontSize: 10,
|
|
88
|
+
fontWeight: 900,
|
|
89
|
+
stroke: "rgba(15, 23, 42, 0.68)",
|
|
90
|
+
strokeWidth: 2,
|
|
91
|
+
formatter: ({ label, value }) => `${label.replace("광역시", "").replace("특별시", "")} ${value}`
|
|
92
|
+
},
|
|
93
|
+
tooltip: {
|
|
94
|
+
formatter: ({ label, data: item, value }) =>
|
|
95
|
+
`<strong>${label}</strong><br/>score: ${value}<br/>${item?.note ?? ""}`
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
}).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>
|