@keneth80/k-chart 1.9.0 → 1.10.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +204 -1
  3. package/docs/assets/kchart-hero.svg +110 -0
  4. package/docs/assets/kchart-icon.svg +40 -0
  5. package/docs/configuration-reference.md +395 -0
  6. package/docs/functional-api.md +103 -3
  7. package/examples/stackblitz-candlestick-basic/index.html +23 -0
  8. package/examples/stackblitz-candlestick-basic/package-lock.json +1435 -0
  9. package/examples/stackblitz-candlestick-basic/package.json +18 -0
  10. package/examples/stackblitz-candlestick-basic/src/main.ts +107 -0
  11. package/examples/stackblitz-candlestick-basic/src/style.css +16 -0
  12. package/examples/stackblitz-canvas-line-basic/index.html +23 -0
  13. package/examples/stackblitz-canvas-line-basic/package-lock.json +1435 -0
  14. package/examples/stackblitz-canvas-line-basic/package.json +18 -0
  15. package/examples/stackblitz-canvas-line-basic/src/main.ts +73 -0
  16. package/examples/stackblitz-canvas-line-basic/src/style.css +46 -0
  17. package/examples/stackblitz-column-basic/index.html +23 -0
  18. package/examples/stackblitz-column-basic/package-lock.json +1435 -0
  19. package/examples/stackblitz-column-basic/package.json +18 -0
  20. package/examples/stackblitz-column-basic/src/main.ts +128 -0
  21. package/examples/stackblitz-column-basic/src/style.css +41 -0
  22. package/examples/stackblitz-doughnut-basic/index.html +21 -0
  23. package/examples/stackblitz-doughnut-basic/package-lock.json +1435 -0
  24. package/examples/stackblitz-doughnut-basic/package.json +18 -0
  25. package/examples/stackblitz-doughnut-basic/src/main.ts +177 -0
  26. package/examples/stackblitz-doughnut-basic/src/style.css +43 -0
  27. package/examples/stackblitz-line-basic/index.html +23 -0
  28. package/examples/stackblitz-line-basic/package-lock.json +1435 -0
  29. package/examples/stackblitz-line-basic/package.json +18 -0
  30. package/examples/stackblitz-line-basic/src/main.ts +112 -0
  31. package/examples/stackblitz-line-basic/src/style.css +108 -0
  32. package/examples/stackblitz-multi-series-basic/index.html +1 -0
  33. package/examples/stackblitz-multi-series-basic/package-lock.json +1435 -0
  34. package/examples/stackblitz-multi-series-basic/package.json +9 -0
  35. package/examples/stackblitz-multi-series-basic/src/main.ts +29 -0
  36. package/examples/stackblitz-multi-series-basic/src/style.css +1 -0
  37. package/examples/stackblitz-options-basic/index.html +1 -0
  38. package/examples/stackblitz-options-basic/package-lock.json +1435 -0
  39. package/examples/stackblitz-options-basic/package.json +9 -0
  40. package/examples/stackblitz-options-basic/src/main.ts +32 -0
  41. package/examples/stackblitz-options-basic/src/style.css +1 -0
  42. package/examples/stackblitz-pie-basic/index.html +21 -0
  43. package/examples/stackblitz-pie-basic/package-lock.json +1435 -0
  44. package/examples/stackblitz-pie-basic/package.json +18 -0
  45. package/examples/stackblitz-pie-basic/src/main.ts +156 -0
  46. package/examples/stackblitz-pie-basic/src/style.css +43 -0
  47. package/examples/stackblitz-plot-basic/index.html +1 -0
  48. package/examples/stackblitz-plot-basic/package-lock.json +1435 -0
  49. package/examples/stackblitz-plot-basic/package.json +9 -0
  50. package/examples/stackblitz-plot-basic/src/main.ts +32 -0
  51. package/examples/stackblitz-plot-basic/src/style.css +1 -0
  52. package/examples/stackblitz-radial-basic/index.html +21 -0
  53. package/examples/stackblitz-radial-basic/package-lock.json +1435 -0
  54. package/examples/stackblitz-radial-basic/package.json +18 -0
  55. package/examples/stackblitz-radial-basic/src/main.ts +223 -0
  56. package/examples/stackblitz-radial-basic/src/style.css +87 -0
  57. package/examples/stackblitz-simple-api-basic/index.html +30 -0
  58. package/examples/stackblitz-simple-api-basic/package-lock.json +1435 -0
  59. package/examples/stackblitz-simple-api-basic/package.json +18 -0
  60. package/examples/stackblitz-simple-api-basic/src/main.ts +69 -0
  61. package/examples/stackblitz-simple-api-basic/src/style.css +127 -0
  62. package/examples/stackblitz-stacked-column-basic/index.html +23 -0
  63. package/examples/stackblitz-stacked-column-basic/package-lock.json +1435 -0
  64. package/examples/stackblitz-stacked-column-basic/package.json +18 -0
  65. package/examples/stackblitz-stacked-column-basic/src/main.ts +136 -0
  66. package/examples/stackblitz-stacked-column-basic/src/style.css +16 -0
  67. package/examples/stackblitz-three-wafer-basic/index.html +1 -0
  68. package/examples/stackblitz-three-wafer-basic/package-lock.json +1453 -0
  69. package/examples/stackblitz-three-wafer-basic/package.json +9 -0
  70. package/examples/stackblitz-three-wafer-basic/src/main.ts +29 -0
  71. package/examples/stackblitz-three-wafer-basic/src/style.css +1 -0
  72. package/examples/stackblitz-topology-basic/index.html +1 -0
  73. package/examples/stackblitz-topology-basic/package-lock.json +1435 -0
  74. package/examples/stackblitz-topology-basic/package.json +9 -0
  75. package/examples/stackblitz-topology-basic/src/main.ts +89 -0
  76. package/examples/stackblitz-topology-basic/src/style.css +1 -0
  77. package/examples/stackblitz-webgl-line-basic/index.html +23 -0
  78. package/examples/stackblitz-webgl-line-basic/package-lock.json +1435 -0
  79. package/examples/stackblitz-webgl-line-basic/package.json +18 -0
  80. package/examples/stackblitz-webgl-line-basic/src/main.ts +86 -0
  81. package/examples/stackblitz-webgl-line-basic/src/style.css +46 -0
  82. package/examples/stackblitz-worker-json-line/index.html +41 -0
  83. package/examples/stackblitz-worker-json-line/package-lock.json +1435 -0
  84. package/examples/stackblitz-worker-json-line/package.json +19 -0
  85. package/examples/stackblitz-worker-json-line/public/data/large-line.json +4322 -0
  86. package/examples/stackblitz-worker-json-line/src/kchart-render.worker.ts +4 -0
  87. package/examples/stackblitz-worker-json-line/src/main.ts +185 -0
  88. package/examples/stackblitz-worker-json-line/src/style.css +101 -0
  89. package/lib/core/contracts.d.ts +22 -0
  90. package/lib/core/contracts.d.ts.map +1 -1
  91. package/lib/core/create-kchart.d.ts.map +1 -1
  92. package/lib/core/create-kchart.js +93 -4
  93. package/lib/core/create-kchart.js.map +1 -1
  94. package/lib/index.d.ts +1 -0
  95. package/lib/index.d.ts.map +1 -1
  96. package/lib/index.js +1 -0
  97. package/lib/index.js.map +1 -1
  98. package/lib/kchart.d.ts +1 -0
  99. package/lib/kchart.d.ts.map +1 -1
  100. package/lib/kchart.js +1 -0
  101. package/lib/kchart.js.map +1 -1
  102. package/lib/presets/index.d.ts +97 -0
  103. package/lib/presets/index.d.ts.map +1 -0
  104. package/lib/presets/index.js +481 -0
  105. package/lib/presets/index.js.map +1 -0
  106. package/lib/series/canvas-line.d.ts.map +1 -1
  107. package/lib/series/canvas-line.js +16 -11
  108. package/lib/series/canvas-line.js.map +1 -1
  109. package/lib/series/svg-line.d.ts.map +1 -1
  110. package/lib/series/svg-line.js +19 -3
  111. package/lib/series/svg-line.js.map +1 -1
  112. package/lib/series/webgl-line.d.ts.map +1 -1
  113. package/lib/series/webgl-line.js +10 -3
  114. package/lib/series/webgl-line.js.map +1 -1
  115. package/package.json +13 -2
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "kchart-stackblitz-simple-api-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,69 @@
1
+ import {
2
+ chartConfig,
3
+ createLineChart
4
+ } from '@keneth80/k-chart';
5
+ import './style.css';
6
+
7
+ interface SalesPoint {
8
+ month: string;
9
+ revenue: number;
10
+ orders: number;
11
+ }
12
+
13
+ const data: SalesPoint[] = [
14
+ { month: 'Jan', revenue: 42, orders: 320 },
15
+ { month: 'Feb', revenue: 48, orders: 360 },
16
+ { month: 'Mar', revenue: 45, orders: 340 },
17
+ { month: 'Apr', revenue: 58, orders: 420 },
18
+ { month: 'May', revenue: 64, orders: 480 },
19
+ { month: 'Jun', revenue: 62, orders: 450 },
20
+ { month: 'Jul', revenue: 74, orders: 520 },
21
+ { month: 'Aug', revenue: 81, orders: 590 }
22
+ ];
23
+
24
+ const lineChart = createLineChart<SalesPoint>({
25
+ selector: '#line-chart',
26
+ data,
27
+ x: { field: 'month', type: 'point', title: 'Month' },
28
+ y: { field: 'revenue', type: 'number', title: 'Revenue', min: 30 },
29
+ title: 'Revenue Trend',
30
+ color: '#5db8ff',
31
+ curve: true,
32
+ dot: { radius: 4 },
33
+ animation: { enabled: true, duration: 820 },
34
+ tooltip: {
35
+ visible: true,
36
+ formatter: ({ data: point }) => `<strong>${point.month}</strong><br/>Revenue: ${point.revenue}k`
37
+ }
38
+ });
39
+
40
+ const columnChart = chartConfig<SalesPoint>(data)
41
+ .selector('#column-chart')
42
+ .title('Orders By Month')
43
+ .x('month', 'point', { title: 'Month' })
44
+ .y('orders', 'number', { title: 'Orders', min: 250 })
45
+ .column({
46
+ displayName: 'Orders',
47
+ color: '#56d08f',
48
+ barRadius: 6
49
+ })
50
+ .tooltip({
51
+ visible: true,
52
+ formatter: ({ data: point }) => `<strong>${point.month}</strong><br/>Orders: ${point.orders}`
53
+ })
54
+ .animation({ enabled: true, duration: 760 })
55
+ .render();
56
+
57
+ window.addEventListener('resize', () => {
58
+ const linePanel = document.querySelector<HTMLElement>('#line-chart');
59
+ const columnPanel = document.querySelector<HTMLElement>('#column-chart');
60
+
61
+ lineChart.resize({
62
+ width: Math.max(linePanel?.clientWidth ?? 320, 320),
63
+ height: 360
64
+ });
65
+ columnChart.resize({
66
+ width: Math.max(columnPanel?.clientWidth ?? 320, 320),
67
+ height: 360
68
+ });
69
+ });
@@ -0,0 +1,127 @@
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 18% 12%, rgba(93, 184, 255, 0.2), transparent 32rem),
25
+ radial-gradient(circle at 82% 4%, rgba(86, 208, 143, 0.14), transparent 28rem),
26
+ #0b1120;
27
+ }
28
+
29
+ .page-shell {
30
+ width: min(1180px, 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: 800;
44
+ letter-spacing: 0.08em;
45
+ text-transform: uppercase;
46
+ }
47
+
48
+ h1 {
49
+ margin: 0;
50
+ font-size: clamp(30px, 5vw, 52px);
51
+ line-height: 1.05;
52
+ }
53
+
54
+ h2 {
55
+ margin: 0 0 14px;
56
+ color: #f8fafc;
57
+ font-size: 16px;
58
+ }
59
+
60
+ .intro p:last-child {
61
+ margin: 12px 0 0;
62
+ color: #b8c5d6;
63
+ }
64
+
65
+ code {
66
+ color: #fbbf24;
67
+ }
68
+
69
+ .chart-grid {
70
+ display: grid;
71
+ grid-template-columns: repeat(2, minmax(0, 1fr));
72
+ gap: 18px;
73
+ }
74
+
75
+ .chart-panel {
76
+ min-height: 430px;
77
+ padding: 22px;
78
+ border: 1px solid rgba(148, 163, 184, 0.24);
79
+ border-radius: 12px;
80
+ background: linear-gradient(145deg, rgba(15, 23, 42, 0.94), rgba(17, 24, 39, 0.84));
81
+ box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
82
+ }
83
+
84
+ #line-chart,
85
+ #column-chart {
86
+ width: 100%;
87
+ height: 360px;
88
+ }
89
+
90
+ .kchart-svg text {
91
+ font-family: inherit;
92
+ }
93
+
94
+ .domain,
95
+ .tick line {
96
+ stroke: rgba(203, 213, 225, 0.54);
97
+ }
98
+
99
+ .tick text,
100
+ .kchart-axis-title {
101
+ fill: #cbd5e1;
102
+ }
103
+
104
+ .kchart-title {
105
+ fill: #f8fafc;
106
+ }
107
+
108
+ .kchart-legend text {
109
+ fill: #dbeafe;
110
+ }
111
+
112
+ @media (max-width: 860px) {
113
+ .chart-grid {
114
+ grid-template-columns: 1fr;
115
+ }
116
+ }
117
+
118
+ @media (max-width: 720px) {
119
+ .page-shell {
120
+ width: min(100vw - 20px, 1180px);
121
+ padding: 24px 0;
122
+ }
123
+
124
+ .chart-panel {
125
+ padding: 12px;
126
+ }
127
+ }
@@ -0,0 +1,23 @@
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 Stacked Column Basic</title>
7
+ </head>
8
+ <body>
9
+ <main class="page-shell">
10
+ <section class="intro">
11
+ <p class="eyebrow">StackBlitz starter</p>
12
+ <h1>KChart Stacked Column</h1>
13
+ <p>Edit <code>src/main.ts</code> to customize stacked segments and tooltip content.</p>
14
+ </section>
15
+
16
+ <section class="chart-panel">
17
+ <div id="chart"></div>
18
+ </section>
19
+ </main>
20
+
21
+ <script type="module" src="/src/main.ts"></script>
22
+ </body>
23
+ </html>