@keneth80/k-chart 1.9.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.
- package/CHANGELOG.md +39 -0
- package/README.md +208 -1
- package/docs/assets/kchart-hero.svg +110 -0
- package/docs/assets/kchart-icon.svg +40 -0
- package/docs/configuration-reference.md +395 -0
- package/docs/functional-api.md +164 -3
- package/examples/stackblitz-candlestick-basic/index.html +23 -0
- package/examples/stackblitz-candlestick-basic/package-lock.json +1435 -0
- package/examples/stackblitz-candlestick-basic/package.json +18 -0
- package/examples/stackblitz-candlestick-basic/src/main.ts +107 -0
- package/examples/stackblitz-candlestick-basic/src/style.css +16 -0
- package/examples/stackblitz-canvas-line-basic/index.html +23 -0
- package/examples/stackblitz-canvas-line-basic/package-lock.json +1435 -0
- package/examples/stackblitz-canvas-line-basic/package.json +18 -0
- package/examples/stackblitz-canvas-line-basic/src/main.ts +73 -0
- package/examples/stackblitz-canvas-line-basic/src/style.css +46 -0
- package/examples/stackblitz-column-basic/index.html +23 -0
- package/examples/stackblitz-column-basic/package-lock.json +1435 -0
- package/examples/stackblitz-column-basic/package.json +18 -0
- package/examples/stackblitz-column-basic/src/main.ts +128 -0
- package/examples/stackblitz-column-basic/src/style.css +41 -0
- package/examples/stackblitz-doughnut-basic/index.html +21 -0
- package/examples/stackblitz-doughnut-basic/package-lock.json +1435 -0
- package/examples/stackblitz-doughnut-basic/package.json +18 -0
- package/examples/stackblitz-doughnut-basic/src/main.ts +177 -0
- package/examples/stackblitz-doughnut-basic/src/style.css +43 -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 +90 -0
- package/examples/stackblitz-korea-region-map-basic/src/style.css +57 -0
- package/examples/stackblitz-line-basic/index.html +23 -0
- package/examples/stackblitz-line-basic/package-lock.json +1435 -0
- package/examples/stackblitz-line-basic/package.json +18 -0
- package/examples/stackblitz-line-basic/src/main.ts +112 -0
- package/examples/stackblitz-line-basic/src/style.css +108 -0
- package/examples/stackblitz-multi-series-basic/index.html +1 -0
- package/examples/stackblitz-multi-series-basic/package-lock.json +1435 -0
- package/examples/stackblitz-multi-series-basic/package.json +9 -0
- package/examples/stackblitz-multi-series-basic/src/main.ts +29 -0
- package/examples/stackblitz-multi-series-basic/src/style.css +1 -0
- package/examples/stackblitz-options-basic/index.html +1 -0
- package/examples/stackblitz-options-basic/package-lock.json +1435 -0
- package/examples/stackblitz-options-basic/package.json +9 -0
- package/examples/stackblitz-options-basic/src/main.ts +32 -0
- package/examples/stackblitz-options-basic/src/style.css +1 -0
- package/examples/stackblitz-pie-basic/index.html +21 -0
- package/examples/stackblitz-pie-basic/package-lock.json +1435 -0
- package/examples/stackblitz-pie-basic/package.json +18 -0
- package/examples/stackblitz-pie-basic/src/main.ts +156 -0
- package/examples/stackblitz-pie-basic/src/style.css +43 -0
- package/examples/stackblitz-plot-basic/index.html +1 -0
- package/examples/stackblitz-plot-basic/package-lock.json +1435 -0
- package/examples/stackblitz-plot-basic/package.json +9 -0
- package/examples/stackblitz-plot-basic/src/main.ts +32 -0
- package/examples/stackblitz-plot-basic/src/style.css +1 -0
- package/examples/stackblitz-radial-basic/index.html +21 -0
- package/examples/stackblitz-radial-basic/package-lock.json +1435 -0
- package/examples/stackblitz-radial-basic/package.json +18 -0
- package/examples/stackblitz-radial-basic/src/main.ts +223 -0
- package/examples/stackblitz-radial-basic/src/style.css +87 -0
- package/examples/stackblitz-simple-api-basic/index.html +30 -0
- package/examples/stackblitz-simple-api-basic/package-lock.json +1435 -0
- package/examples/stackblitz-simple-api-basic/package.json +18 -0
- package/examples/stackblitz-simple-api-basic/src/main.ts +69 -0
- package/examples/stackblitz-simple-api-basic/src/style.css +127 -0
- package/examples/stackblitz-stacked-column-basic/index.html +23 -0
- package/examples/stackblitz-stacked-column-basic/package-lock.json +1435 -0
- package/examples/stackblitz-stacked-column-basic/package.json +18 -0
- package/examples/stackblitz-stacked-column-basic/src/main.ts +136 -0
- package/examples/stackblitz-stacked-column-basic/src/style.css +16 -0
- package/examples/stackblitz-three-wafer-basic/index.html +1 -0
- package/examples/stackblitz-three-wafer-basic/package-lock.json +1453 -0
- package/examples/stackblitz-three-wafer-basic/package.json +9 -0
- package/examples/stackblitz-three-wafer-basic/src/main.ts +29 -0
- package/examples/stackblitz-three-wafer-basic/src/style.css +1 -0
- package/examples/stackblitz-topology-basic/index.html +1 -0
- package/examples/stackblitz-topology-basic/package-lock.json +1435 -0
- package/examples/stackblitz-topology-basic/package.json +9 -0
- package/examples/stackblitz-topology-basic/src/main.ts +89 -0
- package/examples/stackblitz-topology-basic/src/style.css +1 -0
- package/examples/stackblitz-webgl-line-basic/index.html +23 -0
- package/examples/stackblitz-webgl-line-basic/package-lock.json +1435 -0
- package/examples/stackblitz-webgl-line-basic/package.json +18 -0
- package/examples/stackblitz-webgl-line-basic/src/main.ts +86 -0
- package/examples/stackblitz-webgl-line-basic/src/style.css +46 -0
- package/examples/stackblitz-worker-json-line/index.html +41 -0
- package/examples/stackblitz-worker-json-line/package-lock.json +1435 -0
- package/examples/stackblitz-worker-json-line/package.json +19 -0
- package/examples/stackblitz-worker-json-line/public/data/large-line.json +4322 -0
- package/examples/stackblitz-worker-json-line/src/kchart-render.worker.ts +4 -0
- package/examples/stackblitz-worker-json-line/src/main.ts +185 -0
- package/examples/stackblitz-worker-json-line/src/style.css +101 -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 +72 -0
- package/lib/core/contracts.d.ts.map +1 -1
- package/lib/core/create-kchart.d.ts.map +1 -1
- package/lib/core/create-kchart.js +93 -4
- package/lib/core/create-kchart.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/kchart.d.ts +1 -0
- package/lib/kchart.d.ts.map +1 -1
- package/lib/kchart.js +1 -0
- package/lib/kchart.js.map +1 -1
- package/lib/presets/index.d.ts +97 -0
- package/lib/presets/index.d.ts.map +1 -0
- package/lib/presets/index.js +481 -0
- package/lib/presets/index.js.map +1 -0
- package/lib/series/canvas-line.d.ts.map +1 -1
- package/lib/series/canvas-line.js +16 -11
- package/lib/series/canvas-line.js.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-line.d.ts.map +1 -1
- package/lib/series/svg-line.js +19 -3
- package/lib/series/svg-line.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 +324 -0
- package/lib/series/svg-region-map.js.map +1 -0
- package/lib/series/webgl-line.d.ts.map +1 -1
- package/lib/series/webgl-line.js +10 -3
- package/lib/series/webgl-line.js.map +1 -1
- package/package.json +13 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kchart-stackblitz-line-basic",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite --host 0.0.0.0",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"preview": "vite preview --host 0.0.0.0"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@keneth80/k-chart": "^1.9.0"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"typescript": "^6.0.3",
|
|
16
|
+
"vite": "^7.2.7"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createKChart, createLineSeries } from '@keneth80/k-chart';
|
|
2
|
+
import './style.css';
|
|
3
|
+
|
|
4
|
+
interface RevenuePoint {
|
|
5
|
+
month: string;
|
|
6
|
+
revenue: number;
|
|
7
|
+
target: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const data: RevenuePoint[] = [
|
|
11
|
+
{ month: 'Jan', revenue: 42, target: 38 },
|
|
12
|
+
{ month: 'Feb', revenue: 48, target: 42 },
|
|
13
|
+
{ month: 'Mar', revenue: 45, target: 46 },
|
|
14
|
+
{ month: 'Apr', revenue: 58, target: 50 },
|
|
15
|
+
{ month: 'May', revenue: 64, target: 55 },
|
|
16
|
+
{ month: 'Jun', revenue: 62, target: 60 },
|
|
17
|
+
{ month: 'Jul', revenue: 74, target: 64 },
|
|
18
|
+
{ month: 'Aug', revenue: 81, target: 70 },
|
|
19
|
+
{ month: 'Sep', revenue: 78, target: 73 },
|
|
20
|
+
{ month: 'Oct', revenue: 88, target: 78 },
|
|
21
|
+
{ month: 'Nov', revenue: 92, target: 82 },
|
|
22
|
+
{ month: 'Dec', revenue: 101, target: 88 }
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const chart = createKChart<RevenuePoint>({
|
|
26
|
+
selector: '#chart',
|
|
27
|
+
data,
|
|
28
|
+
width: 920,
|
|
29
|
+
height: 460,
|
|
30
|
+
margin: {
|
|
31
|
+
top: 88,
|
|
32
|
+
right: 36,
|
|
33
|
+
bottom: 58,
|
|
34
|
+
left: 64
|
|
35
|
+
},
|
|
36
|
+
colors: ['#7dd3fc', '#fbbf24'],
|
|
37
|
+
title: {
|
|
38
|
+
text: 'Monthly Revenue vs Target',
|
|
39
|
+
align: 'left',
|
|
40
|
+
fontSize: 18
|
|
41
|
+
},
|
|
42
|
+
grid: {
|
|
43
|
+
visible: true,
|
|
44
|
+
x: false,
|
|
45
|
+
y: true,
|
|
46
|
+
color: 'rgba(148, 163, 184, 0.22)',
|
|
47
|
+
dasharray: '3 8'
|
|
48
|
+
},
|
|
49
|
+
legend: {
|
|
50
|
+
visible: true,
|
|
51
|
+
placement: 'top',
|
|
52
|
+
selectable: true
|
|
53
|
+
},
|
|
54
|
+
axes: [
|
|
55
|
+
{
|
|
56
|
+
field: 'month',
|
|
57
|
+
type: 'point',
|
|
58
|
+
placement: 'bottom',
|
|
59
|
+
title: 'Month'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
field: 'revenue',
|
|
63
|
+
type: 'number',
|
|
64
|
+
placement: 'left',
|
|
65
|
+
domainFields: ['revenue', 'target'],
|
|
66
|
+
min: 30,
|
|
67
|
+
title: 'Revenue (k USD)'
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
tooltip: {
|
|
71
|
+
visible: true,
|
|
72
|
+
formatter: ({ data: point, series, y }) => `
|
|
73
|
+
<strong>${series.displayName}</strong>
|
|
74
|
+
<div>${point.month}: ${Number(y).toLocaleString()}k USD</div>
|
|
75
|
+
`
|
|
76
|
+
},
|
|
77
|
+
series: [
|
|
78
|
+
createLineSeries({
|
|
79
|
+
selector: 'revenue-line',
|
|
80
|
+
displayName: 'Revenue',
|
|
81
|
+
xField: 'month',
|
|
82
|
+
yField: 'revenue',
|
|
83
|
+
strokeWidth: 3,
|
|
84
|
+
curve: true,
|
|
85
|
+
dot: { radius: 4 }
|
|
86
|
+
}),
|
|
87
|
+
createLineSeries({
|
|
88
|
+
selector: 'target-line',
|
|
89
|
+
displayName: 'Target',
|
|
90
|
+
xField: 'month',
|
|
91
|
+
yField: 'target',
|
|
92
|
+
color: '#fbbf24',
|
|
93
|
+
strokeWidth: 2.5,
|
|
94
|
+
curve: true,
|
|
95
|
+
dot: { radius: 3, fill: '#fbbf24' }
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
chart.render();
|
|
101
|
+
|
|
102
|
+
window.addEventListener('resize', () => {
|
|
103
|
+
const panel = document.querySelector<HTMLElement>('.chart-panel');
|
|
104
|
+
if (!panel) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
chart.resize({
|
|
109
|
+
width: Math.max(panel.clientWidth - 48, 320),
|
|
110
|
+
height: 460
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
color-scheme: dark;
|
|
3
|
+
font-family:
|
|
4
|
+
Inter,
|
|
5
|
+
ui-sans-serif,
|
|
6
|
+
system-ui,
|
|
7
|
+
-apple-system,
|
|
8
|
+
BlinkMacSystemFont,
|
|
9
|
+
"Segoe UI",
|
|
10
|
+
sans-serif;
|
|
11
|
+
background: #0b1120;
|
|
12
|
+
color: #e5edf7;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
* {
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
body {
|
|
20
|
+
margin: 0;
|
|
21
|
+
min-width: 320px;
|
|
22
|
+
min-height: 100vh;
|
|
23
|
+
background:
|
|
24
|
+
radial-gradient(circle at 20% 10%, rgba(56, 189, 248, 0.18), transparent 32rem),
|
|
25
|
+
radial-gradient(circle at 80% 0%, rgba(251, 191, 36, 0.12), transparent 28rem),
|
|
26
|
+
#0b1120;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.page-shell {
|
|
30
|
+
width: min(1120px, calc(100vw - 32px));
|
|
31
|
+
margin: 0 auto;
|
|
32
|
+
padding: 40px 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.intro {
|
|
36
|
+
margin-bottom: 18px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.eyebrow {
|
|
40
|
+
margin: 0 0 8px;
|
|
41
|
+
color: #7dd3fc;
|
|
42
|
+
font-size: 12px;
|
|
43
|
+
font-weight: 700;
|
|
44
|
+
letter-spacing: 0.08em;
|
|
45
|
+
text-transform: uppercase;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
h1 {
|
|
49
|
+
margin: 0;
|
|
50
|
+
font-size: clamp(28px, 5vw, 52px);
|
|
51
|
+
line-height: 1.05;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.intro p:last-child {
|
|
55
|
+
margin: 12px 0 0;
|
|
56
|
+
color: #b8c5d6;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
code {
|
|
60
|
+
color: #fbbf24;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.chart-panel {
|
|
64
|
+
min-height: 520px;
|
|
65
|
+
padding: 24px;
|
|
66
|
+
border: 1px solid rgba(148, 163, 184, 0.24);
|
|
67
|
+
border-radius: 12px;
|
|
68
|
+
background: linear-gradient(145deg, rgba(15, 23, 42, 0.92), rgba(17, 24, 39, 0.82));
|
|
69
|
+
box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
#chart {
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 460px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
#chart .kchart-svg text {
|
|
78
|
+
font-family: inherit;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#chart .domain,
|
|
82
|
+
#chart .tick line {
|
|
83
|
+
stroke: rgba(203, 213, 225, 0.54);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#chart .tick text,
|
|
87
|
+
#chart .kchart-axis-title {
|
|
88
|
+
fill: #cbd5e1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#chart .kchart-title {
|
|
92
|
+
fill: #f8fafc;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
#chart .kchart-legend text {
|
|
96
|
+
fill: #dbeafe;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@media (max-width: 720px) {
|
|
100
|
+
.page-shell {
|
|
101
|
+
width: min(100vw - 20px, 1120px);
|
|
102
|
+
padding: 24px 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.chart-panel {
|
|
106
|
+
padding: 12px;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><title>KChart Multi Series Basic</title></head><body><main class="page-shell"><section class="intro"><p class="eyebrow">StackBlitz starter</p><h1>KChart Multi Series</h1><p>Mix SVG and Canvas series in one chart while sharing the same axes.</p></section><section class="chart-panel"><div id="chart"></div></section></main><script type="module" src="/src/main.ts"></script></body></html>
|