@aeriz/chart 1.1.0 → 2.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 (45) hide show
  1. package/README.md +60 -34
  2. package/dist/aeriz.cjs +609 -354
  3. package/dist/aeriz.esm.js +578 -331
  4. package/dist/aeriz.esm.min.js +119 -105
  5. package/dist/aeriz.js +609 -354
  6. package/dist/aeriz.min.cjs +123 -107
  7. package/dist/aeriz.min.js +123 -107
  8. package/dist/esm/base.js +33 -22
  9. package/dist/esm/cartesian.js +7 -5
  10. package/dist/esm/charts/area.js +6 -6
  11. package/dist/esm/charts/bar.js +3 -3
  12. package/dist/esm/charts/boxplot.js +3 -3
  13. package/dist/esm/charts/bubble.js +3 -3
  14. package/dist/esm/charts/composite.js +8 -8
  15. package/dist/esm/charts/funnel.js +3 -3
  16. package/dist/esm/charts/gauge.js +5 -5
  17. package/dist/esm/charts/grouped-bar.js +4 -4
  18. package/dist/esm/charts/hbar.js +5 -5
  19. package/dist/esm/charts/heatmap.js +6 -6
  20. package/dist/esm/charts/line.js +6 -6
  21. package/dist/esm/charts/multi-line.js +5 -5
  22. package/dist/esm/charts/pie.js +6 -6
  23. package/dist/esm/charts/polar.js +3 -3
  24. package/dist/esm/charts/radar.js +6 -6
  25. package/dist/esm/charts/realtime.js +11 -9
  26. package/dist/esm/charts/scatter.js +4 -4
  27. package/dist/esm/charts/sparkline.js +4 -4
  28. package/dist/esm/charts/stacked-bar.js +5 -5
  29. package/dist/esm/charts/treemap.js +4 -4
  30. package/dist/esm/charts/waterfall.js +4 -4
  31. package/dist/esm/engine.js +1 -1
  32. package/dist/esm/index.js +2 -2
  33. package/dist/esm/jquery.js +5 -4
  34. package/dist/esm/math.js +1 -1
  35. package/dist/esm/react.js +4 -4
  36. package/dist/esm/shallow.js +4 -2
  37. package/dist/esm/svelte.js +4 -4
  38. package/dist/esm/vue.js +4 -2
  39. package/dist/index.d.ts +228 -552
  40. package/dist/jquery.d.ts +19 -8
  41. package/dist/react.d.ts +55 -18
  42. package/dist/svelte.d.ts +53 -14
  43. package/dist/types/sparkline.d.ts +1 -1
  44. package/dist/vue.d.ts +60 -10
  45. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @aeriz/chart
2
2
 
3
- Visualization, light as air. 21 canvas chart types from one options object, with zero dependencies.
3
+ Visualization, light as air. 21 canvas chart types, one way to use them, zero dependencies.
4
4
 
5
5
  **Docs and live demos: https://aeriz.dev/chart/**
6
6
 
