chartai 0.1.0 → 1.0.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 (78) hide show
  1. package/dist/chart-library.d.ts +33 -146
  2. package/dist/chart-library.d.ts.map +1 -1
  3. package/dist/chart-library.js +378 -321
  4. package/dist/chart-library.min.js +1 -1
  5. package/dist/charts/area.d.ts +6 -0
  6. package/dist/charts/area.d.ts.map +1 -0
  7. package/dist/charts/area.js +65 -0
  8. package/dist/charts/area.min.js +1 -0
  9. package/dist/charts/bar.d.ts +11 -0
  10. package/dist/charts/bar.d.ts.map +1 -0
  11. package/dist/charts/bar.js +65 -0
  12. package/dist/charts/bar.min.js +1 -0
  13. package/dist/charts/boids.js +167 -0
  14. package/dist/charts/boids.min.js +18 -0
  15. package/dist/charts/candlestick.d.ts +21 -0
  16. package/dist/charts/candlestick.d.ts.map +1 -0
  17. package/dist/charts/candlestick.js +132 -0
  18. package/dist/charts/candlestick.min.js +32 -0
  19. package/dist/charts/line.d.ts +12 -0
  20. package/dist/charts/line.d.ts.map +1 -0
  21. package/dist/charts/line.js +62 -0
  22. package/dist/charts/line.min.js +1 -0
  23. package/dist/charts/scatter.d.ts +11 -0
  24. package/dist/charts/scatter.d.ts.map +1 -0
  25. package/dist/charts/scatter.js +46 -0
  26. package/dist/charts/scatter.min.js +1 -0
  27. package/dist/chunk-0jepamv9.js +7 -0
  28. package/dist/chunk-1p45ex5n.min.js +2 -0
  29. package/dist/chunk-831dem4f.js +4 -0
  30. package/dist/chunk-93yrr7er.js +35 -0
  31. package/dist/chunk-94kc81rr.min.js +2 -0
  32. package/dist/chunk-a27be8p9.js +105 -0
  33. package/dist/chunk-bfyv7z27.min.js +2 -0
  34. package/dist/chunk-dmaxrg6s.min.js +2 -0
  35. package/dist/chunk-e7d3zgw5.min.js +2 -0
  36. package/dist/chunk-g6m56ptf.js +609 -0
  37. package/dist/chunk-m17t3vjq.js +9 -0
  38. package/dist/chunk-me3qaz3m.min.js +2 -0
  39. package/dist/chunk-qr6mweck.min.js +2 -0
  40. package/dist/chunk-yabjrff2.js +11 -0
  41. package/dist/gpu-worker.js +625 -686
  42. package/dist/gpu-worker.min.js +1 -1
  43. package/dist/msg.d.ts +33 -0
  44. package/dist/msg.d.ts.map +1 -0
  45. package/dist/plugins/coords.d.ts +18 -0
  46. package/dist/plugins/coords.d.ts.map +1 -0
  47. package/dist/plugins/hover.d.ts +15 -2
  48. package/dist/plugins/hover.d.ts.map +1 -1
  49. package/dist/plugins/hover.js +92 -13
  50. package/dist/plugins/hover.min.js +1 -1
  51. package/dist/plugins/labels-panel.d.ts +4 -0
  52. package/dist/plugins/labels-panel.d.ts.map +1 -0
  53. package/dist/plugins/labels-panel.js +122 -0
  54. package/dist/plugins/labels-panel.min.js +1 -0
  55. package/dist/plugins/labels.d.ts +17 -2
  56. package/dist/plugins/labels.d.ts.map +1 -1
  57. package/dist/plugins/labels.js +11 -99
  58. package/dist/plugins/labels.min.js +1 -1
  59. package/dist/plugins/legend.d.ts +16 -0
  60. package/dist/plugins/legend.d.ts.map +1 -0
  61. package/dist/plugins/legend.js +282 -0
  62. package/dist/plugins/legend.min.js +21 -0
  63. package/dist/plugins/shared.d.ts +7 -0
  64. package/dist/plugins/shared.d.ts.map +1 -0
  65. package/dist/plugins/zoom.d.ts +10 -2
  66. package/dist/plugins/zoom.d.ts.map +1 -1
  67. package/dist/plugins/zoom.js +63 -62
  68. package/dist/plugins/zoom.min.js +1 -1
  69. package/dist/types.d.ts +179 -0
  70. package/dist/types.d.ts.map +1 -0
  71. package/dist/types.js +0 -0
  72. package/dist/types.min.js +0 -0
  73. package/dist/worker-inline.d.ts +1 -1
  74. package/dist/worker-inline.d.ts.map +1 -1
  75. package/package.json +11 -11
  76. package/readme.md +51 -42
  77. package/dist/chunk-bgfkgcmg.js +0 -25
  78. package/dist/chunk-cj3zanvs.min.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chartai",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "description": "tiny gpu powered charts",
