cats-charts 0.0.37 → 0.0.38
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/README.md +473 -341
- package/assets/images/headerIcon.svg +3 -3
- package/assets/images/infoIcon.svg +10 -10
- package/assets/images/leftArrow.svg +3 -3
- package/assets/images/rightArrow.svg +3 -3
- package/fesm2022/cats-charts.mjs +439 -214
- package/fesm2022/cats-charts.mjs.map +1 -1
- package/index.d.ts +60 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,341 +1,473 @@
|
|
|
1
|
-
# CATS4U Charts
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-

|
|
7
|
-
|
|
8
|
-
**CATS4U Charts** is a reusable Angular chart library built on **Apache ECharts** and **ngx-echarts**.
|
|
9
|
-
It provides easy-to-use components for rendering interactive charts such as **Bar, Line, Area, Pie, Doughnut, Sankey, Timeline**, and more.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
# ✨ Features
|
|
14
|
-
|
|
15
|
-
- 📊 Multiple chart types
|
|
16
|
-
- ⚡ Powered by Apache ECharts
|
|
17
|
-
- 🔌 Angular Standalone Components
|
|
18
|
-
- 🎨 Built-in theme support
|
|
19
|
-
- 🖱 Click & drill-down events
|
|
20
|
-
- 🧩 Easy integration
|
|
21
|
-
- 📦 Lightweight and reusable
|
|
22
|
-
|
|
23
|
-
---
|
|
24
|
-
|
|
25
|
-
# 📦 Installation
|
|
26
|
-
|
|
27
|
-
Install the package along with required dependencies:
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
npm install cats-charts
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
-
|
|
302
|
-
-
|
|
303
|
-
-
|
|
304
|
-
-
|
|
305
|
-
-
|
|
306
|
-
-
|
|
307
|
-
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
1
|
+
# CATS4U Charts
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
**CATS4U Charts** is a reusable Angular chart library built on **Apache ECharts** and **ngx-echarts**.
|
|
9
|
+
It provides easy-to-use components for rendering interactive charts such as **Bar, Line, Area, Pie, Doughnut, Sankey, Timeline**, and more.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# ✨ Features
|
|
14
|
+
|
|
15
|
+
- 📊 Multiple chart types
|
|
16
|
+
- ⚡ Powered by Apache ECharts
|
|
17
|
+
- 🔌 Angular Standalone Components
|
|
18
|
+
- 🎨 Built-in theme support
|
|
19
|
+
- 🖱 Click & drill-down events
|
|
20
|
+
- 🧩 Easy integration
|
|
21
|
+
- 📦 Lightweight and reusable
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
# 📦 Installation
|
|
26
|
+
|
|
27
|
+
Install the package along with required dependencies:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install cats-charts
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
# 🚀 Usage
|
|
35
|
+
|
|
36
|
+
## Import Library
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { ChartsLib } from 'cats-charts';
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## TS Syntax
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import {
|
|
46
|
+
BarChart,
|
|
47
|
+
CustomChartComponent,
|
|
48
|
+
DoughnutChart,
|
|
49
|
+
LinesChart,
|
|
50
|
+
PieChart,
|
|
51
|
+
SankeyChart
|
|
52
|
+
} from 'cats-charts';
|
|
53
|
+
|
|
54
|
+
@Component({
|
|
55
|
+
...,
|
|
56
|
+
imports: [
|
|
57
|
+
BarChart,
|
|
58
|
+
CustomChartComponent,
|
|
59
|
+
DoughnutChart,
|
|
60
|
+
LinesChart,
|
|
61
|
+
PieChart,
|
|
62
|
+
SankeyChart
|
|
63
|
+
],
|
|
64
|
+
})
|
|
65
|
+
export class App {}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
# ⚙️ Inputs
|
|
71
|
+
|
|
72
|
+
| Input | Type | Description |
|
|
73
|
+
| ------------------ | ------------------------------------------------- | -------------------------------------------------------------- |
|
|
74
|
+
| config | | Configuration options to customize chart and pass dynamic data |
|
|
75
|
+
| theme | string | default \| dark \| vintage \| essos \| chalk \| roma |
|
|
76
|
+
| contextMenuOptions | { label: string; value: string; icon?: string }[] | Context menu options |
|
|
77
|
+
| events | string[] | ['click', 'contextmenu', 'dblclick'] |
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
# 📤 Outputs
|
|
82
|
+
|
|
83
|
+
| Output | Description |
|
|
84
|
+
| ---------------- | ---------------------- |
|
|
85
|
+
| contextMenuClick | ( event: any ) => void |
|
|
86
|
+
| chartEvent | ( event: any ) => void |
|
|
87
|
+
|
|
88
|
+
## Bar chart config
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
BarChartConfig {
|
|
92
|
+
series: {
|
|
93
|
+
name: string;
|
|
94
|
+
data: number[];
|
|
95
|
+
[key: string]: any;
|
|
96
|
+
}[];
|
|
97
|
+
xAxisData: string[];
|
|
98
|
+
colors?: string[];
|
|
99
|
+
backgroundColor?: string;
|
|
100
|
+
|
|
101
|
+
// --------------- Title configs ---------------
|
|
102
|
+
title?: string;
|
|
103
|
+
titlePosition?: string;
|
|
104
|
+
showTitle?: boolean;
|
|
105
|
+
|
|
106
|
+
// --------------- Tooltip configs ---------------
|
|
107
|
+
showTooltip?: boolean;
|
|
108
|
+
tooltipFormatter?: (params: any) => void;
|
|
109
|
+
|
|
110
|
+
// --------------- Grid configs ---------------
|
|
111
|
+
gridLeft?: string | number;
|
|
112
|
+
gridRight?: string | number;
|
|
113
|
+
gridBottom?: string | number;
|
|
114
|
+
gridTop?: string | number;
|
|
115
|
+
|
|
116
|
+
// --------------- Zoom Slider configs ---------------
|
|
117
|
+
showZoomSlider?: boolean;
|
|
118
|
+
zoomStart?: number;
|
|
119
|
+
zoomEnd?: number;
|
|
120
|
+
zoomControlButtonStyle?: any;
|
|
121
|
+
|
|
122
|
+
yAxis?: any;
|
|
123
|
+
xAxis?: any;
|
|
124
|
+
stacked?: boolean;
|
|
125
|
+
|
|
126
|
+
barWidth?: string | number;
|
|
127
|
+
|
|
128
|
+
borderRadius?: number;
|
|
129
|
+
showLabel?: boolean;
|
|
130
|
+
labelPosition?: string;
|
|
131
|
+
showXAxisLine?: boolean;
|
|
132
|
+
showYAxisLine?: boolean;
|
|
133
|
+
// Legend
|
|
134
|
+
hideLegend?: boolean;
|
|
135
|
+
legendPosition?: 'top' | 'bottom' | 'left' | 'right' | string;
|
|
136
|
+
legendAlign?: 'left' | 'center' | 'right' | string;
|
|
137
|
+
legendDirection?: 'horizontal' | 'vertical' | string;
|
|
138
|
+
legendTextColor?: string;
|
|
139
|
+
legendFontSize?: number;
|
|
140
|
+
legendContainerWidth?: number; // 0-1
|
|
141
|
+
legendIndicatorHeight?: number; // number value is in px
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Line and Area Chart config
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
LineChartConfig {
|
|
149
|
+
isTrendChart?: boolean;
|
|
150
|
+
title?: string;
|
|
151
|
+
showTitle?: boolean;
|
|
152
|
+
titlePosition?: string;
|
|
153
|
+
xAxisData: string[];
|
|
154
|
+
tooltipFormatter?: (params: any) => void;
|
|
155
|
+
colors?: string[];
|
|
156
|
+
series: {
|
|
157
|
+
name: string;
|
|
158
|
+
data: number[];
|
|
159
|
+
areaColor?: string;
|
|
160
|
+
smooth?: boolean;
|
|
161
|
+
area?: boolean;
|
|
162
|
+
[key: string]: any;
|
|
163
|
+
}[];
|
|
164
|
+
// --------------- Grid configs ---------------
|
|
165
|
+
gridLeft?: string | number;
|
|
166
|
+
gridRight?: string | number;
|
|
167
|
+
gridBottom?: string | number;
|
|
168
|
+
gridTop?: string | number;
|
|
169
|
+
|
|
170
|
+
borderRadius?: number;
|
|
171
|
+
showLabel?: boolean;
|
|
172
|
+
labelPosition?: string;
|
|
173
|
+
|
|
174
|
+
yAxis?: any;
|
|
175
|
+
xAxis?: any;
|
|
176
|
+
showXAxisLine?: boolean;
|
|
177
|
+
showYAxisLine?: boolean;
|
|
178
|
+
showTooltip?: boolean;
|
|
179
|
+
|
|
180
|
+
backgroundColor?: string;
|
|
181
|
+
|
|
182
|
+
// Legend
|
|
183
|
+
hideLegend?: boolean;
|
|
184
|
+
legendPosition?: 'top' | 'bottom' | 'left' | 'right' | string;
|
|
185
|
+
legendAlign?: 'left' | 'center' | 'right' | string;
|
|
186
|
+
legendDirection?: 'horizontal' | 'vertical' | string;
|
|
187
|
+
legendTextColor?: string;
|
|
188
|
+
legendFontSize?: number;
|
|
189
|
+
legendContainerWidth?: number; // 0-1
|
|
190
|
+
legendIndicatorHeight?: number; // number value is in px
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Pie and Donut chart config
|
|
195
|
+
|
|
196
|
+
```ts
|
|
197
|
+
DoughnutChartConfig {
|
|
198
|
+
title?: string;
|
|
199
|
+
showTitle?: boolean;
|
|
200
|
+
titlePosition?: 'left' | 'center' | 'right';
|
|
201
|
+
top?: any;
|
|
202
|
+
bottom?: any;
|
|
203
|
+
backgroundColor?: string;
|
|
204
|
+
series?: any;
|
|
205
|
+
data: {
|
|
206
|
+
name: string;
|
|
207
|
+
value: number;
|
|
208
|
+
[key: string]: any;
|
|
209
|
+
}[];
|
|
210
|
+
|
|
211
|
+
colors?: string[];
|
|
212
|
+
|
|
213
|
+
// Doughnut
|
|
214
|
+
innerRadius?: string;
|
|
215
|
+
outerRadius?: string;
|
|
216
|
+
center?: string[];
|
|
217
|
+
// Center Text
|
|
218
|
+
showCenterText?: boolean;
|
|
219
|
+
centerLabel?: any;
|
|
220
|
+
centerValue?: string;
|
|
221
|
+
centerValueFromTotal?: boolean;
|
|
222
|
+
|
|
223
|
+
// Tooltip
|
|
224
|
+
showTooltip?: boolean;
|
|
225
|
+
showTooltipPercent?: boolean;
|
|
226
|
+
tooltipFormatter?: (params: any, config: DoughnutChartConfig) => void;
|
|
227
|
+
valueFormatter?: (value: number) => string;
|
|
228
|
+
|
|
229
|
+
// Legend
|
|
230
|
+
hideLegend?: boolean;
|
|
231
|
+
legendBottom?: number;
|
|
232
|
+
legendPosition?: 'top' | 'bottom' | 'left' | 'right' | string;
|
|
233
|
+
legendAlign?: 'left' | 'center' | 'right' | string;
|
|
234
|
+
legendDirection?: 'horizontal' | 'vertical' | string;
|
|
235
|
+
legendTextColor?: string;
|
|
236
|
+
legendFontSize?: number;
|
|
237
|
+
legendContainerWidth?: number; // 0-1
|
|
238
|
+
// Labels
|
|
239
|
+
showLabel?: boolean;
|
|
240
|
+
labelPosition?: 'inside' | 'outside' | 'center';
|
|
241
|
+
showLabelValue?: boolean;
|
|
242
|
+
showLabelPercentage?: boolean;
|
|
243
|
+
|
|
244
|
+
// Emphasis
|
|
245
|
+
emphasisScale?: boolean;
|
|
246
|
+
|
|
247
|
+
// Style
|
|
248
|
+
borderRadius?: number;
|
|
249
|
+
borderColor?: string;
|
|
250
|
+
borderWidth?: number;
|
|
251
|
+
|
|
252
|
+
enableHoverEffect?: boolean;
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Custom chart config
|
|
257
|
+
|
|
258
|
+
```ts
|
|
259
|
+
CustomChartConfig {
|
|
260
|
+
startHour?: string;
|
|
261
|
+
endHour?: string;
|
|
262
|
+
|
|
263
|
+
shiftColor?: string;
|
|
264
|
+
chartMode: 'weekly' | 'daily' | string;
|
|
265
|
+
|
|
266
|
+
yAxisData: string[];
|
|
267
|
+
categories: string[];
|
|
268
|
+
legends: TimeLineLegends;
|
|
269
|
+
|
|
270
|
+
barHeight?: number;
|
|
271
|
+
shiftHeight?: number;
|
|
272
|
+
|
|
273
|
+
data: TimelineData[];
|
|
274
|
+
hideLegendCategory?: boolean;
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Sankey Chart config
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
SankeyChartConfig {
|
|
282
|
+
title?: string;
|
|
283
|
+
showTitle?: boolean;
|
|
284
|
+
backgroundColor?: string;
|
|
285
|
+
colors?: string[];
|
|
286
|
+
showTooltip?: boolean;
|
|
287
|
+
tooltipFormatter?: (params: any) => string;
|
|
288
|
+
nodes: SankeyNode[];
|
|
289
|
+
links: SankeyLink[];
|
|
290
|
+
seriesOption?: SankeySeriesOption;
|
|
291
|
+
lineCurveness?: number;
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### For `SankeySeriesOption` refer echarts Sankey series documentation
|
|
296
|
+
|
|
297
|
+
https://echarts.apache.org/en/option.html#series-sankey
|
|
298
|
+
|
|
299
|
+
# 📊 Supported Charts
|
|
300
|
+
|
|
301
|
+
- Bar Chart
|
|
302
|
+
- Line Chart
|
|
303
|
+
- Area Chart
|
|
304
|
+
- Pie Chart
|
|
305
|
+
- Doughnut Chart
|
|
306
|
+
- Stacked Area Chart
|
|
307
|
+
- Sankey Chart
|
|
308
|
+
- Heatmap Chart
|
|
309
|
+
- Custom Charts
|
|
310
|
+
|
|
311
|
+
* Bar Chart
|
|
312
|
+
* Line Chart
|
|
313
|
+
* Area Chart
|
|
314
|
+
* Pie Chart
|
|
315
|
+
* Doughnut Chart
|
|
316
|
+
* Stacked Area Chart
|
|
317
|
+
* Sankey Chart
|
|
318
|
+
* Custom Charts
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
# Heatmap Chart
|
|
323
|
+
|
|
324
|
+
The heatmap component renders category-based intensity data using Apache ECharts.
|
|
325
|
+
Use `[xIndex, yIndex, value]` tuples, where `xIndex` points to `xAxisData` and `yIndex` points to `yAxisData`.
|
|
326
|
+
|
|
327
|
+
## Import
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
import { Heatmap } from 'cats-charts';
|
|
331
|
+
|
|
332
|
+
@Component({
|
|
333
|
+
selector: 'app-root',
|
|
334
|
+
standalone: true,
|
|
335
|
+
imports: [Heatmap],
|
|
336
|
+
templateUrl: './app.html',
|
|
337
|
+
})
|
|
338
|
+
export class App {}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## HTML
|
|
342
|
+
|
|
343
|
+
```html
|
|
344
|
+
<div style="width: 100%; height: 340px">
|
|
345
|
+
<lib-heatmap
|
|
346
|
+
[config]="heatmapConfig"
|
|
347
|
+
[theme]="selectedTheme"
|
|
348
|
+
[events]="['click', 'contextmenu']"
|
|
349
|
+
(chartEvent)="handleChartEvent($event)"
|
|
350
|
+
></lib-heatmap>
|
|
351
|
+
</div>
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
## TypeScript
|
|
355
|
+
|
|
356
|
+
```ts
|
|
357
|
+
heatmapConfig = {
|
|
358
|
+
xAxisData: ['00:00', '01:00', '02:00', '03:00', '04:00', '05:00'],
|
|
359
|
+
yAxisData: ['eth0', 'eth1', 'wlan0', 'vlan10', 'vlan20'],
|
|
360
|
+
|
|
361
|
+
data: [
|
|
362
|
+
[0, 0, 20],
|
|
363
|
+
[1, 0, 60],
|
|
364
|
+
[2, 0, 0],
|
|
365
|
+
[3, 0, 40],
|
|
366
|
+
[4, 0, 80],
|
|
367
|
+
[5, 0, 100],
|
|
368
|
+
|
|
369
|
+
[0, 1, 40],
|
|
370
|
+
[1, 1, 0],
|
|
371
|
+
[2, 1, 20],
|
|
372
|
+
[3, 1, 60],
|
|
373
|
+
[4, 1, 100],
|
|
374
|
+
[5, 1, 80],
|
|
375
|
+
] as [number, number, number][],
|
|
376
|
+
|
|
377
|
+
min: 0,
|
|
378
|
+
max: 100,
|
|
379
|
+
showTooltip: true,
|
|
380
|
+
|
|
381
|
+
grid: {
|
|
382
|
+
left: 58,
|
|
383
|
+
right: 18,
|
|
384
|
+
top: 20,
|
|
385
|
+
bottom: 46,
|
|
386
|
+
containLabel: false,
|
|
387
|
+
},
|
|
388
|
+
|
|
389
|
+
xAxis: {
|
|
390
|
+
axisLabel: { color: '#6b7280' },
|
|
391
|
+
axisLine: { lineStyle: { color: '#9ca3af' } },
|
|
392
|
+
axisTick: { show: true },
|
|
393
|
+
},
|
|
394
|
+
|
|
395
|
+
yAxis: {
|
|
396
|
+
inverse: true,
|
|
397
|
+
axisLabel: { color: '#6b7280' },
|
|
398
|
+
axisLine: { show: false },
|
|
399
|
+
axisTick: { show: true },
|
|
400
|
+
},
|
|
401
|
+
|
|
402
|
+
visualMap: {
|
|
403
|
+
type: 'piecewise',
|
|
404
|
+
pieces: [
|
|
405
|
+
{ min: 0, max: 20, label: '20%', color: '#fde6bd' },
|
|
406
|
+
{ min: 21, max: 40, label: '40%', color: '#ffd85a' },
|
|
407
|
+
{ min: 41, max: 60, label: '60%', color: '#ffb247' },
|
|
408
|
+
{ min: 61, max: 80, label: '80%', color: '#ff0b1f' },
|
|
409
|
+
{ min: 81, max: 100, label: '100%', color: '#a51d29' },
|
|
410
|
+
],
|
|
411
|
+
},
|
|
412
|
+
|
|
413
|
+
series: {
|
|
414
|
+
itemStyle: {
|
|
415
|
+
borderWidth: 0,
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
};
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
## Heatmap Config Options
|
|
422
|
+
|
|
423
|
+
| Option | Type | Description |
|
|
424
|
+
| ---------------- | -------------------------- | ----------------------------------------------------------------------- |
|
|
425
|
+
| xAxisData | string[] | Labels for the x-axis |
|
|
426
|
+
| yAxisData | string[] | Labels for the y-axis |
|
|
427
|
+
| data | [number, number, number][] | Heatmap cells as `[xIndex, yIndex, value]` |
|
|
428
|
+
| min | number | Minimum value for color mapping |
|
|
429
|
+
| max | number | Maximum value for color mapping |
|
|
430
|
+
| colors | string[] | Continuous color range when `visualMap.pieces` is not used |
|
|
431
|
+
| visualMap | any | ECharts visual map config. `pieces` also drives the custom legend pills |
|
|
432
|
+
| grid | object | ECharts grid config |
|
|
433
|
+
| xAxis | any | Extra ECharts x-axis config |
|
|
434
|
+
| yAxis | any | Extra ECharts y-axis config |
|
|
435
|
+
| showTooltip | boolean | Enables or disables tooltip |
|
|
436
|
+
| tooltipFormatter | function | Custom tooltip formatter |
|
|
437
|
+
| showLabel | boolean | Shows value labels inside cells |
|
|
438
|
+
| labelFormatter | string \| function | Cell label formatter |
|
|
439
|
+
| series | any \| any[] | Extra ECharts heatmap series config |
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
# 🎨 Themes
|
|
444
|
+
|
|
445
|
+
Available chart themes:
|
|
446
|
+
|
|
447
|
+
- default
|
|
448
|
+
- dark
|
|
449
|
+
- vintage
|
|
450
|
+
- essos
|
|
451
|
+
- chalk
|
|
452
|
+
- roma
|
|
453
|
+
|
|
454
|
+
---
|
|
455
|
+
|
|
456
|
+
# 📚 Documentation
|
|
457
|
+
|
|
458
|
+
Apache ECharts documentation:
|
|
459
|
+
|
|
460
|
+
https://echarts.apache.org/en/api.html#echarts
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
# 🤝 Contributing
|
|
465
|
+
|
|
466
|
+
Contributions, issues, and feature requests are welcome.
|
|
467
|
+
Feel free to submit a pull request.
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
# 📄 License
|
|
472
|
+
|
|
473
|
+
MIT License
|