@@ -18,77 +18,103 @@ const chart = new BarChart('#sales', {
18
18
  chart.update({ data: { Jan: 30, Feb: 80 } }); // animates to the new values
19
19
  ```
20
20
 
21
- ## Why
21
+ ## One way to do it
22
22
 
23
- - **One API.** Every type works the same: `new Chart(el, options)` → `update()` → `destroy()`.
24
- - **Only what you use.** Each chart is its own module and the package has `"sideEffects": false`, so bundlers keep only the charts you import. One chart costs about 7–10 KB min+gzip, and all 21 cost about 19 KB.
25
- - **Works anywhere.** Adapters for React, Vue, Svelte and jQuery are separate entry points.
26
- - **Fast.** A million-point line draws in about 50 ms. Off-screen charts don't draw.
27
- - **Fits in without config.** Text color, font and background come from the page, so charts match light and dark themes. Override any of it with `--aeriz-*` CSS variables.
28
- - **Accessible.** You get keyboard navigation, screen-reader announcements, a clickable legend, and touch and pen tooltips.
23
+ Every chart, in every environment:
24
+
25
+ | To | Use |
26
+ |---|---|
27
+ | Create | `new BarChart(target, options)` |
28
+ | Change data or options | `chart.update({ data, … })` |
29
+ | Loading · empty · error | `chart.setState('loading' \| 'empty' \| 'error' \| null, text?)` |
30
+ | Redraw now (after CSS changes, off-screen) | `chart.render()` |
31
+ | Remove | `chart.destroy()` |
32
+
33
+ Data is always the `data` option:
34
+
35
+ ```js
36
+ new BarChart(el, { data: [64, 42, 78] }); // numbers
37
+ new BarChart(el, { data: { Jan: 64, Feb: 42 } }); // an object
38
+ new BarChart(el, { data: rows, value: (r) => r.sales }); // your rows
39
+
40
+ new MultiLineChart(el, {
41
+ data: { categories: ['Q1', 'Q2'], series: [{ name: '2026', values: [140, 160] }] },
42
+ });
43
+ ```
44
+
45
+ Mistakes don't fail silently. The console says what is wrong and how to fix it:
46
+
47
+ ```
48
+ [aeriz] BarChart: unknown option "dat" — did you mean "data"?
49
+ [aeriz] MultiLineChart: series[0] "2026" has 1 values but there are 2 categories.
50
+ ```
29
51
 
30
52
  ## Charts
31
53
 
32
- `BarChart` `HBarChart` `LineChart` `AreaChart` `StackedBarChart` `GroupedBarChart` `MultiLineChart` `ScatterChart` `BubbleChart` `PieChart` `RadarChart` `PolarChart` `GaugeChart` `HeatmapChart` `BoxplotChart` `FunnelChart` `TreemapChart` `Sparkline` `RealtimeChart` `WaterfallChart` `CompositeChart`
54
+ `BarChart` `HBarChart` `LineChart` `AreaChart` `StackedBarChart` `GroupedBarChart` `MultiLineChart` `ScatterChart` `BubbleChart` `PieChart` `RadarChart` `PolarChart` `GaugeChart` `HeatmapChart` `BoxplotChart` `FunnelChart` `TreemapChart` `SparklineChart` `RealtimeChart` `WaterfallChart` `CompositeChart`
33
55
 
34
- Import one directly by its subpath: `@aeriz/chart/bar`, `@aeriz/chart/line`, `@aeriz/chart/multi-line` and so on.
56
+ Each chart is its own module and the package has `"sideEffects": false`, so bundlers keep only the charts you import: one chart is about 9–12 KB min+gzip, all 21 about 21 KB. Without a bundler, import a subpath: `@aeriz/chart/bar`, `@aeriz/chart/line`, `@aeriz/chart/multi-line` and so on.
35
57
 
36
58
  ## Frameworks
37
59
 
60
+ Same chart names, same options as props.
61
+
38
62
  ```jsx
39
63
  // React 16.8+
40
- import { BarChart } from '@aeriz/chart/bar';
41
- import { AerizChart } from '@aeriz/chart/react';
64
+ import { BarChart } from '@aeriz/chart/react';
42
65
 
43
- <AerizChart type={BarChart} data={rows} style={{ height: 320 }} />;
66
+ <BarChart data={rows} format={{ style: 'percent' }} onClick={(hit) => …} style={{ height: 320 }} />;
44
67
  ```
45
68
 
46
69
  ```vue
47
70
  <!-- Vue 3.2+ -->
48
- <AerizChart :type="LineChart" :data="rows" style="height: 300px" />
49
- <!-- import { AerizChart } from '@aeriz/chart/vue' -->
71
+ <script setup>
72
+ import { LineChart } from '@aeriz/chart/vue';
73
+ </script>
74
+ <template><LineChart :data="rows" @click="onHit" style="height: 300px" /></template>
50
75
  ```
51
76
 
52
77
  ```svelte
53
78
  <!-- Svelte 3, 4, 5 (an action, so no compiler setup) -->
54
- <div use:aeriz={{ type: BarChart, data: rows }} style="height: 300px"></div>
55
- <!-- import { aeriz } from '@aeriz/chart/svelte' -->
79
+ <script>
80
+ import { barChart } from '@aeriz/chart/svelte';
81
+ </script>
82
+ <div use:barChart={{ data: rows }} style="height: 300px"></div>
56
83
  ```
57
84
 
58
85
  ```js
59
86
  // jQuery 1.7+
87
+ import { PieChart } from '@aeriz/chart/pie';
60
88
  import { install } from '@aeriz/chart/jquery';
61
- install($);
62
- $('#share').aerizChart(PieChart, { data: { Chrome: 64, Safari: 19 } });
89
+
90
+ install($, { PieChart });
91
+ $('#share').aerizChart('pie', { data: { Chrome: 64, Safari: 19 } });
92
+ $('#share').aerizChart('update', { data: { Chrome: 70, Safari: 20 } });
63
93
  ```
64
94
 
65
95
  ## CDN
66
96
 
67
97
  ```html
68
- <!-- Everything, as the global Aeriz (also installs the jQuery plugin if jQuery is present) -->
69
- <script src="https://cdn.jsdelivr.net/npm/@aeriz/chart@1.1.0/dist/aeriz.min.js"></script>
98
+ <!-- Everything, as the global Aeriz (also installs the jQuery plugin if jQuery is loaded first) -->
99
+ <script src="https://cdn.jsdelivr.net/npm/@aeriz/chart@2.0.0/dist/aeriz.min.js"></script>
70
100
 
71
101
  <!-- One chart, as an ES module -->
72
102
  <script type="module">
73
- import { BarChart } from 'https://cdn.jsdelivr.net/npm/@aeriz/chart@1.1.0/dist/esm/charts/bar.js';
103
+ import { BarChart } from 'https://cdn.jsdelivr.net/npm/@aeriz/chart@2.0.0/dist/esm/charts/bar.js';
74
104
  </script>
75
105
  ```
76
106
 
77
- ## New in 1.1
107
+ ## Upgrading from 1.x
78
108
 
79
- 1.0 code keeps working. What 1.1 adds:
109
+ 2.0 removes the duplicate ways of doing the same thing. When you use a 1.x name, the console tells you the 2.0 one. The main changes:
80
110
 
81
- - per-chart modules and subpath imports;
82
- - the framework adapters;
83
- - `update()`;
84
- - a `format` option for numbers;
85
- - a legend that toggles series;
86
- - keyboard support and accessibility;
87
- - local-time axes;
88
- - right-axis composite charts;
89
- - large-data decimation.
111
+ - `setData(d)` → `update({ data: d })`; `setLoading/setEmpty/setError/clearState` → `setState(…)`; `invalidate()` → `render()`.
112
+ - `categories`/`series`/`layers`/`axes` options → `data: { categories, series }`.
113
+ - `ariaLabel` → `title`, `palette`/`color` → `colors`, `yTickFormat`/`xTickFormat` → `format`/`labelFormat`, `interpolation` → `curve`.
114
+ - React/Vue `<AerizChart type={BarChart}>` → `<BarChart>`; Svelte `use:aeriz` → `use:barChart`; jQuery `.aerizChart(PieChart, …)` → `.aerizChart('pie', …)`.
115
+ - `Sparkline` → `SparklineChart`.
90
116
 
91
- It also fixes a long list of 1.0 bugs. The full list is at https://aeriz.dev/chart/#changes.
117
+ The full table is at https://aeriz.dev/chart/#migrate. To stay on 1.x: `npm install @aeriz/chart@1`.
92
118
 
93
119
  ## License
94
120