5
5
  "type": "module",
6
6
  "main": "./dist/chart-library.js",
@@ -11,21 +11,21 @@
11
11
  "types": "./dist/chart-library.d.ts",
12
12
  "default": "./dist/chart-library.js"
13
13
  },
14
+ "./types": {
15
+ "types": "./dist/types.d.ts",
16
+ "default": "./dist/types.js"
17
+ },
14
18
  "./worker": {
15
19
  "types": "./dist/gpu-worker.d.ts",
16
20
  "default": "./dist/gpu-worker.js"
17
21
  },
18
- "./plugins/hover": {
19
- "types": "./dist/plugins/hover.d.ts",
20
- "default": "./dist/plugins/hover.js"
21
- },
22
- "./plugins/labels": {
23
- "types": "./dist/plugins/labels.d.ts",
24
- "default": "./dist/plugins/labels.js"
22
+ "./plugins/*": {
23
+ "types": "./dist/plugins/*.d.ts",
24
+ "default": "./dist/plugins/*.js"
25
25
  },
26
- "./plugins/zoom": {
27
- "types": "./dist/plugins/zoom.d.ts",
28
- "default": "./dist/plugins/zoom.js"
26
+ "./charts/*": {
27
+ "types": "./dist/charts/*.d.ts",
28
+ "default": "./dist/charts/*.js"
29
29
  }
30
30
  },
31
31
  "files": [
package/readme.md CHANGED
@@ -1,41 +1,45 @@
1
- # ChartAI
1
+ # chartai
2
2
 
3
- Are you looking for a simple tiny little chart library which can draw as many lines and points across as many charts as you have vram? Look no further.
3
+ Are you looking for a simple tiny little chart library which can draw as many lines and points as you have vram? Look no further.
4
4
 
5
- ChartAI is an ai powered chart library which can draw millions and millions of lines across hundreds at 60fps. But like good engineers we only draw when we need to saving battery life.
5
+ chartai is a library that can draw millions and millions of lines across thousands of series wickedly fast. It uses a passive rendering system that only update charts when needed. It lives in a web worker keeping the main thread free. It is fully pluggable so you only take way you need or add what's missing.
6
6
 
7
7
  * **[Examples](https://dgerrells.github.io/chartai/)**
8
8
  * **[Playground](https://dgerrells.github.io/chartai/demo/)**
9
- * **[Real data canvas demo](https://dgerrells.github.io/chartai/canvas/)**
9
+ * **[Silly overly complicated demo](https://dgerrells.github.io/chartai/canvas/)**
10
10
 
11
- Why ChartAI?
11
+ ## Why chartai?
12
12
 
13
- * Tiny, unlimited charts at ~11kb, plugins make it ~15kb
13
+ This library was inspired by uplot which is likely all you need. But if you do need the performance without the bundle bloat, this may do it.
14
+
15
+ * Tiny, unlimited line charts at ~11kb
14
16
  * Customizable with plugins
15
- * Lines, scatter, and bars
17
+ * Lines, scatter, bar, adn candlestick out of the box
16
18
  * Chart synchronization
17
19
  * Stupid faster compute shaders
18
20
  * Passively rendered, automatic virtualization
19
21
  * Doesn't miss the spikes in data, unless you want it to
20
- * Simple api
21
22
 
22
- ### Add a line chart.
23
+ Cool. How do I use it?
24
+
25
+ ### Add a line chart
23
26
 
24
27
  ```js
25
28
  import { ChartManager } from 'chartai';
29
+ import { LineChart } from 'chartai/charts/line';
26
30
 
27
- const manager = ChartManager.getInstance();
28
- await manager.init();
31
+ ChartManager.use(LineChart);
32
+ await ChartManager.init();
29
33
 
30
34
  const x = Array.from({ length: 100 }, (_, i) => i);
31
35
  const y = x.map(v => Math.sin(v * 0.1) * 50 + 50);
32
36
 
33
- const chartId = manager.create({
37
+ const chart = ChartManager.create({
34
38
  type: 'line',
35
39
  container: document.getElementById('chart'),
36
40
  series: [{
37
41
  label: 'My Data',
38
- color: { r: 0.4, g: 0.6, b: 1 },
42
+ color: 'oklab(0.65 0.15 -0.2)',
39
43
  x,
40
44
  y
41
45
  }],
@@ -45,52 +49,53 @@ const chartId = manager.create({
45
49
  ### Plugins
46
50
 
47
51
  ```js
48
- import { ChartManager, registerPlugin } from 'chartai';
49
- import { zoomPlugin } from 'chartai/plugins/zoom';
52
+ import { ChartManager } from 'chartai';
53
+ import { labelsPlugin } from 'chartai/plugins/labels';
50
54
  import { hoverPlugin } from 'chartai/plugins/hover';
51
55
 
52
- registerPlugin(zoomPlugin());
53
- registerPlugin(hoverPlugin);
56
+ ChartManager.use(zoomPlugin);
57
+ ChartManager.use(hoverPlugin);
54
58
  ```
55
59
 
56
- ### React weirdos
60
+ ### Agnostic
61
+
62
+ It is pure js. Add it to your favorite framework.
57
63
 
58
64
  ```js
59
65
  import { useEffect, useRef } from 'react';
60
- import { ChartManager, registerPlugin } from 'chartai';
66
+ import { ChartManager } from 'chartai';
67
+ import { LineChart } from 'chartai/charts/line';
61
68
  import { zoomPlugin } from 'chartai/plugins/zoom';
62
69
  import { hoverPlugin } from 'chartai/plugins/hover';
63
70
  import { labelsPlugin } from 'chartai/plugins/labels';
64
71
 
65
72
  function Chart() {
66
73
  const ref = useRef(null);
67
- const chartIdRef = useRef(null);
74
+ const chartRef = useRef(null);
68
75
 
69
76
  useEffect(() => {
70
- registerPlugin(labelsPlugin);
71
- registerPlugin(zoomPlugin());
72
- registerPlugin(hoverPlugin);
77
+ ChartManager.use(LineChart);
78
+ ChartManager.use(labelsPlugin);
79
+ ChartManager.use(zoomPlugin());
80
+ ChartManager.use(hoverPlugin);
73
81
 
74
- const manager = ChartManager.getInstance();
75
- manager.init().then(() => {
82
+ ChartManager.init().then(() => {
76
83
  const x = Array.from({ length: 100 }, (_, i) => i);
77
84
  const y = x.map(v => Math.sin(v * 0.1) * 50 + 50);
78
85
 
79
- chartIdRef.current = manager.create({
86
+ chartRef.current = ChartManager.create({
80
87
  type: 'line',
81
88
  container: ref.current,
82
- series: [{ label: 'My Data', color: { r: 0.4, g: 0.6, b: 1 }, x, y }],
89
+ series: [{ label: 'My Data', color: '#ffffff', x, y }],
83
90
  zoomMode: 'both',
84
91
  showTooltip: true
85
92
  });
86
93
 
87
- manager.setZoomMode(chartIdRef.current, 'x-only');
94
+ chartRef.current.configure({ zoomMode: 'x-only' });
88
95
  });
89
96
 
90
97
  return () => {
91
- if (chartIdRef.current) {
92
- manager.destroy(chartIdRef.current);
93
- }
98
+ chartRef.current?.destroy();
94
99
  };
95
100
  }, []);
96
101
 
@@ -100,16 +105,20 @@ function Chart() {
100
105
 
101
106
  ## Design
102
107
 
103
- I need to draw lots of lines, points, boxes whatever on multiple (2o+) charts where the view port is synchronized. The solution is to have a web worker generating frames via compute shaders. This allows for almost unlimited charts. As many as you can fit on the screen. Data scale depends on hardware but an m1 can push it at 60fps until ram runs out.
108
+ A little layer communicates with a web worker that does all the web gpu rendering. The design is pretty simple. Everything is a plugin. Both charts and well, plugins. The best way to see how to write your own plugins and charts is to look at the ones that exist.
109
+
110
+ Yes, you can point an agent at the examples and it will understand it.
111
+
112
+ To demonstrate just how well it works there is a boids simulation chart where the chart data functions as starting locations for the boids. It is totally overkill and ridiculous and silly. It does show how powerful the framework is.
113
+
114
+ ## Gotchas
115
+
116
+ * WebGPU - this uses it so if it isn't there it will not work. No fallback is provided as the intent is for this library to be tiny and lean.
117
+ * Appending data - Updating data is plenty fast even with larger datasets but it could be smarter. It doesn't support having a larger buffer size and only sending updated data. It is a full update internally for now.
118
+ * Workers - The library will try and inline bundle the worker for maximum simplicity. If it fails, it will fallback to standard es worker loading.
119
+
120
+ ### Contribution
104
121
 
105
- ## Gotchas and missing features
122
+ I test using bun which handles most of the bundling out of the box.
106
123
 
107
- * appending or updating is stupid. Full reupload. There are ways you can fast copy on the gpu memory to smartly grow. At small sizes it is still butter.
108
- * Bar charts...i like these and will not change them. They may not fit your jib. Copypasta your own shader, this lib is tiny.
109
- * Webgpu is used. No compute shaders, no charts
110
- * missing line size option. I need to switch up to a post process option (works well and cheap) or use signed distance fields. Many benefits but complex.
111
- * triple layered canvas. The plugins allow for canvas drawing behind and in front of the chart via 2 extra canvases. I hate it. There is a way I think to use a single canvas but I am still trying to figure it out.
112
- * Decimation may not be to your liking.
113
- * Finding the closes data point is a little messy.
114
- * I fucking hate npm publishing so if you like this, best bet is to just copypasta whatever you want. Or point local AI at this repo cook.
115
- * AI help with human review. If you want your code free-range and hormone free, look elsewhere. This works for me.
124
+ You can start a server watching files by running `bun server.ts`.
@@ -1,25 +0,0 @@
1
- var __create = Object.create;
2
- var __getProtoOf = Object.getPrototypeOf;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __toESM = (mod, isNodeMode, target) => {
7
- target = mod != null ? __create(__getProtoOf(mod)) : {};
8
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
- for (let key of __getOwnPropNames(mod))
10
- if (!__hasOwnProp.call(to, key))
11
- __defProp(to, key, {
12
- get: () => mod[key],
13
- enumerable: true
14
- });
15
- return to;
16
- };
17
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
18
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
19
- }) : x)(function(x) {
20
- if (typeof require !== "undefined")
21
- return require.apply(this, arguments);
22
- throw Error('Dynamic require of "' + x + '" is not supported');
23
- });
24
-
25
- export { __toESM, __require };
@@ -1,2 +0,0 @@
1
- var g=Object.create;var{getPrototypeOf:h,defineProperty:f,getOwnPropertyNames:i}=Object;var j=Object.prototype.hasOwnProperty;var k=(a,c,b)=>{b=a!=null?g(h(a)):{};let d=c||!a||!a.__esModule?f(b,"default",{value:a,enumerable:!0}):b;for(let e of i(a))if(!j.call(d,e))f(d,e,{get:()=>a[e],enumerable:!0});return d};var l=((a)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(a,{get:(c,b)=>(typeof require!=="undefined"?require:c)[b]}):a)(function(a){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});
2
- export{k as b,l as c};