@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,9 @@
1
+ {
2
+ "name": "kchart-stackblitz-topology-basic",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": { "dev": "vite --host 0.0.0.0", "build": "tsc && vite build", "preview": "vite preview --host 0.0.0.0" },
7
+ "dependencies": { "@keneth80/k-chart": "^1.9.0" },
8
+ "devDependencies": { "typescript": "^6.0.3", "vite": "^7.2.7" }
9
+ }
@@ -0,0 +1,89 @@
1
+ import { createCustomSeries, createKChart } from '@keneth80/k-chart';
2
+ import './style.css';
3
+
4
+ type TopologyPoint = { label: string; x: number; value: number };
5
+
6
+ const topologySeries = createCustomSeries<TopologyPoint>({
7
+ selector: 'topology',
8
+ displayName: 'Topology',
9
+ render({ group, plotSize }) {
10
+ const groups = [
11
+ { id: 'TEST_CLEAN', x: 28, y: 24, members: ['C1', 'C4', 'D1', 'D2', 'C2', 'C3'], machines: ['M16-FW-01', 'M16-FW-02'] },
12
+ { id: 'TEST_CMP', x: 360, y: 24, members: ['D1', 'D2', 'C1', 'C2', 'C3', 'C4'], machines: ['M16-FW-02', 'M16-FW-03'] },
13
+ { id: 'TEST_IMP', x: 310, y: plotSize.height - 140, members: ['D1', 'D2', 'C1', 'C2', 'C3', 'C4'], machines: ['M16-FW-01', 'M16-FW-03'] },
14
+ { id: 'TEST_PHOTO', x: 650, y: plotSize.height - 140, members: ['D1', 'D2', 'C1', 'C2', 'C3', 'C4', 'C5'], machines: ['M16-FW-03', 'P3-Dummy-01', 'P3-Dummy-02'] }
15
+ ];
16
+ const machines = ['M16-FW-01', 'M16-FW-02', 'M16-FW-03', 'P3-Dummy-01', 'P3-Dummy-02'];
17
+ const machinePositions = new Map<string, { x: number; y: number }>();
18
+ const memberPositions: Array<{ id: string; group: string; machine: string; x: number; y: number }> = [];
19
+ const machineY = plotSize.height * 0.48;
20
+
21
+ group.selectAll('*').remove();
22
+ group.append('rect').attr('width', plotSize.width).attr('height', plotSize.height).style('fill', '#eef1f5');
23
+ const links = group.append('g');
24
+ const nodes = group.append('g');
25
+ const startX = plotSize.width / 2 - 300;
26
+ machines.forEach((machine, index) => machinePositions.set(machine, { x: startX + index * 150, y: machineY }));
27
+
28
+ groups.forEach((item) => {
29
+ const width = item.members.length * 44 + 24;
30
+ const top = item.y < machineY;
31
+ const frame = nodes.append('g').attr('data-group', item.id).attr('transform', `translate(${item.x},${item.y})`).style('cursor', 'pointer');
32
+ frame.append('rect').attr('class', 'frame').attr('width', width).attr('height', 110).attr('rx', 10).style('fill', '#dfe3e8').style('stroke', '#c6ccd5');
33
+ frame.append('text').attr('x', 14).attr('y', top ? 26 : 96).style('font-weight', 900).style('fill', '#111827').text(item.id);
34
+ item.members.forEach((member, index) => {
35
+ const machine = item.machines[index % item.machines.length];
36
+ const localX = 14 + index * 44;
37
+ const localY = top ? 40 : 12;
38
+ const node = frame.append('g').attr('data-member', `${item.id}-${member}`).style('cursor', 'pointer').attr('transform', `translate(${localX},${localY})`);
39
+ node.append('rect').attr('width', 34).attr('height', 58).attr('rx', 7).style('fill', '#fff').style('stroke', '#c6ccd5');
40
+ node.append('text').attr('x', 17).attr('y', 38).style('text-anchor', 'middle').style('fill', '#1f2937').text(member);
41
+ memberPositions.push({ id: `${item.id}-${member}`, group: item.id, machine, x: item.x + localX + 17, y: item.y + localY + (top ? 58 : 0) });
42
+ });
43
+ });
44
+
45
+ memberPositions.forEach((member) => {
46
+ const machine = machinePositions.get(member.machine);
47
+ if (!machine) return;
48
+ links.append('path').attr('data-group', member.group).attr('data-member', member.id).attr('data-machine', member.machine)
49
+ .attr('d', `M${member.x},${member.y} C${member.x},${(member.y + machine.y) / 2} ${machine.x},${(member.y + machine.y) / 2} ${machine.x},${machine.y}`)
50
+ .style('fill', 'none').style('stroke', '#8c8f94').style('stroke-width', 1).style('opacity', 0.72);
51
+ });
52
+
53
+ machines.forEach((machine) => {
54
+ const position = machinePositions.get(machine);
55
+ if (!position) return;
56
+ const node = nodes.append('g').attr('data-machine', machine).attr('transform', `translate(${position.x - 54},${position.y})`).style('cursor', 'pointer');
57
+ node.append('rect').attr('width', 108).attr('height', 64).attr('rx', 10).style('fill', '#fff').style('stroke', '#c6ccd5');
58
+ node.append('text').attr('x', 54).attr('y', 39).style('text-anchor', 'middle').style('font-weight', 900).style('fill', '#111827').text(machine);
59
+ });
60
+
61
+ const reset = () => {
62
+ group.selectAll('path').style('opacity', 0.72).style('stroke', '#8c8f94').style('stroke-width', 1);
63
+ group.selectAll('[data-group],[data-member],[data-machine]').style('opacity', 1);
64
+ };
65
+ const highlight = (attr: 'group' | 'member' | 'machine', id: string) => {
66
+ const activeGroups = new Set<string>();
67
+ const activeMembers = new Set<string>();
68
+ const activeMachines = new Set<string>();
69
+ group.selectAll<SVGPathElement, unknown>('path').style('opacity', function () {
70
+ const active = this.getAttribute(`data-${attr}`) === id;
71
+ if (active) {
72
+ activeGroups.add(this.getAttribute('data-group') ?? '');
73
+ activeMembers.add(this.getAttribute('data-member') ?? '');
74
+ activeMachines.add(this.getAttribute('data-machine') ?? '');
75
+ }
76
+ return active ? 1 : 0.12;
77
+ }).style('stroke', function () { return this.getAttribute(`data-${attr}`) === id ? '#0384fc' : '#8c8f94'; }).style('stroke-width', function () { return this.getAttribute(`data-${attr}`) === id ? 2 : 1; });
78
+ group.selectAll<SVGGElement, unknown>('[data-group]').style('opacity', function () { return activeGroups.has(this.getAttribute('data-group') ?? '') ? 1 : 0.28; });
79
+ group.selectAll<SVGGElement, unknown>('[data-member]').style('opacity', function () { return activeMembers.has(this.getAttribute('data-member') ?? '') ? 1 : 0.24; });
80
+ group.selectAll<SVGGElement, unknown>('[data-machine]').style('opacity', function () { return activeMachines.has(this.getAttribute('data-machine') ?? '') ? 1 : 0.28; });
81
+ };
82
+
83
+ group.selectAll<SVGGElement, unknown>('[data-group]').on('mouseenter', function () { highlight('group', this.getAttribute('data-group') ?? ''); }).on('mouseleave', reset);
84
+ group.selectAll<SVGGElement, unknown>('[data-member]').on('mouseenter', function (event) { event.stopPropagation(); highlight('member', this.getAttribute('data-member') ?? ''); }).on('mouseleave', reset);
85
+ group.selectAll<SVGGElement, unknown>('[data-machine]').on('mouseenter', function (event) { event.stopPropagation(); highlight('machine', this.getAttribute('data-machine') ?? ''); }).on('mouseleave', reset);
86
+ }
87
+ });
88
+
89
+ createKChart<TopologyPoint>({ selector: '#chart', data: [{ label: 'topology', x: 0, value: 0 }], width: 1320, height: 660, margin: { top: 10, right: 10, bottom: 10, left: 10 }, grid: { visible: false }, legend: { visible: false }, tooltip: { visible: false }, axes: [], series: [topologySeries] }).render();
@@ -0,0 +1 @@
1
+ :root{color-scheme:dark;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:#0b1120;color:#e5edf7}*{box-sizing:border-box}body{margin:0;min-width:320px;min-height:100vh;background:#0b1120}.page-shell{width:min(1400px,calc(100vw - 32px));margin:0 auto;padding:32px 0}.intro{margin-bottom:16px}.eyebrow{margin:0 0 8px;color:#7dd3fc;font-size:12px;font-weight:700;letter-spacing:.08em;text-transform:uppercase}h1{margin:0;font-size:clamp(28px,5vw,48px);line-height:1.05}.intro p:last-child{margin:12px 0 0;color:#b8c5d6}code{color:#fbbf24}.chart-panel{overflow:auto;min-height:720px;padding:16px;border:1px solid rgba(148,163,184,.24);border-radius:12px;background:linear-gradient(145deg,rgba(15,23,42,.92),rgba(17,24,39,.82))}#chart{width:1320px;height:660px}
@@ -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 WebGL Line 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 WebGL Line</h1>
13
+ <p>Edit <code>src/main.ts</code> to experiment with high-density WebGL traces.</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>