@pyreon/charts 0.6.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/LICENSE +21 -0
- package/README.md +159 -0
- package/lib/analysis/index.js.html +5406 -0
- package/lib/analysis/manual.js.html +5406 -0
- package/lib/charts-Ckh2qxB5.js +17571 -0
- package/lib/charts-Ckh2qxB5.js.map +1 -0
- package/lib/components-BcPePBeS.js +13688 -0
- package/lib/components-BcPePBeS.js.map +1 -0
- package/lib/core-9w0g6EOI.js +200 -0
- package/lib/core-9w0g6EOI.js.map +1 -0
- package/lib/createSeriesData-DOHScdgk.js +412 -0
- package/lib/createSeriesData-DOHScdgk.js.map +1 -0
- package/lib/customGraphicKeyframeAnimation-CvkEkSt_.js +8524 -0
- package/lib/customGraphicKeyframeAnimation-CvkEkSt_.js.map +1 -0
- package/lib/graphic-CPJ2K90a.js +10771 -0
- package/lib/graphic-CPJ2K90a.js.map +1 -0
- package/lib/index.js +309 -0
- package/lib/index.js.map +1 -0
- package/lib/manual.js +334 -0
- package/lib/manual.js.map +1 -0
- package/lib/parseGeoJson-BlBe5Vig.js +18498 -0
- package/lib/parseGeoJson-BlBe5Vig.js.map +1 -0
- package/lib/renderers-Dytryvoy.js +2044 -0
- package/lib/renderers-Dytryvoy.js.map +1 -0
- package/lib/types/charts.d.ts +7968 -0
- package/lib/types/charts.d.ts.map +1 -0
- package/lib/types/components.d.ts +4074 -0
- package/lib/types/components.d.ts.map +1 -0
- package/lib/types/core.d.ts +98 -0
- package/lib/types/core.d.ts.map +1 -0
- package/lib/types/createSeriesData.d.ts +325 -0
- package/lib/types/createSeriesData.d.ts.map +1 -0
- package/lib/types/customGraphicKeyframeAnimation.d.ts +3531 -0
- package/lib/types/customGraphicKeyframeAnimation.d.ts.map +1 -0
- package/lib/types/graphic.d.ts +4043 -0
- package/lib/types/graphic.d.ts.map +1 -0
- package/lib/types/index.d.ts +255 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index2.d.ts +2221 -0
- package/lib/types/index2.d.ts.map +1 -0
- package/lib/types/manual.d.ts +279 -0
- package/lib/types/manual.d.ts.map +1 -0
- package/lib/types/manual2.d.ts +2238 -0
- package/lib/types/manual2.d.ts.map +1 -0
- package/lib/types/parseGeoJson.d.ts +8695 -0
- package/lib/types/parseGeoJson.d.ts.map +1 -0
- package/lib/types/renderers.d.ts +995 -0
- package/lib/types/renderers.d.ts.map +1 -0
- package/package.json +58 -0
- package/src/chart-component.tsx +53 -0
- package/src/index.ts +64 -0
- package/src/loader.ts +222 -0
- package/src/manual.ts +36 -0
- package/src/tests/charts.test.tsx +363 -0
- package/src/types.ts +118 -0
- package/src/use-chart.ts +136 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Vit Bokisch
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# @pyreon/charts
|
|
2
|
+
|
|
3
|
+
Reactive ECharts bridge for Pyreon. Lazy loading, signal-driven updates, Canvas by default.
|
|
4
|
+
|
|
5
|
+
Zero ECharts bytes in your bundle until a chart actually renders. Chart types and components are auto-detected from your config and dynamically imported on demand.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add @pyreon/charts echarts
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Chart } from '@pyreon/charts'
|
|
17
|
+
import { signal } from '@pyreon/reactivity'
|
|
18
|
+
|
|
19
|
+
function RevenueChart() {
|
|
20
|
+
const revenue = signal([120, 200, 150, 80, 70, 110, 130])
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Chart
|
|
24
|
+
options={() => ({
|
|
25
|
+
xAxis: { type: 'category', data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'] },
|
|
26
|
+
yAxis: { type: 'value' },
|
|
27
|
+
tooltip: { trigger: 'axis' },
|
|
28
|
+
series: [{ type: 'bar', data: revenue() }],
|
|
29
|
+
})}
|
|
30
|
+
style="height: 400px"
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Signal changes → chart updates automatically. No manual `setOption` calls.
|
|
37
|
+
|
|
38
|
+
## How it works
|
|
39
|
+
|
|
40
|
+
1. You write a config object with `type: 'bar'` in series
|
|
41
|
+
2. The bridge detects: needs `BarChart` + `GridComponent` + `TooltipComponent` + `CanvasRenderer`
|
|
42
|
+
3. Dynamically imports only those ECharts modules (~35KB vs 300KB+ full)
|
|
43
|
+
4. Creates the chart instance with Canvas renderer
|
|
44
|
+
5. Sets up a reactive effect — when signals in your config function change, `setOption()` is called
|
|
45
|
+
6. ResizeObserver auto-resizes the chart
|
|
46
|
+
7. On unmount, chart is disposed and observer disconnected
|
|
47
|
+
|
|
48
|
+
## API
|
|
49
|
+
|
|
50
|
+
### `<Chart />`
|
|
51
|
+
|
|
52
|
+
Component shorthand wrapping `useChart`.
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
<Chart
|
|
56
|
+
options={() => ({
|
|
57
|
+
series: [{ type: 'pie', data: segments() }],
|
|
58
|
+
legend: {},
|
|
59
|
+
})}
|
|
60
|
+
theme="dark"
|
|
61
|
+
style="height: 300px"
|
|
62
|
+
class="my-chart"
|
|
63
|
+
onClick={(params) => console.log(params)}
|
|
64
|
+
/>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
| Prop | Type | Description |
|
|
68
|
+
| --- | --- | --- |
|
|
69
|
+
| `options` | `() => EChartOption` | Reactive config function |
|
|
70
|
+
| `theme?` | `string \| object` | ECharts theme |
|
|
71
|
+
| `renderer?` | `'canvas' \| 'svg'` | Renderer (default: `'canvas'`) |
|
|
72
|
+
| `style?` | `string` | CSS style for container |
|
|
73
|
+
| `class?` | `string` | CSS class for container |
|
|
74
|
+
| `onClick?` | `(params) => void` | Click event |
|
|
75
|
+
| `onMouseover?` | `(params) => void` | Mouseover event |
|
|
76
|
+
| `onMouseout?` | `(params) => void` | Mouseout event |
|
|
77
|
+
|
|
78
|
+
### `useChart(options, config?)`
|
|
79
|
+
|
|
80
|
+
Core hook for programmatic control.
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
const chart = useChart(() => ({
|
|
84
|
+
xAxis: { data: months() },
|
|
85
|
+
series: [{ type: 'line', data: values(), smooth: true }],
|
|
86
|
+
}))
|
|
87
|
+
|
|
88
|
+
return <div ref={chart.ref} style="height: 400px" />
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Returns:**
|
|
92
|
+
|
|
93
|
+
| Property | Type | Description |
|
|
94
|
+
| --- | --- | --- |
|
|
95
|
+
| `ref` | `(el: HTMLElement \| null) => void` | Bind to container div |
|
|
96
|
+
| `instance` | `Signal<ECharts \| null>` | ECharts instance (null until loaded) |
|
|
97
|
+
| `loading` | `Signal<boolean>` | True while modules are loading |
|
|
98
|
+
| `resize` | `() => void` | Manually trigger resize |
|
|
99
|
+
|
|
100
|
+
**Config options:**
|
|
101
|
+
|
|
102
|
+
| Option | Type | Default | Description |
|
|
103
|
+
| --- | --- | --- | --- |
|
|
104
|
+
| `theme` | `string \| object` | — | ECharts theme |
|
|
105
|
+
| `renderer` | `'canvas' \| 'svg'` | `'canvas'` | Rendering engine |
|
|
106
|
+
| `locale` | `string` | `'EN'` | ECharts locale |
|
|
107
|
+
| `notMerge` | `boolean` | `false` | Replace options instead of merging |
|
|
108
|
+
| `lazyUpdate` | `boolean` | `true` | Batch updates |
|
|
109
|
+
| `onInit` | `(instance) => void` | — | Called when chart is created |
|
|
110
|
+
|
|
111
|
+
## Manual Registration (Tree-shaking)
|
|
112
|
+
|
|
113
|
+
For apps that want absolute minimal bundles, explicitly import only what you need:
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import { useChart, Chart, use } from '@pyreon/charts/manual'
|
|
117
|
+
import { BarChart, LineChart } from 'echarts/charts'
|
|
118
|
+
import { GridComponent, TooltipComponent } from 'echarts/components'
|
|
119
|
+
import { CanvasRenderer } from 'echarts/renderers'
|
|
120
|
+
|
|
121
|
+
use(BarChart, LineChart, GridComponent, TooltipComponent, CanvasRenderer)
|
|
122
|
+
|
|
123
|
+
// Same API — no dynamic imports, no loading state
|
|
124
|
+
<Chart
|
|
125
|
+
options={() => ({
|
|
126
|
+
series: [{ type: 'bar', data: values() }],
|
|
127
|
+
})}
|
|
128
|
+
style="height: 400px"
|
|
129
|
+
/>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Supported Chart Types
|
|
133
|
+
|
|
134
|
+
bar, line, pie, scatter, radar, heatmap, treemap, sunburst, sankey, funnel, gauge, graph, tree, boxplot, candlestick, parallel, themeRiver, effectScatter, lines, pictorialBar, custom, map
|
|
135
|
+
|
|
136
|
+
## Supported Components
|
|
137
|
+
|
|
138
|
+
tooltip, legend, title, toolbox, dataZoom, visualMap, timeline, graphic, brush, calendar, dataset, aria, grid (also implied by xAxis/yAxis), polar, radar, geo
|
|
139
|
+
|
|
140
|
+
## Bundle Size
|
|
141
|
+
|
|
142
|
+
| Usage | ECharts loaded | Approx gzipped |
|
|
143
|
+
| --- | --- | --- |
|
|
144
|
+
| No charts rendered | Nothing | 0 KB |
|
|
145
|
+
| Bar + tooltip | core + BarChart + Grid + Tooltip + Canvas | ~35 KB |
|
|
146
|
+
| Bar + Line + legend | core + BarChart + LineChart + Grid + Legend + Tooltip + Canvas | ~42 KB |
|
|
147
|
+
| Pie only | core + PieChart + Canvas | ~25 KB |
|
|
148
|
+
| @pyreon/charts itself | Module map + hook | ~3 KB |
|
|
149
|
+
|
|
150
|
+
## Why Canvas by default
|
|
151
|
+
|
|
152
|
+
Canvas renders the entire chart as a single `<canvas>` element. SVG creates hundreds of DOM elements for complex charts. Canvas is better for:
|
|
153
|
+
|
|
154
|
+
- Charts with many data points
|
|
155
|
+
- Frequent signal-driven updates
|
|
156
|
+
- Animations
|
|
157
|
+
- Memory efficiency
|
|
158
|
+
|
|
159
|
+
Use `renderer: 'svg'` only when you need CSS styling on individual elements or PDF export.
|