@keneth80/k-chart 1.21.0 → 1.23.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 (80) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +10 -24
  3. package/docs/configuration-reference.md +18 -0
  4. package/docs/functional-api.md +16 -0
  5. package/examples/stackblitz-area-basic/index.html +21 -0
  6. package/examples/stackblitz-area-basic/package-lock.json +1531 -0
  7. package/examples/stackblitz-area-basic/package.json +18 -0
  8. package/examples/stackblitz-area-basic/src/main.ts +65 -0
  9. package/examples/stackblitz-area-basic/src/style.css +83 -0
  10. package/examples/stackblitz-area-basic/src/vite-env.d.ts +1 -0
  11. package/examples/stackblitz-box-plot-basic/index.html +21 -0
  12. package/examples/stackblitz-box-plot-basic/package-lock.json +1531 -0
  13. package/examples/stackblitz-box-plot-basic/package.json +18 -0
  14. package/examples/stackblitz-box-plot-basic/src/main.ts +69 -0
  15. package/examples/stackblitz-box-plot-basic/src/style.css +83 -0
  16. package/examples/stackblitz-box-plot-basic/src/vite-env.d.ts +1 -0
  17. package/examples/stackblitz-bubble-basic/index.html +21 -0
  18. package/examples/stackblitz-bubble-basic/package-lock.json +1531 -0
  19. package/examples/stackblitz-bubble-basic/package.json +18 -0
  20. package/examples/stackblitz-bubble-basic/src/main.ts +64 -0
  21. package/examples/stackblitz-bubble-basic/src/style.css +83 -0
  22. package/examples/stackblitz-bubble-basic/src/vite-env.d.ts +1 -0
  23. package/examples/stackblitz-gauge-basic/index.html +21 -0
  24. package/examples/stackblitz-gauge-basic/package-lock.json +1531 -0
  25. package/examples/stackblitz-gauge-basic/package.json +18 -0
  26. package/examples/stackblitz-gauge-basic/src/main.ts +55 -0
  27. package/examples/stackblitz-gauge-basic/src/style.css +83 -0
  28. package/examples/stackblitz-gauge-basic/src/vite-env.d.ts +1 -0
  29. package/examples/stackblitz-grouped-column-basic/index.html +26 -0
  30. package/examples/stackblitz-grouped-column-basic/package-lock.json +1531 -0
  31. package/examples/stackblitz-grouped-column-basic/package.json +18 -0
  32. package/examples/stackblitz-grouped-column-basic/src/main.ts +61 -0
  33. package/examples/stackblitz-grouped-column-basic/src/style.css +83 -0
  34. package/examples/stackblitz-grouped-column-basic/src/vite-env.d.ts +1 -0
  35. package/examples/stackblitz-histogram-basic/index.html +21 -0
  36. package/examples/stackblitz-histogram-basic/package-lock.json +1531 -0
  37. package/examples/stackblitz-histogram-basic/package.json +18 -0
  38. package/examples/stackblitz-histogram-basic/src/main.ts +64 -0
  39. package/examples/stackblitz-histogram-basic/src/style.css +83 -0
  40. package/examples/stackblitz-histogram-basic/src/vite-env.d.ts +1 -0
  41. package/examples/stackblitz-horizontal-bar-basic/index.html +21 -0
  42. package/examples/stackblitz-horizontal-bar-basic/package-lock.json +1531 -0
  43. package/examples/stackblitz-horizontal-bar-basic/package.json +18 -0
  44. package/examples/stackblitz-horizontal-bar-basic/src/main.ts +58 -0
  45. package/examples/stackblitz-horizontal-bar-basic/src/style.css +83 -0
  46. package/examples/stackblitz-horizontal-bar-basic/src/vite-env.d.ts +1 -0
  47. package/examples/stackblitz-scatter-basic/index.html +21 -0
  48. package/examples/stackblitz-scatter-basic/package-lock.json +1531 -0
  49. package/examples/stackblitz-scatter-basic/package.json +18 -0
  50. package/examples/stackblitz-scatter-basic/src/main.ts +66 -0
  51. package/examples/stackblitz-scatter-basic/src/style.css +83 -0
  52. package/examples/stackblitz-scatter-basic/src/vite-env.d.ts +1 -0
  53. package/examples/stackblitz-three-constellation-basic/index.html +41 -0
  54. package/examples/stackblitz-three-constellation-basic/package-lock.json +1607 -0
  55. package/examples/stackblitz-three-constellation-basic/package.json +22 -0
  56. package/examples/stackblitz-three-constellation-basic/src/main.ts +374 -0
  57. package/examples/stackblitz-three-constellation-basic/src/style.css +173 -0
  58. package/examples/stackblitz-waterfall-basic/index.html +26 -0
  59. package/examples/stackblitz-waterfall-basic/package-lock.json +1531 -0
  60. package/examples/stackblitz-waterfall-basic/package.json +18 -0
  61. package/examples/stackblitz-waterfall-basic/src/main.ts +75 -0
  62. package/examples/stackblitz-waterfall-basic/src/style.css +83 -0
  63. package/examples/stackblitz-waterfall-basic/src/vite-env.d.ts +1 -0
  64. package/lib/core/axis-title.d.ts +23 -0
  65. package/lib/core/axis-title.d.ts.map +1 -0
  66. package/lib/core/axis-title.js +129 -0
  67. package/lib/core/axis-title.js.map +1 -0
  68. package/lib/core/contracts.d.ts +3 -0
  69. package/lib/core/contracts.d.ts.map +1 -1
  70. package/lib/core/create-kchart.d.ts +9 -0
  71. package/lib/core/create-kchart.d.ts.map +1 -1
  72. package/lib/core/create-kchart.js +130 -25
  73. package/lib/core/create-kchart.js.map +1 -1
  74. package/lib/presets/index.d.ts +2 -0
  75. package/lib/presets/index.d.ts.map +1 -1
  76. package/lib/presets/index.js.map +1 -1
  77. package/lib/series/support/canvas.d.ts.map +1 -1
  78. package/lib/series/support/canvas.js +68 -15
  79. package/lib/series/support/canvas.js.map +1 -1
  80. package/package.json +2 -2
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "kchart-stackblitz-scatter-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 --noEmit && vite build",
9
+ "preview": "vite preview --host 0.0.0.0"
10
+ },
11
+ "dependencies": {
12
+ "@keneth80/k-chart": "^1.22.0"
13
+ },
14
+ "devDependencies": {
15
+ "typescript": "^6.0.3",
16
+ "vite": "^7.2.7"
17
+ }
18
+ }
@@ -0,0 +1,66 @@
1
+ import {createKChart, createScatterSeries} from '@keneth80/k-chart';
2
+ import './style.css';
3
+
4
+ interface StudentResult {
5
+ student: string;
6
+ studyHours: number;
7
+ examScore: number;
8
+ cohort: 'Morning' | 'Evening';
9
+ }
10
+
11
+ const data: StudentResult[] = [
12
+ {student: 'Ari', studyHours: 3.5, examScore: 61, cohort: 'Evening'},
13
+ {student: 'Bea', studyHours: 4.2, examScore: 68, cohort: 'Morning'},
14
+ {student: 'Chen', studyHours: 5.1, examScore: 72, cohort: 'Morning'},
15
+ {student: 'Dara', studyHours: 5.8, examScore: 70, cohort: 'Evening'},
16
+ {student: 'Eli', studyHours: 6.4, examScore: 79, cohort: 'Morning'},
17
+ {student: 'Faye', studyHours: 7.1, examScore: 83, cohort: 'Evening'},
18
+ {student: 'Gus', studyHours: 7.7, examScore: 86, cohort: 'Morning'},
19
+ {student: 'Hana', studyHours: 8.2, examScore: 84, cohort: 'Evening'},
20
+ {student: 'Ivan', studyHours: 8.9, examScore: 91, cohort: 'Morning'},
21
+ {student: 'Jules', studyHours: 9.6, examScore: 94, cohort: 'Evening'},
22
+ {student: 'Kira', studyHours: 10.4, examScore: 96, cohort: 'Morning'},
23
+ {student: 'Leo', studyHours: 6.9, examScore: 76, cohort: 'Evening'}
24
+ ];
25
+
26
+ const scatterSeries = createScatterSeries<StudentResult>({
27
+ selector: 'study-results',
28
+ displayName: 'Student result',
29
+ xField: 'studyHours',
30
+ yField: 'examScore',
31
+ radius: 6,
32
+ fill: (point) => point.cohort === 'Morning' ? '#38bdf8' : '#34d399',
33
+ stroke: '#f8fafc',
34
+ strokeWidth: 1.5,
35
+ opacity: 0.9
36
+ });
37
+
38
+ const panel = document.querySelector<HTMLElement>('.chart-panel');
39
+ const chartHeight = 520;
40
+ const chartWidth = () => Math.max(320, Math.min(1040, (panel?.clientWidth ?? 980) - 48));
41
+
42
+ const chart = createKChart<StudentResult>({
43
+ selector: '#chart',
44
+ data,
45
+ width: chartWidth(),
46
+ height: chartHeight,
47
+ margin: {top: 76, right: 36, bottom: 62, left: 72},
48
+ title: {text: 'Focused study and final score', align: 'left', fontSize: 18},
49
+ grid: {visible: true, x: true, y: true, color: 'rgba(148, 163, 184, 0.18)', dasharray: '3 8'},
50
+ legend: {visible: false},
51
+ tooltip: {visible: true},
52
+ axes: [
53
+ {field: 'studyHours', type: 'number', placement: 'bottom', min: 2, max: 12, title: 'Study hours per week'},
54
+ {field: 'examScore', type: 'number', placement: 'left', min: 55, max: 100, title: 'Exam score'}
55
+ ],
56
+ series: [scatterSeries]
57
+ });
58
+
59
+ chart.render();
60
+
61
+ const resize = () => chart.resize({width: chartWidth(), height: chartHeight});
62
+ window.addEventListener('resize', resize);
63
+ window.addEventListener('beforeunload', () => {
64
+ window.removeEventListener('resize', resize);
65
+ chart.destroy();
66
+ });
@@ -0,0 +1,83 @@
1
+ :root {
2
+ color-scheme: dark;
3
+ font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
4
+ background: #090d13;
5
+ color: #e8eef7;
6
+ }
7
+
8
+ * { box-sizing: border-box; }
9
+
10
+ body {
11
+ margin: 0;
12
+ min-width: 320px;
13
+ min-height: 100vh;
14
+ background: #090d13;
15
+ }
16
+
17
+ .page-shell {
18
+ width: min(1120px, calc(100vw - 32px));
19
+ margin: 0 auto;
20
+ padding: 40px 0;
21
+ }
22
+
23
+ .intro { margin-bottom: 20px; }
24
+
25
+ .eyebrow {
26
+ margin: 0 0 8px;
27
+ color: #67e8f9;
28
+ font-size: 12px;
29
+ font-weight: 800;
30
+ letter-spacing: 0;
31
+ text-transform: uppercase;
32
+ }
33
+
34
+ h1 {
35
+ margin: 0;
36
+ color: #f8fafc;
37
+ font-size: 42px;
38
+ line-height: 1.08;
39
+ letter-spacing: 0;
40
+ }
41
+
42
+ .intro p:last-child {
43
+ max-width: 720px;
44
+ margin: 12px 0 0;
45
+ color: #aebdce;
46
+ line-height: 1.6;
47
+ }
48
+
49
+ .data-key {
50
+ display: flex;
51
+ flex-wrap: wrap;
52
+ gap: 16px;
53
+ margin: 0 0 16px;
54
+ color: #cbd5e1;
55
+ font-size: 13px;
56
+ font-weight: 700;
57
+ }
58
+
59
+ .data-key span { display: inline-flex; align-items: center; gap: 7px; }
60
+ .data-key i { width: 10px; height: 10px; border-radius: 2px; background: var(--key-color); }
61
+
62
+ .chart-panel {
63
+ min-height: 568px;
64
+ padding: 24px;
65
+ overflow: hidden;
66
+ border: 1px solid #263244;
67
+ border-radius: 8px;
68
+ background: #101722;
69
+ box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
70
+ }
71
+
72
+ #chart { width: 100%; height: 520px; }
73
+ #chart .kchart-svg text { font-family: inherit; }
74
+ #chart .domain, #chart .tick line { stroke: rgba(203, 213, 225, 0.42); }
75
+ #chart .tick text, #chart .kchart-axis-title { fill: #cbd5e1; }
76
+ #chart .kchart-title { fill: #f8fafc; }
77
+ #chart .kchart-legend text { fill: #dbeafe; }
78
+
79
+ @media (max-width: 720px) {
80
+ .page-shell { width: calc(100vw - 20px); padding: 24px 0; }
81
+ .chart-panel { min-height: 544px; padding: 12px; }
82
+ h1 { font-size: 32px; }
83
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,41 @@
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
+ <meta name="theme-color" content="#060b14" />
7
+ <title>KChart Three.js Aries</title>
8
+ </head>
9
+ <body>
10
+ <main class="page-shell">
11
+ <header class="intro">
12
+ <p class="eyebrow">KChart Three adapter</p>
13
+ <h1>Aries constellation</h1>
14
+ <p class="lede">Explore the ram's brightest stars in an interactive Three.js scene.</p>
15
+ </header>
16
+
17
+ <section class="constellation-panel" aria-label="Interactive Aries constellation">
18
+ <div class="panel-meta">
19
+ <div>
20
+ <span class="catalog-label">IAU constellation</span>
21
+ <strong>ARI / The Ram</strong>
22
+ </div>
23
+ <div class="sky-key" aria-hidden="true">
24
+ <span></span>
25
+ Northern sky
26
+ </div>
27
+ </div>
28
+
29
+ <div id="scene" class="scene-host"></div>
30
+
31
+ <div class="interaction-bar">
32
+ <p id="star-status" aria-live="polite">Drag to orbit. Scroll to zoom. Select a star.</p>
33
+ <p class="interaction-hint">5 stars / 4 links</p>
34
+ </div>
35
+ </section>
36
+ </main>
37
+
38
+ <script type="module" src="/src/main.ts"></script>
39
+ </body>
40
+ </html>
41
+