@kubex/zinc 1.0.106 → 1.0.107
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/custom-elements.json +183 -83
- package/dist/vscode.html-custom-data.json +19 -10
- package/dist/web-types.json +56 -45
- package/dist/zn.d.ts +66 -34
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +1006 -1907
- package/docs/pages/components/chart.md +134 -8
- package/docs/pages/components/simple-chart.md +20 -5
- package/docs/pages/components/stat.md +531 -401
- package/package.json +5 -6
- package/src/components/chart/builders.test.ts +211 -0
- package/src/components/chart/builders.ts +221 -0
- package/src/components/chart/chart.component.ts +182 -173
- package/src/components/chart/chart.scss +0 -1
- package/src/components/chart/chart.test.ts +48 -4
- package/src/components/editor/modules/context-menu/context-menu.ts +2 -1
- package/src/components/rating/rating.component.ts +2 -1
- package/src/components/simple-chart/simple-chart.component.ts +72 -180
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
meta:
|
|
3
3
|
title: Data Chart
|
|
4
|
-
description: Charts visualize data using various chart types powered by
|
|
4
|
+
description: Charts visualize data using various chart types powered by Apache ECharts. Display line charts, bar charts, area charts, sankey diagrams, and more with full customization options.
|
|
5
5
|
layout: component
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
```html:preview
|
|
9
9
|
<zn-chart
|
|
10
10
|
type="area"
|
|
11
|
+
smooth
|
|
11
12
|
categories="["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep"]"
|
|
12
13
|
data="[{"name":"Series 1","data":[30,40,45,50,49,60,70,91,125]}]"
|
|
13
14
|
height="300">
|
|
@@ -15,7 +16,7 @@ layout: component
|
|
|
15
16
|
```
|
|
16
17
|
|
|
17
18
|
:::tip
|
|
18
|
-
The chart component is built on
|
|
19
|
+
The chart component is built on Apache ECharts, providing a powerful and flexible charting library with extensive customisation options. Visit the [Apache ECharts documentation](https://echarts.apache.org/en/option.html) for advanced configuration reference.
|
|
19
20
|
:::
|
|
20
21
|
|
|
21
22
|
## Examples
|
|
@@ -27,6 +28,7 @@ Use `type="line"` to create a line chart. The `data` attribute accepts an array
|
|
|
27
28
|
```html:preview
|
|
28
29
|
<zn-chart
|
|
29
30
|
type="line"
|
|
31
|
+
scale
|
|
30
32
|
categories="["Jan","Feb","Mar","Apr","May","Jun"]"
|
|
31
33
|
data="[{"name":"Revenue","data":[30,40,35,50,49,60]},{"name":"Expenses","data":[20,29,25,35,39,45]}]"
|
|
32
34
|
height="300">
|
|
@@ -94,6 +96,7 @@ Stacked area charts work similarly to stacked bar charts but with area fills.
|
|
|
94
96
|
<zn-chart
|
|
95
97
|
type="area"
|
|
96
98
|
stacked
|
|
99
|
+
smooth
|
|
97
100
|
categories="["Jan","Feb","Mar","Apr","May","Jun"]"
|
|
98
101
|
data="[{"name":"Desktop","data":[300,400,350,500,490,600]},{"name":"Mobile","data":[200,290,250,350,390,450]},{"name":"Tablet","data":[100,150,120,180,170,200]}]"
|
|
99
102
|
height="300">
|
|
@@ -114,6 +117,7 @@ Use the `height` attribute to control the chart's height in pixels. The default
|
|
|
114
117
|
<br />
|
|
115
118
|
<zn-chart
|
|
116
119
|
type="line"
|
|
120
|
+
scale
|
|
117
121
|
categories="["Jan","Feb","Mar","Apr"]"
|
|
118
122
|
data="[{"name":"Sales","data":[40,55,45,60]}]"
|
|
119
123
|
height="400">
|
|
@@ -127,6 +131,7 @@ Use the `d-size` attribute to control the size of data point markers on line and
|
|
|
127
131
|
```html:preview
|
|
128
132
|
<zn-chart
|
|
129
133
|
type="line"
|
|
134
|
+
scale
|
|
130
135
|
categories="["Jan","Feb","Mar","Apr","May"]"
|
|
131
136
|
data="[{"name":"Small Markers","data":[30,40,35,50,49]}]"
|
|
132
137
|
d-size="1"
|
|
@@ -135,6 +140,7 @@ Use the `d-size` attribute to control the size of data point markers on line and
|
|
|
135
140
|
<br />
|
|
136
141
|
<zn-chart
|
|
137
142
|
type="line"
|
|
143
|
+
scale
|
|
138
144
|
categories="["Jan","Feb","Mar","Apr","May"]"
|
|
139
145
|
data="[{"name":"Large Markers","data":[30,40,35,50,49]}]"
|
|
140
146
|
d-size="6"
|
|
@@ -166,31 +172,73 @@ Use `y-axis-append` to add a suffix to y-axis labels and tooltip values. Common
|
|
|
166
172
|
|
|
167
173
|
### Time Series with X-Axis Type
|
|
168
174
|
|
|
169
|
-
Use the `
|
|
175
|
+
Use the `xaxis` attribute to specify the x-axis type. Common values include `datetime`, `category`, and `numeric`.
|
|
170
176
|
|
|
171
177
|
```html:preview
|
|
172
178
|
<zn-chart
|
|
173
179
|
type="line"
|
|
174
|
-
|
|
180
|
+
xaxis="datetime"
|
|
175
181
|
data="[{"name":"Traffic","data":[{"x":1609459200000,"y":30},{"x":1612137600000,"y":40},{"x":1614556800000,"y":35},{"x":1617235200000,"y":50},{"x":1619827200000,"y":49},{"x":1622505600000,"y":60}]}]"
|
|
176
182
|
height="300">
|
|
177
183
|
</zn-chart>
|
|
178
184
|
```
|
|
179
185
|
|
|
180
186
|
:::tip
|
|
181
|
-
When using `
|
|
187
|
+
When using `xaxis="datetime"`, provide data in the format `[{x: timestamp, y: value}]` where `x` is a Unix timestamp in milliseconds. The chart will automatically format the dates on the x-axis.
|
|
182
188
|
:::
|
|
183
189
|
|
|
184
190
|
### Enable Animations
|
|
185
191
|
|
|
186
|
-
By default, animations are disabled for better performance.
|
|
192
|
+
By default, animations are disabled for better performance. Add the `enable-animations` attribute to animate on first render — bars grow from the baseline and lines draw in. Pass a number (milliseconds) to control the duration; bare `enable-animations` defaults to `1500`.
|
|
187
193
|
|
|
188
194
|
```html:preview
|
|
189
195
|
<zn-chart
|
|
190
196
|
type="bar"
|
|
191
197
|
categories="["A","B","C","D","E"]"
|
|
192
198
|
data="[{"name":"Values","data":[44,55,41,37,52]}]"
|
|
193
|
-
enable-animations
|
|
199
|
+
enable-animations="2500"
|
|
200
|
+
height="300">
|
|
201
|
+
</zn-chart>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Smooth Lines
|
|
205
|
+
|
|
206
|
+
Add the `smooth` attribute to render line and area charts with curved segments instead of straight ones. Ignored for bar and sankey charts.
|
|
207
|
+
|
|
208
|
+
```html:preview
|
|
209
|
+
<zn-chart
|
|
210
|
+
type="line"
|
|
211
|
+
smooth
|
|
212
|
+
categories="["Jan","Feb","Mar","Apr","May","Jun"]"
|
|
213
|
+
data="[{"name":"Revenue","data":[30,40,35,50,49,60]}]"
|
|
214
|
+
height="300">
|
|
215
|
+
</zn-chart>
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Scaled Y-Axis
|
|
219
|
+
|
|
220
|
+
By default the y-axis starts at `0`. Add the `scale` attribute to adapt the y-axis to the data range — useful when values are clustered far from zero and you want to emphasise variation.
|
|
221
|
+
|
|
222
|
+
```html:preview
|
|
223
|
+
<zn-chart
|
|
224
|
+
type="line"
|
|
225
|
+
scale
|
|
226
|
+
categories="["Mon","Tue","Wed","Thu","Fri"]"
|
|
227
|
+
data="[{"name":"Temperature","data":[18,19,17,20,22]}]"
|
|
228
|
+
y-axis-append="°C"
|
|
229
|
+
height="300">
|
|
230
|
+
</zn-chart>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Pass a number to `scale` to add that percentage of padding on top and bottom of the data range (e.g. `scale="10"` adds 10% padding). Larger values make the axis "breathe" more around the data.
|
|
234
|
+
|
|
235
|
+
```html:preview
|
|
236
|
+
<zn-chart
|
|
237
|
+
type="line"
|
|
238
|
+
scale="10"
|
|
239
|
+
categories="["Mon","Tue","Wed","Thu","Fri"]"
|
|
240
|
+
data="[{"name":"Temperature","data":[18,19,17,20,22]}]"
|
|
241
|
+
y-axis-append="°C"
|
|
194
242
|
height="300">
|
|
195
243
|
</zn-chart>
|
|
196
244
|
```
|
|
@@ -221,6 +269,65 @@ When no data is available, the chart will display an empty state. Consider addin
|
|
|
221
269
|
</zn-chart>
|
|
222
270
|
```
|
|
223
271
|
|
|
272
|
+
### Sankey Diagram
|
|
273
|
+
|
|
274
|
+
Use `type="sankey"` to render a Sankey flow diagram. Each item in the series `data` array is an edge with `source`, `target`, and `value`. Nodes are auto-derived from unique source/target values.
|
|
275
|
+
|
|
276
|
+
```html:preview
|
|
277
|
+
<zn-chart
|
|
278
|
+
type="sankey"
|
|
279
|
+
height="400"
|
|
280
|
+
data="[{"name":"Payment Flow","data":[{"source":"Stripe","target":"USD","value":1200},{"source":"Stripe","target":"EUR","value":430},{"source":"USD","target":"Captured","value":900},{"source":"USD","target":"Declined","value":300},{"source":"EUR","target":"Captured","value":380},{"source":"EUR","target":"Declined","value":50}]}]">
|
|
281
|
+
</zn-chart>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Cross-Chart Tooltip Sync
|
|
285
|
+
|
|
286
|
+
Use `sync-group="<id>"` on two or more charts to synchronise hover tooltips, zoom, and legend selection across them.
|
|
287
|
+
|
|
288
|
+
```html:preview
|
|
289
|
+
<zn-chart
|
|
290
|
+
sync-group="demo-group"
|
|
291
|
+
type="line"
|
|
292
|
+
categories="["Mon","Tue","Wed","Thu","Fri"]"
|
|
293
|
+
data="[{"name":"Visits","data":[120,180,150,220,190]}]"
|
|
294
|
+
height="250">
|
|
295
|
+
</zn-chart>
|
|
296
|
+
<br />
|
|
297
|
+
<zn-chart
|
|
298
|
+
sync-group="demo-group"
|
|
299
|
+
type="bar"
|
|
300
|
+
categories="["Mon","Tue","Wed","Thu","Fri"]"
|
|
301
|
+
data="[{"name":"Signups","data":[12,18,15,22,19]}]"
|
|
302
|
+
height="250">
|
|
303
|
+
</zn-chart>
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### Custom Colors
|
|
307
|
+
|
|
308
|
+
Use the `colors` attribute to set the palette that cycles across series.
|
|
309
|
+
|
|
310
|
+
```html:preview
|
|
311
|
+
<zn-chart
|
|
312
|
+
type="bar"
|
|
313
|
+
colors="["#ff6c9c","#6483F2","#29bab5"]"
|
|
314
|
+
categories="["Q1","Q2","Q3"]"
|
|
315
|
+
data="[{"name":"A","data":[10,20,30]},{"name":"B","data":[15,25,35]},{"name":"C","data":[20,30,40]}]"
|
|
316
|
+
height="300">
|
|
317
|
+
</zn-chart>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
For a specific series colour, add a `color` property to the series object in the `data` array:
|
|
321
|
+
|
|
322
|
+
```html:preview
|
|
323
|
+
<zn-chart
|
|
324
|
+
type="line"
|
|
325
|
+
categories="["Jan","Feb","Mar"]"
|
|
326
|
+
data="[{"name":"Revenue","color":"hsl(210,70%,50%)","data":[10,20,30]}]"
|
|
327
|
+
height="300">
|
|
328
|
+
</zn-chart>
|
|
329
|
+
```
|
|
330
|
+
|
|
224
331
|
### Dark Mode Support
|
|
225
332
|
|
|
226
333
|
The chart component automatically adapts to dark mode using the `t` attribute. The theme adjusts colors, gridlines, and text to match the current theme.
|
|
@@ -229,6 +336,8 @@ The chart component automatically adapts to dark mode using the `t` attribute. T
|
|
|
229
336
|
<zn-chart
|
|
230
337
|
t="dark"
|
|
231
338
|
type="area"
|
|
339
|
+
scale
|
|
340
|
+
smooth
|
|
232
341
|
categories="["Mon","Tue","Wed","Thu","Fri"]"
|
|
233
342
|
data="[{"name":"Series 1","data":[30,40,35,50,49]},{"name":"Series 2","data":[25,35,30,45,42]}]"
|
|
234
343
|
height="300">
|
|
@@ -257,6 +366,7 @@ You can combine various attributes to create rich, informative charts.
|
|
|
257
366
|
```html:preview
|
|
258
367
|
<zn-chart
|
|
259
368
|
type="line"
|
|
369
|
+
scale
|
|
260
370
|
categories="["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"]"
|
|
261
371
|
data="[{"name":"Target","data":[80,85,82,90,88,95,92,98]},{"name":"Actual","data":[75,82,78,88,91,97,94,102]}]"
|
|
262
372
|
d-size="4"
|
|
@@ -298,7 +408,7 @@ The chart component accepts data in JSON format through the `data` attribute. Th
|
|
|
298
408
|
|
|
299
409
|
### Time Series Format
|
|
300
410
|
|
|
301
|
-
When using `
|
|
411
|
+
When using `xaxis="datetime"`, use the coordinate format:
|
|
302
412
|
|
|
303
413
|
```json
|
|
304
414
|
[
|
|
@@ -313,6 +423,22 @@ When using `x-axis="datetime"`, use the coordinate format:
|
|
|
313
423
|
]
|
|
314
424
|
```
|
|
315
425
|
|
|
426
|
+
### Sankey Edge Format
|
|
427
|
+
|
|
428
|
+
When `type="sankey"`, each item in the series `data` array is an edge:
|
|
429
|
+
|
|
430
|
+
```json
|
|
431
|
+
[{
|
|
432
|
+
"name": "Flow",
|
|
433
|
+
"data": [
|
|
434
|
+
{"source": "A", "target": "B", "value": 100},
|
|
435
|
+
{"source": "A", "target": "C", "value": 50}
|
|
436
|
+
]
|
|
437
|
+
}]
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
Nodes are auto-derived from unique source/target values. To customise node appearance or ordering, include an explicit `nodes` key on the series object.
|
|
441
|
+
|
|
316
442
|
### HTML Encoding
|
|
317
443
|
|
|
318
444
|
When using the data attribute in HTML, JSON must be properly encoded. Use `"` for quotes:
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
meta:
|
|
3
3
|
title: Simple Chart
|
|
4
|
-
description:
|
|
4
|
+
description: A pre-styled compact bar chart for inline sparklines and dashboard tiles.
|
|
5
5
|
layout: component
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
`zn-simple-chart` renders a small, opinionated bar chart with no axes or legend — handy for inline sparklines and dashboard summary tiles. It accepts a single series of values via `datasets` and optional x-axis labels via `labels`. If neither is provided, a placeholder dataset is shown.
|
|
9
|
+
|
|
8
10
|
```html:preview
|
|
9
11
|
<zn-simple-chart>
|
|
10
12
|
</zn-simple-chart>
|
|
@@ -12,12 +14,25 @@ layout: component
|
|
|
12
14
|
|
|
13
15
|
## Examples
|
|
14
16
|
|
|
15
|
-
###
|
|
17
|
+
### With Your Own Data
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
Pass a `datasets` array with one entry and its `data` values, plus a matching `labels` array for tooltip context.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
```html:preview
|
|
22
|
+
<zn-simple-chart
|
|
23
|
+
datasets="[{"data":[12,18,9,24,30,22,35,42]}]"
|
|
24
|
+
labels="["Mon","Tue","Wed","Thu","Fri","Sat","Sun","Mon"]">
|
|
25
|
+
</zn-simple-chart>
|
|
26
|
+
```
|
|
20
27
|
|
|
21
|
-
|
|
28
|
+
### Enable Animations
|
|
22
29
|
|
|
30
|
+
By default, bars render immediately with no animation. Add the `enable-animations` attribute to make bars grow from the baseline on first render. Pass a number (milliseconds) to control the duration; bare `enable-animations` defaults to `1500`.
|
|
23
31
|
|
|
32
|
+
```html:preview
|
|
33
|
+
<zn-simple-chart
|
|
34
|
+
enable-animations="3000"
|
|
35
|
+
datasets="[{"data":[12,18,9,24,30,22,35,42]}]"
|
|
36
|
+
labels="["Mon","Tue","Wed","Thu","Fri","Sat","Sun","Mon"]">
|
|
37
|
+
</zn-simple-chart>
|
|
38
|
+
```
|