chartai 0.1.0 → 1.1.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/dist/chart-library.d.ts +34 -146
- package/dist/chart-library.d.ts.map +1 -1
- package/dist/chart-library.js +411 -322
- package/dist/chart-library.min.js +1 -1
- package/dist/charts/area.d.ts +6 -0
- package/dist/charts/area.d.ts.map +1 -0
- package/dist/charts/area.js +65 -0
- package/dist/charts/area.min.js +1 -0
- package/dist/charts/bar.d.ts +11 -0
- package/dist/charts/bar.d.ts.map +1 -0
- package/dist/charts/bar.js +65 -0
- package/dist/charts/bar.min.js +1 -0
- package/dist/charts/boids.js +167 -0
- package/dist/charts/boids.min.js +18 -0
- package/dist/charts/candlestick.d.ts +21 -0
- package/dist/charts/candlestick.d.ts.map +1 -0
- package/dist/charts/candlestick.js +10 -0
- package/dist/charts/candlestick.min.js +1 -0
- package/dist/charts/experimental/baseline-area.js +70 -0
- package/dist/charts/experimental/baseline-area.min.js +1 -0
- package/dist/charts/experimental/bubble.js +48 -0
- package/dist/charts/experimental/bubble.min.js +1 -0
- package/dist/charts/experimental/error-band.js +111 -0
- package/dist/charts/experimental/error-band.min.js +1 -0
- package/dist/charts/experimental/heatmap.js +69 -0
- package/dist/charts/experimental/heatmap.min.js +1 -0
- package/dist/charts/experimental/histogram.js +139 -0
- package/dist/charts/experimental/histogram.min.js +7 -0
- package/dist/charts/experimental/ohlc.js +132 -0
- package/dist/charts/experimental/ohlc.min.js +32 -0
- package/dist/charts/experimental/step.js +67 -0
- package/dist/charts/experimental/step.min.js +1 -0
- package/dist/charts/experimental/waterfall.js +121 -0
- package/dist/charts/experimental/waterfall.min.js +7 -0
- package/dist/charts/line.d.ts +12 -0
- package/dist/charts/line.d.ts.map +1 -0
- package/dist/charts/line.js +62 -0
- package/dist/charts/line.min.js +1 -0
- package/dist/charts/scatter.d.ts +11 -0
- package/dist/charts/scatter.d.ts.map +1 -0
- package/dist/charts/scatter.js +46 -0
- package/dist/charts/scatter.min.js +1 -0
- package/dist/chunk-0eh4rzy9.min.js +2 -0
- package/dist/chunk-0jepamv9.js +7 -0
- package/dist/chunk-1ngxm8t2.js +129 -0
- package/dist/chunk-50bcv2hw.min.js +2 -0
- package/dist/chunk-5gtx3pza.js +9 -0
- package/dist/chunk-64q9a7nw.min.js +2 -0
- package/dist/chunk-831dem4f.js +4 -0
- package/dist/chunk-93yrr7er.js +35 -0
- package/dist/chunk-bbyt23tw.min.js +2 -0
- package/dist/chunk-cbydth3q.min.js +2 -0
- package/dist/chunk-cvtt04m6.min.js +2 -0
- package/dist/chunk-g2qmt43n.min.js +33 -0
- package/dist/chunk-gm0d4cgx.min.js +2 -0
- package/dist/chunk-mmsy3yqt.js +27 -0
- package/dist/chunk-n8ew0z0e.js +637 -0
- package/dist/chunk-t0kdz02m.js +129 -0
- package/dist/chunk-wdfq2fpx.min.js +2 -0
- package/dist/chunk-yabjrff2.js +11 -0
- package/dist/gpu-worker.js +630 -686
- package/dist/gpu-worker.min.js +1 -1
- package/dist/msg.d.ts +33 -0
- package/dist/msg.d.ts.map +1 -0
- package/dist/plugins/coords.d.ts +18 -0
- package/dist/plugins/coords.d.ts.map +1 -0
- package/dist/plugins/experimental/annotations.js +164 -0
- package/dist/plugins/experimental/annotations.min.js +1 -0
- package/dist/plugins/experimental/crosshair.js +82 -0
- package/dist/plugins/experimental/crosshair.min.js +1 -0
- package/dist/plugins/experimental/minimap.js +190 -0
- package/dist/plugins/experimental/minimap.min.js +1 -0
- package/dist/plugins/experimental/range-selector.js +220 -0
- package/dist/plugins/experimental/range-selector.min.js +1 -0
- package/dist/plugins/experimental/ruler.js +434 -0
- package/dist/plugins/experimental/ruler.min.js +59 -0
- package/dist/plugins/experimental/stats.js +229 -0
- package/dist/plugins/experimental/stats.min.js +8 -0
- package/dist/plugins/experimental/threshold.js +96 -0
- package/dist/plugins/experimental/threshold.min.js +1 -0
- package/dist/plugins/experimental/tooltip-pin.js +177 -0
- package/dist/plugins/experimental/tooltip-pin.min.js +1 -0
- package/dist/plugins/experimental/watermark.js +76 -0
- package/dist/plugins/experimental/watermark.min.js +1 -0
- package/dist/plugins/hover.d.ts +15 -2
- package/dist/plugins/hover.d.ts.map +1 -1
- package/dist/plugins/hover.js +75 -14
- package/dist/plugins/hover.min.js +1 -1
- package/dist/plugins/labels-panel.d.ts +4 -0
- package/dist/plugins/labels-panel.d.ts.map +1 -0
- package/dist/plugins/labels-panel.js +122 -0
- package/dist/plugins/labels-panel.min.js +1 -0
- package/dist/plugins/labels.d.ts +17 -2
- package/dist/plugins/labels.d.ts.map +1 -1
- package/dist/plugins/labels.js +11 -99
- package/dist/plugins/labels.min.js +1 -1
- package/dist/plugins/legend.d.ts +16 -0
- package/dist/plugins/legend.d.ts.map +1 -0
- package/dist/plugins/legend.js +353 -0
- package/dist/plugins/legend.min.js +37 -0
- package/dist/plugins/shared.d.ts +7 -0
- package/dist/plugins/shared.d.ts.map +1 -0
- package/dist/plugins/zoom.d.ts +10 -2
- package/dist/plugins/zoom.d.ts.map +1 -1
- package/dist/plugins/zoom.js +63 -62
- package/dist/plugins/zoom.min.js +1 -1
- package/dist/types.d.ts +187 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +0 -0
- package/dist/types.min.js +0 -0
- package/dist/worker-inline.d.ts +1 -1
- package/dist/worker-inline.d.ts.map +1 -1
- package/package.json +11 -11
- package/readme.md +54 -42
- package/dist/chunk-bgfkgcmg.js +0 -25
- package/dist/chunk-cj3zanvs.min.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chartai",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.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
|
|
19
|
-
"types": "./dist/plugins
|
|
20
|
-
"default": "./dist/plugins
|
|
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
|
-
"./
|
|
27
|
-
"types": "./dist/
|
|
28
|
-
"default": "./dist/
|
|
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,46 @@
|
|
|
1
|
-
#
|
|
1
|
+
# chartai
|
|
2
2
|
|
|
3
|
-
Are you looking for a simple tiny little chart library which can draw as many lines and points
|
|
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
|
-
|
|
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
|
-
* **[
|
|
9
|
+
* **[Silly overly complicated demo](https://dgerrells.github.io/chartai/canvas/)**
|
|
10
10
|
|
|
11
|
-
Why
|
|
11
|
+
## Why chartai?
|
|
12
12
|
|
|
13
|
-
|
|
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. With all the core charts and plugins, chartai is about the same size as uplot.
|
|
14
|
+
|
|
15
|
+
* Tiny, unlimited line charts at ~11kb
|
|
14
16
|
* Customizable with plugins
|
|
15
|
-
* Lines, scatter,
|
|
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
|
-
*
|
|
22
|
+
* Typescript, No dependencies
|
|
23
|
+
|
|
24
|
+
Cool. How do I use it?
|
|
21
25
|
|
|
22
|
-
### Add a line chart
|
|
26
|
+
### Add a line chart
|
|
23
27
|
|
|
24
28
|
```js
|
|
25
29
|
import { ChartManager } from 'chartai';
|
|
30
|
+
import { LineChart } from 'chartai/charts/line';
|
|
26
31
|
|
|
27
|
-
|
|
28
|
-
await
|
|
32
|
+
ChartManager.use(LineChart);
|
|
33
|
+
await ChartManager.init();
|
|
29
34
|
|
|
30
35
|
const x = Array.from({ length: 100 }, (_, i) => i);
|
|
31
36
|
const y = x.map(v => Math.sin(v * 0.1) * 50 + 50);
|
|
32
37
|
|
|
33
|
-
const
|
|
38
|
+
const chart = ChartManager.create({
|
|
34
39
|
type: 'line',
|
|
35
40
|
container: document.getElementById('chart'),
|
|
36
41
|
series: [{
|
|
37
42
|
label: 'My Data',
|
|
38
|
-
color:
|
|
43
|
+
color: 'oklab(0.65 0.15 -0.2)',
|
|
39
44
|
x,
|
|
40
45
|
y
|
|
41
46
|
}],
|
|
@@ -45,52 +50,53 @@ const chartId = manager.create({
|
|
|
45
50
|
### Plugins
|
|
46
51
|
|
|
47
52
|
```js
|
|
48
|
-
import { ChartManager
|
|
49
|
-
import {
|
|
53
|
+
import { ChartManager } from 'chartai';
|
|
54
|
+
import { labelsPlugin } from 'chartai/plugins/labels';
|
|
50
55
|
import { hoverPlugin } from 'chartai/plugins/hover';
|
|
51
56
|
|
|
52
|
-
|
|
53
|
-
|
|
57
|
+
ChartManager.use(zoomPlugin);
|
|
58
|
+
ChartManager.use(hoverPlugin);
|
|
54
59
|
```
|
|
55
60
|
|
|
56
|
-
###
|
|
61
|
+
### Agnostic
|
|
62
|
+
|
|
63
|
+
It is pure js. Add it to your favorite framework.
|
|
57
64
|
|
|
58
65
|
```js
|
|
59
66
|
import { useEffect, useRef } from 'react';
|
|
60
|
-
import { ChartManager
|
|
67
|
+
import { ChartManager } from 'chartai';
|
|
68
|
+
import { LineChart } from 'chartai/charts/line';
|
|
61
69
|
import { zoomPlugin } from 'chartai/plugins/zoom';
|
|
62
70
|
import { hoverPlugin } from 'chartai/plugins/hover';
|
|
63
71
|
import { labelsPlugin } from 'chartai/plugins/labels';
|
|
64
72
|
|
|
65
73
|
function Chart() {
|
|
66
74
|
const ref = useRef(null);
|
|
67
|
-
const
|
|
75
|
+
const chartRef = useRef(null);
|
|
68
76
|
|
|
69
77
|
useEffect(() => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
78
|
+
ChartManager.use(LineChart);
|
|
79
|
+
ChartManager.use(labelsPlugin);
|
|
80
|
+
ChartManager.use(zoomPlugin());
|
|
81
|
+
ChartManager.use(hoverPlugin);
|
|
73
82
|
|
|
74
|
-
|
|
75
|
-
manager.init().then(() => {
|
|
83
|
+
ChartManager.init().then(() => {
|
|
76
84
|
const x = Array.from({ length: 100 }, (_, i) => i);
|
|
77
85
|
const y = x.map(v => Math.sin(v * 0.1) * 50 + 50);
|
|
78
86
|
|
|
79
|
-
|
|
87
|
+
chartRef.current = ChartManager.create({
|
|
80
88
|
type: 'line',
|
|
81
89
|
container: ref.current,
|
|
82
|
-
series: [{ label: 'My Data', color:
|
|
90
|
+
series: [{ label: 'My Data', color: '#ffffff', x, y }],
|
|
83
91
|
zoomMode: 'both',
|
|
84
92
|
showTooltip: true
|
|
85
93
|
});
|
|
86
94
|
|
|
87
|
-
|
|
95
|
+
chartRef.current.configure({ zoomMode: 'x-only' });
|
|
88
96
|
});
|
|
89
97
|
|
|
90
98
|
return () => {
|
|
91
|
-
|
|
92
|
-
manager.destroy(chartIdRef.current);
|
|
93
|
-
}
|
|
99
|
+
chartRef.current?.destroy();
|
|
94
100
|
};
|
|
95
101
|
}, []);
|
|
96
102
|
|
|
@@ -100,16 +106,22 @@ function Chart() {
|
|
|
100
106
|
|
|
101
107
|
## Design
|
|
102
108
|
|
|
103
|
-
|
|
109
|
+
A little layer communicates with a web worker that does all the 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 already exist.
|
|
110
|
+
|
|
111
|
+
Yes, you can point an agent at the examples and it will understand it.
|
|
112
|
+
|
|
113
|
+
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 the power of the framework.
|
|
114
|
+
|
|
115
|
+
Some charts and plugins are AI generated without thorough review. They are listed under an `/experimental` folder to make it explicit they are not polished.
|
|
116
|
+
|
|
117
|
+
## Gotchas
|
|
118
|
+
|
|
119
|
+
* 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.
|
|
120
|
+
* 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.
|
|
121
|
+
* Workers - The library will try and inline bundle the worker for maximum simplicity. If it fails, it will fallback to standard es worker loading.
|
|
122
|
+
|
|
123
|
+
### Contribution
|
|
104
124
|
|
|
105
|
-
|
|
125
|
+
I test using bun which handles most of the bundling out of the box.
|
|
106
126
|
|
|
107
|
-
|
|
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.
|
|
127
|
+
You can start a server watching files by running `bun server.ts`.
|
package/dist/chunk-bgfkgcmg.js
DELETED
|
@@ -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};
|