@kubex/zinc 1.0.25 → 1.0.99
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/.claude/project.md +556 -0
- package/.github/workflows/js_build_and_deploy.yaml +9 -10
- package/dist/custom-elements.json +13575 -8856
- package/dist/vscode.html-custom-data.json +583 -48
- package/dist/web-types.json +1441 -181
- package/dist/zn.d.ts +1645 -660
- package/dist/zn.min.css +1 -1
- package/dist/zn.min.js +1412 -893
- package/docs/_utilities/code-previews.cjs +10 -1
- package/docs/assets/scripts/docs.js +42 -18
- package/docs/data/data-table.json +229 -66
- package/docs/data/empty.json +6 -0
- package/docs/data/products-table.json +41 -193
- package/docs/pages/components/action-bar.md +121 -6
- package/docs/pages/components/alert.md +118 -15
- package/docs/pages/components/animated-button.md +299 -0
- package/docs/pages/components/audio-select.md +534 -0
- package/docs/pages/components/bulk-actions.md +79 -5
- package/docs/pages/components/button-group.md +235 -27
- package/docs/pages/components/button.md +139 -1
- package/docs/pages/components/chart.md +365 -9
- package/docs/pages/components/checkbox.md +387 -58
- package/docs/pages/components/chip.md +253 -33
- package/docs/pages/components/collapsible.md +393 -46
- package/docs/pages/components/cols.md +152 -30
- package/docs/pages/components/confirm.md +182 -16
- package/docs/pages/components/copy-button.md +169 -6
- package/docs/pages/components/data-select.md +194 -15
- package/docs/pages/components/data-table-filter.md +96 -5
- package/docs/pages/components/data-table-search.md +451 -0
- package/docs/pages/components/data-table-sort.md +66 -5
- package/docs/pages/components/data-table.md +727 -66
- package/docs/pages/components/datepicker.md +402 -7
- package/docs/pages/components/defined-label.md +120 -5
- package/docs/pages/components/dialog.md +339 -59
- package/docs/pages/components/dropdown.md +366 -11
- package/docs/pages/components/editor.md +604 -7
- package/docs/pages/components/empty-state.md +315 -16
- package/docs/pages/components/expanding-action.md +212 -28
- package/docs/pages/components/file.md +421 -12
- package/docs/pages/components/filter-container.md +158 -5
- package/docs/pages/components/filter-wrapper.md +167 -6
- package/docs/pages/components/form-group.md +383 -6
- package/docs/pages/components/hover-container.md +237 -6
- package/docs/pages/components/icon-picker.md +121 -0
- package/docs/pages/components/icon.md +454 -48
- package/docs/pages/components/inline-edit.md +787 -19
- package/docs/pages/components/input-group.md +207 -13
- package/docs/pages/components/input.md +194 -0
- package/docs/pages/components/item.md +18 -0
- package/docs/pages/components/key-container.md +115 -0
- package/docs/pages/components/key.md +101 -0
- package/docs/pages/components/menu.md +512 -6
- package/docs/pages/components/note.md +239 -36
- package/docs/pages/components/opt-group.md +107 -0
- package/docs/pages/components/pagination.md +332 -6
- package/docs/pages/components/pane.md +222 -6
- package/docs/pages/components/panel.md +213 -26
- package/docs/pages/components/popup.md +1354 -6
- package/docs/pages/components/priority-list.md +233 -0
- package/docs/pages/components/progress-bar.md +387 -6
- package/docs/pages/components/radio-group.md +242 -5
- package/docs/pages/components/radio.md +474 -6
- package/docs/pages/components/rating.md +331 -7
- package/docs/pages/components/reveal.md +524 -6
- package/docs/pages/components/scroll-container.md +552 -6
- package/docs/pages/components/select.md +762 -160
- package/docs/pages/components/skeleton.md +473 -30
- package/docs/pages/components/slideout.md +261 -5
- package/docs/pages/components/sp.md +99 -41
- package/docs/pages/components/split-button.md +347 -9
- package/docs/pages/components/split-pane.md +445 -6
- package/docs/pages/components/stat.md +549 -9
- package/docs/pages/components/status-indicator.md +230 -1
- package/docs/pages/components/stepper.md +563 -6
- package/docs/pages/components/tabs.md +439 -13
- package/docs/pages/components/textarea.md +415 -17
- package/docs/pages/components/tile.md +385 -26
- package/docs/pages/components/toggle.md +424 -6
- package/docs/pages/components/tooltip.md +367 -0
- package/docs/pages/components/translation-group.md +210 -0
- package/docs/pages/components/translations.md +319 -19
- package/docs/pages/components/vertical-stepper.md +401 -8
- package/docs/pages/components/well.md +300 -3
- package/docs/pages/getting-started/form-controls.md +162 -0
- package/docs/pages/index.md +116 -15
- package/package.json +5 -6
- package/scss/_global-spacing.scss +4 -0
- package/scss/_root.scss +2 -2
- package/scss/boot.scss +19 -0
- package/scss/shared/layout.scss +5 -0
- package/scss/themes/_light.scss +3 -3
- package/src/components/alert/alert.scss +1 -0
- package/src/components/animated-button/README.md +306 -0
- package/src/components/animated-button/animated-button.component.ts +229 -0
- package/src/components/animated-button/animated-button.scss +228 -0
- package/src/components/animated-button/animated-button.test.ts +143 -0
- package/src/components/animated-button/index.ts +12 -0
- package/src/components/button/button.component.ts +5 -0
- package/src/components/button-group/button-group.component.ts +25 -13
- package/src/components/button-group/button-group.scss +6 -0
- package/src/components/checkbox/checkbox.component.ts +4 -0
- package/src/components/checkbox/checkbox.scss +7 -4
- package/src/components/checkbox-group/checkbox-group.scss +7 -0
- package/src/components/chip/chip.component.ts +7 -2
- package/src/components/chip/chip.scss +16 -2
- package/src/components/collapsible/collapsible.component.ts +27 -20
- package/src/components/cols/cols.component.ts +14 -2
- package/src/components/cols/cols.scss +6 -12
- package/src/components/confirm/confirm.component.ts +7 -0
- package/src/components/copy-button/copy-button.component.ts +12 -11
- package/src/components/data-select/data-select.component.ts +215 -44
- package/src/components/data-select/data-select.scss +66 -6
- package/src/components/data-select/providers/currency-data-provider.ts +20 -6
- package/src/components/data-select/providers/provider.ts +1 -0
- package/src/components/data-select/providers/us-state-data-provider.ts +68 -0
- package/src/components/data-table/data-table.component.ts +81 -22
- package/src/components/data-table-search/data-table-search.component.ts +184 -0
- package/src/components/data-table-search/data-table-search.scss +17 -0
- package/src/components/data-table-search/data-table-search.test.ts +11 -0
- package/src/components/data-table-search/index.ts +12 -0
- package/src/components/datepicker/datepicker.component.ts +347 -13
- package/src/components/dialog/dialog.component.ts +1 -1
- package/src/components/empty-state/empty-state.scss +6 -1
- package/src/components/header/header.scss +3 -3
- package/src/components/icon/icon.component.ts +23 -1
- package/src/components/icon/icon.scss +23 -0
- package/src/components/icon-picker/brand-icons.ts +24 -0
- package/src/components/icon-picker/icon-picker.component.ts +407 -0
- package/src/components/icon-picker/icon-picker.scss +205 -0
- package/src/components/icon-picker/index.ts +12 -0
- package/src/components/icon-picker/line-icons.ts +612 -0
- package/src/components/icon-picker/material-icons.ts +14543 -0
- package/src/components/inline-edit/inline-edit.component.ts +190 -46
- package/src/components/inline-edit/inline-edit.scss +29 -0
- package/src/components/inline-edit/inline-edit.test.ts +314 -1
- package/src/components/input/input.component.ts +324 -5
- package/src/components/input/input.scss +87 -0
- package/src/components/input-group/input-group.component.ts +28 -7
- package/src/components/input-group/input-group.scss +48 -10
- package/src/components/item/item.component.ts +24 -3
- package/src/components/item/item.scss +18 -0
- package/src/components/key/index.ts +12 -0
- package/src/components/key/key.component.ts +47 -0
- package/src/components/key/key.scss +38 -0
- package/src/components/key-container/index.ts +12 -0
- package/src/components/key-container/key-container.component.ts +142 -0
- package/src/components/key-container/key-container.scss +33 -0
- package/src/components/menu-item/menu-item.component.ts +20 -0
- package/src/components/menu-item/menu-item.scss +69 -2
- package/src/components/navbar/navbar.component.ts +103 -11
- package/src/components/navbar/navbar.scss +6 -1
- package/src/components/opt-group/index.ts +12 -0
- package/src/components/opt-group/opt-group.component.ts +74 -0
- package/src/components/opt-group/opt-group.scss +37 -0
- package/src/components/opt-group/opt-group.test.ts +27 -0
- package/src/components/option/option.component.ts +1 -16
- package/src/components/option/option.scss +4 -0
- package/src/components/panel/panel.component.ts +10 -8
- package/src/components/panel/panel.scss +20 -0
- package/src/components/priority-list/index.ts +12 -0
- package/src/components/priority-list/priority-list.component.ts +611 -0
- package/src/components/priority-list/priority-list.scss +185 -0
- package/src/components/priority-list/priority-list.test.ts +139 -0
- package/src/components/progress-bar/progress-bar.component.ts +22 -16
- package/src/components/radio/radio.scss +10 -3
- package/src/components/select/select.component.ts +812 -72
- package/src/components/select/select.scss +108 -2
- package/src/components/select/select.test.ts +147 -2
- package/src/components/settings-container/settings-container.component.ts +44 -19
- package/src/components/settings-container/settings-container.scss +1 -1
- package/src/components/skeleton/skeleton.component.ts +6 -1
- package/src/components/slideout/slideout.scss +8 -3
- package/src/components/sp/sp.component.ts +3 -1
- package/src/components/sp/sp.scss +19 -0
- package/src/components/stepper/stepper.component.ts +16 -10
- package/src/components/textarea/textarea.scss +0 -4
- package/src/components/tile/tile.component.ts +12 -3
- package/src/components/tile/tile.scss +1 -1
- package/src/components/timer/timer.component.ts +15 -2
- package/src/components/toggle/toggle.component.ts +29 -26
- package/src/components/toggle/toggle.scss +13 -1
- package/src/components/translation-group/index.ts +12 -0
- package/src/components/translation-group/translation-group.component.ts +207 -0
- package/src/components/translation-group/translation-group.scss +8 -0
- package/src/components/translations/translations.component.ts +90 -44
- package/src/components/translations/translations.scss +4 -0
- package/src/components/vertical-stepper/vertical-stepper.component.ts +14 -9
- package/src/events/events.ts +12 -7
- package/src/events/zn-language-change.ts +7 -0
- package/src/events/zn-purchase.ts +11 -0
- package/src/events/zn-redirect.ts +7 -0
- package/src/events/zn-reorder.ts +7 -0
- package/src/events/zn-search-change.ts +11 -0
- package/src/events/zn-submit.ts +1 -1
- package/src/form-control.scss +4 -0
- package/src/internal/form-navigation.ts +510 -0
- package/src/internal/form.ts +6 -0
- package/src/zinc.ts +91 -83
|
@@ -1,27 +1,383 @@
|
|
|
1
1
|
---
|
|
2
2
|
meta:
|
|
3
3
|
title: Data Chart
|
|
4
|
-
description:
|
|
4
|
+
description: Charts visualize data using various chart types powered by ApexCharts. Display line charts, bar charts, area charts, and more with full customization options.
|
|
5
5
|
layout: component
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
```html:preview
|
|
9
|
-
<zn-chart
|
|
10
|
-
type="area"
|
|
11
|
-
categories="["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep"]"
|
|
12
|
-
data="[{"name":"Series 1","data":[30,40,45,50,49,60,70,91,125]}]"
|
|
9
|
+
<zn-chart
|
|
10
|
+
type="area"
|
|
11
|
+
categories="["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep"]"
|
|
12
|
+
data="[{"name":"Series 1","data":[30,40,45,50,49,60,70,91,125]}]"
|
|
13
13
|
height="300">
|
|
14
14
|
</zn-chart>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
:::tip
|
|
18
|
+
The chart component is built on ApexCharts, providing a powerful and flexible charting library with extensive customization options. Visit the [ApexCharts documentation](https://apexcharts.com/docs/) for advanced configuration options.
|
|
19
|
+
:::
|
|
20
|
+
|
|
17
21
|
## Examples
|
|
18
22
|
|
|
19
|
-
###
|
|
23
|
+
### Basic Line Chart
|
|
24
|
+
|
|
25
|
+
Use `type="line"` to create a line chart. The `data` attribute accepts an array of series objects, and `categories` defines the x-axis labels.
|
|
26
|
+
|
|
27
|
+
```html:preview
|
|
28
|
+
<zn-chart
|
|
29
|
+
type="line"
|
|
30
|
+
categories="["Jan","Feb","Mar","Apr","May","Jun"]"
|
|
31
|
+
data="[{"name":"Revenue","data":[30,40,35,50,49,60]},{"name":"Expenses","data":[20,29,25,35,39,45]}]"
|
|
32
|
+
height="300">
|
|
33
|
+
</zn-chart>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Bar Chart
|
|
37
|
+
|
|
38
|
+
Use `type="bar"` to create a vertical bar chart. Perfect for comparing values across categories.
|
|
39
|
+
|
|
40
|
+
```html:preview
|
|
41
|
+
<zn-chart
|
|
42
|
+
type="bar"
|
|
43
|
+
categories="["Q1","Q2","Q3","Q4"]"
|
|
44
|
+
data="[{"name":"Sales","data":[44,55,57,56]},{"name":"Returns","data":[13,23,20,8]}]"
|
|
45
|
+
height="300">
|
|
46
|
+
</zn-chart>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Area Chart
|
|
50
|
+
|
|
51
|
+
Use `type="area"` to create an area chart with filled regions under the line.
|
|
52
|
+
|
|
53
|
+
```html:preview
|
|
54
|
+
<zn-chart
|
|
55
|
+
type="area"
|
|
56
|
+
categories="["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]"
|
|
57
|
+
data="[{"name":"Active Users","data":[150,200,180,220,240,280,260]}]"
|
|
58
|
+
height="300">
|
|
59
|
+
</zn-chart>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Multiple Series
|
|
63
|
+
|
|
64
|
+
Charts support multiple data series. Each series appears with its own color and legend entry.
|
|
65
|
+
|
|
66
|
+
```html:preview
|
|
67
|
+
<zn-chart
|
|
68
|
+
type="line"
|
|
69
|
+
categories="["Week 1","Week 2","Week 3","Week 4"]"
|
|
70
|
+
data="[{"name":"Product A","data":[45,52,48,61]},{"name":"Product B","data":[35,41,36,46]},{"name":"Product C","data":[25,28,32,38]}]"
|
|
71
|
+
height="350">
|
|
72
|
+
</zn-chart>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Stacked Bar Chart
|
|
76
|
+
|
|
77
|
+
Use the `stacked` attribute to create stacked bar charts where series are stacked on top of each other.
|
|
78
|
+
|
|
79
|
+
```html:preview
|
|
80
|
+
<zn-chart
|
|
81
|
+
type="bar"
|
|
82
|
+
stacked
|
|
83
|
+
categories="["Jan","Feb","Mar","Apr","May"]"
|
|
84
|
+
data="[{"name":"Direct","data":[44,55,41,37,22]},{"name":"Referral","data":[53,32,33,52,13]},{"name":"Organic","data":[12,17,11,9,15]}]"
|
|
85
|
+
height="300">
|
|
86
|
+
</zn-chart>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Stacked Area Chart
|
|
90
|
+
|
|
91
|
+
Stacked area charts work similarly to stacked bar charts but with area fills.
|
|
92
|
+
|
|
93
|
+
```html:preview
|
|
94
|
+
<zn-chart
|
|
95
|
+
type="area"
|
|
96
|
+
stacked
|
|
97
|
+
categories="["Jan","Feb","Mar","Apr","May","Jun"]"
|
|
98
|
+
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
|
+
height="300">
|
|
100
|
+
</zn-chart>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Chart Heights
|
|
104
|
+
|
|
105
|
+
Use the `height` attribute to control the chart's height in pixels. The default height is 300px.
|
|
106
|
+
|
|
107
|
+
```html:preview
|
|
108
|
+
<zn-chart
|
|
109
|
+
type="bar"
|
|
110
|
+
categories="["Small","Medium","Large"]"
|
|
111
|
+
data="[{"name":"Orders","data":[12,19,15]}]"
|
|
112
|
+
height="200">
|
|
113
|
+
</zn-chart>
|
|
114
|
+
<br />
|
|
115
|
+
<zn-chart
|
|
116
|
+
type="line"
|
|
117
|
+
categories="["Jan","Feb","Mar","Apr"]"
|
|
118
|
+
data="[{"name":"Sales","data":[40,55,45,60]}]"
|
|
119
|
+
height="400">
|
|
120
|
+
</zn-chart>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Data Point Markers
|
|
124
|
+
|
|
125
|
+
Use the `d-size` attribute to control the size of data point markers on line and area charts. Default size is 1.
|
|
126
|
+
|
|
127
|
+
```html:preview
|
|
128
|
+
<zn-chart
|
|
129
|
+
type="line"
|
|
130
|
+
categories="["Jan","Feb","Mar","Apr","May"]"
|
|
131
|
+
data="[{"name":"Small Markers","data":[30,40,35,50,49]}]"
|
|
132
|
+
d-size="1"
|
|
133
|
+
height="250">
|
|
134
|
+
</zn-chart>
|
|
135
|
+
<br />
|
|
136
|
+
<zn-chart
|
|
137
|
+
type="line"
|
|
138
|
+
categories="["Jan","Feb","Mar","Apr","May"]"
|
|
139
|
+
data="[{"name":"Large Markers","data":[30,40,35,50,49]}]"
|
|
140
|
+
d-size="6"
|
|
141
|
+
height="250">
|
|
142
|
+
</zn-chart>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Y-Axis Formatting
|
|
146
|
+
|
|
147
|
+
Use `y-axis-append` to add a suffix to y-axis labels and tooltip values. Common uses include units like `%`, `$`, `K`, `M`, etc.
|
|
148
|
+
|
|
149
|
+
```html:preview
|
|
150
|
+
<zn-chart
|
|
151
|
+
type="bar"
|
|
152
|
+
categories="["Product A","Product B","Product C"]"
|
|
153
|
+
data="[{"name":"Market Share","data":[25,35,40]}]"
|
|
154
|
+
y-axis-append="%"
|
|
155
|
+
height="300">
|
|
156
|
+
</zn-chart>
|
|
157
|
+
<br />
|
|
158
|
+
<zn-chart
|
|
159
|
+
type="line"
|
|
160
|
+
categories="["Jan","Feb","Mar","Apr"]"
|
|
161
|
+
data="[{"name":"Revenue","data":[100,120,115,140]}]"
|
|
162
|
+
y-axis-append="K"
|
|
163
|
+
height="300">
|
|
164
|
+
</zn-chart>
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Time Series with X-Axis Type
|
|
168
|
+
|
|
169
|
+
Use the `x-axis` attribute to specify the x-axis type. Common values include `datetime`, `category`, and `numeric`.
|
|
170
|
+
|
|
171
|
+
```html:preview
|
|
172
|
+
<zn-chart
|
|
173
|
+
type="line"
|
|
174
|
+
x-axis="datetime"
|
|
175
|
+
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
|
+
height="300">
|
|
177
|
+
</zn-chart>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
:::tip
|
|
181
|
+
When using `x-axis="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
|
+
:::
|
|
183
|
+
|
|
184
|
+
### Enable Animations
|
|
185
|
+
|
|
186
|
+
By default, animations are disabled for better performance. Use the `enable-animations` attribute to enable chart animations.
|
|
187
|
+
|
|
188
|
+
```html:preview
|
|
189
|
+
<zn-chart
|
|
190
|
+
type="bar"
|
|
191
|
+
categories="["A","B","C","D","E"]"
|
|
192
|
+
data="[{"name":"Values","data":[44,55,41,37,52]}]"
|
|
193
|
+
enable-animations
|
|
194
|
+
height="300">
|
|
195
|
+
</zn-chart>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Single Series Chart
|
|
199
|
+
|
|
200
|
+
For simple visualizations, use a single data series without multiple comparisons.
|
|
201
|
+
|
|
202
|
+
```html:preview
|
|
203
|
+
<zn-chart
|
|
204
|
+
type="area"
|
|
205
|
+
categories="["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"]"
|
|
206
|
+
data="[{"name":"Page Views","data":[1200,1900,1500,2200,2400,2800,2600,3100]}]"
|
|
207
|
+
height="300">
|
|
208
|
+
</zn-chart>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Empty State
|
|
212
|
+
|
|
213
|
+
When no data is available, the chart will display an empty state. Consider adding custom messaging around the chart component.
|
|
214
|
+
|
|
215
|
+
```html:preview
|
|
216
|
+
<zn-chart
|
|
217
|
+
type="line"
|
|
218
|
+
categories="[]"
|
|
219
|
+
data="[]"
|
|
220
|
+
height="300">
|
|
221
|
+
</zn-chart>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Dark Mode Support
|
|
225
|
+
|
|
226
|
+
The chart component automatically adapts to dark mode using the `t` attribute. The theme adjusts colors, gridlines, and text to match the current theme.
|
|
227
|
+
|
|
228
|
+
```html:preview
|
|
229
|
+
<zn-chart
|
|
230
|
+
t="dark"
|
|
231
|
+
type="area"
|
|
232
|
+
categories="["Mon","Tue","Wed","Thu","Fri"]"
|
|
233
|
+
data="[{"name":"Series 1","data":[30,40,35,50,49]},{"name":"Series 2","data":[25,35,30,45,42]}]"
|
|
234
|
+
height="300">
|
|
235
|
+
</zn-chart>
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Responsive Charts
|
|
239
|
+
|
|
240
|
+
Charts automatically resize to fit their container. The width adapts to the parent element while height is controlled by the `height` attribute.
|
|
241
|
+
|
|
242
|
+
```html:preview
|
|
243
|
+
<div style="width: 100%; max-width: 600px;">
|
|
244
|
+
<zn-chart
|
|
245
|
+
type="bar"
|
|
246
|
+
categories="["Mobile","Desktop","Tablet"]"
|
|
247
|
+
data="[{"name":"Sessions","data":[450,680,320]}]"
|
|
248
|
+
height="300">
|
|
249
|
+
</zn-chart>
|
|
250
|
+
</div>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Combining Different Configurations
|
|
254
|
+
|
|
255
|
+
You can combine various attributes to create rich, informative charts.
|
|
256
|
+
|
|
257
|
+
```html:preview
|
|
258
|
+
<zn-chart
|
|
259
|
+
type="line"
|
|
260
|
+
categories="["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug"]"
|
|
261
|
+
data="[{"name":"Target","data":[80,85,82,90,88,95,92,98]},{"name":"Actual","data":[75,82,78,88,91,97,94,102]}]"
|
|
262
|
+
d-size="4"
|
|
263
|
+
y-axis-append="%"
|
|
264
|
+
height="350"
|
|
265
|
+
enable-animations>
|
|
266
|
+
</zn-chart>
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Data Format
|
|
270
|
+
|
|
271
|
+
The chart component accepts data in JSON format through the `data` attribute. The data should be an array of series objects.
|
|
272
|
+
|
|
273
|
+
### Basic Series Format
|
|
274
|
+
|
|
275
|
+
```json
|
|
276
|
+
[
|
|
277
|
+
{
|
|
278
|
+
"name": "Series Name",
|
|
279
|
+
"data": [10, 20, 30, 40, 50]
|
|
280
|
+
}
|
|
281
|
+
]
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Multiple Series Format
|
|
285
|
+
|
|
286
|
+
```json
|
|
287
|
+
[
|
|
288
|
+
{
|
|
289
|
+
"name": "Series 1",
|
|
290
|
+
"data": [10, 20, 30, 40, 50]
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"name": "Series 2",
|
|
294
|
+
"data": [15, 25, 35, 45, 55]
|
|
295
|
+
}
|
|
296
|
+
]
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Time Series Format
|
|
300
|
+
|
|
301
|
+
When using `x-axis="datetime"`, use the coordinate format:
|
|
302
|
+
|
|
303
|
+
```json
|
|
304
|
+
[
|
|
305
|
+
{
|
|
306
|
+
"name": "Time Series",
|
|
307
|
+
"data": [
|
|
308
|
+
{"x": 1609459200000, "y": 30},
|
|
309
|
+
{"x": 1612137600000, "y": 40},
|
|
310
|
+
{"x": 1614556800000, "y": 35}
|
|
311
|
+
]
|
|
312
|
+
}
|
|
313
|
+
]
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### HTML Encoding
|
|
317
|
+
|
|
318
|
+
When using the data attribute in HTML, JSON must be properly encoded. Use `"` for quotes:
|
|
319
|
+
|
|
320
|
+
```html
|
|
321
|
+
<zn-chart
|
|
322
|
+
data="[{"name":"Sales","data":[10,20,30]}]"
|
|
323
|
+
categories="["A","B","C"]">
|
|
324
|
+
</zn-chart>
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## JavaScript API
|
|
328
|
+
|
|
329
|
+
You can also interact with the chart component using JavaScript:
|
|
330
|
+
|
|
331
|
+
```javascript
|
|
332
|
+
// Get chart element
|
|
333
|
+
const chart = document.querySelector('zn-chart');
|
|
334
|
+
|
|
335
|
+
// Set data programmatically
|
|
336
|
+
chart.data = [
|
|
337
|
+
{ name: 'Series 1', data: [10, 20, 30, 40] }
|
|
338
|
+
];
|
|
339
|
+
|
|
340
|
+
// Set categories
|
|
341
|
+
chart.categories = ['Q1', 'Q2', 'Q3', 'Q4'];
|
|
342
|
+
|
|
343
|
+
// Change chart type
|
|
344
|
+
chart.type = 'bar';
|
|
345
|
+
|
|
346
|
+
// Update height
|
|
347
|
+
chart.height = 400;
|
|
348
|
+
|
|
349
|
+
// Enable animations
|
|
350
|
+
chart.enableAnimations = true;
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Best Practices
|
|
354
|
+
|
|
355
|
+
### Choosing Chart Types
|
|
356
|
+
|
|
357
|
+
- **Line Charts**: Best for showing trends over time or continuous data
|
|
358
|
+
- **Bar Charts**: Ideal for comparing discrete categories or values
|
|
359
|
+
- **Area Charts**: Good for showing cumulative totals or part-to-whole relationships over time
|
|
360
|
+
- **Stacked Charts**: Use when showing how categories contribute to a total
|
|
361
|
+
|
|
362
|
+
### Performance Considerations
|
|
363
|
+
|
|
364
|
+
- Keep the number of data points reasonable (under 1000 points for optimal performance)
|
|
365
|
+
- Disable animations by default for better initial render performance
|
|
366
|
+
- Use appropriate chart heights based on the amount of data being displayed
|
|
367
|
+
- Consider using the `live` mode only when necessary, as it can impact performance
|
|
368
|
+
|
|
369
|
+
### Accessibility
|
|
20
370
|
|
|
21
|
-
|
|
371
|
+
- Ensure chart data is also available in an accessible format (table, list, etc.)
|
|
372
|
+
- Use descriptive series names that clearly identify the data
|
|
373
|
+
- Choose appropriate colors that provide sufficient contrast
|
|
374
|
+
- Consider adding supplementary text descriptions for complex charts
|
|
22
375
|
|
|
23
|
-
###
|
|
376
|
+
### Data Formatting
|
|
24
377
|
|
|
25
|
-
|
|
378
|
+
- Use consistent units across related charts
|
|
379
|
+
- Round values appropriately for readability
|
|
380
|
+
- Use `y-axis-append` to add units or symbols to values
|
|
381
|
+
- Format dates consistently when using time series data
|
|
26
382
|
|
|
27
383
|
|