@mozaic-ds/chart 0.1.0-beta.29 → 0.1.0-beta.30
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 +1 -1
- package/dist/mozaic-chart.js +2303 -2109
- package/dist/mozaic-chart.umd.cjs +9 -9
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/assets/base.css +1 -1
- package/src/components/bar/BarChart.stories.ts +99 -99
- package/src/components/bar/BarChart.vue +70 -53
- package/src/components/bar/index.ts +3 -3
- package/src/components/bubble/BubbleChart.stories.ts +12 -12
- package/src/components/bubble/BubbleChart.vue +118 -91
- package/src/components/bubble/index.ts +3 -3
- package/src/components/doughnut/DoughnutChart.stories.ts +38 -37
- package/src/components/doughnut/DoughnutChart.vue +89 -71
- package/src/components/doughnut/index.ts +3 -3
- package/src/components/index.ts +4 -4
- package/src/components/line/LineChart.stories.ts +38 -38
- package/src/components/line/LineChart.vue +54 -51
- package/src/components/line/index.ts +3 -3
- package/src/components/mixed/MixedBarLineChart.stories.ts +15 -15
- package/src/components/mixed/MixedBarLineChart.vue +44 -44
- package/src/components/mixed/index.ts +1 -1
- package/src/components/radar/RadarChart.stories.ts +100 -100
- package/src/components/radar/RadarChart.vue +41 -34
- package/src/components/radar/index.ts +3 -3
- package/src/main.ts +14 -7
- package/src/plugin.ts +9 -9
- package/src/services/BarChartFunctions.ts +133 -35
- package/src/services/BubbleTooltipService.ts +58 -56
- package/src/services/ChartsCommonLegend.ts +271 -127
- package/src/services/ColorFunctions.ts +1 -1
- package/src/services/DoughnutChartFunctions.ts +42 -13
- package/src/services/FormatUtilities.ts +28 -14
- package/src/services/GenericTooltipService.ts +125 -65
- package/src/services/MixedBarLineFunctions.ts +46 -44
- package/src/services/PatternFunctions.ts +25 -18
- package/src/services/RadarChartFunctions.ts +5 -5
- package/src/services/patterns/ChartDesign.ts +35 -24
- package/src/services/patterns/patternCircles.ts +63 -36
- package/src/services/patterns/patternDashedDiagonals.ts +64 -57
- package/src/services/patterns/patternDiagonals.ts +138 -106
- package/src/services/patterns/patternSquares.ts +86 -80
- package/src/services/patterns/patternVerticalLines.ts +76 -69
- package/src/services/patterns/patternZigzag.ts +92 -85
- package/src/stories/Changelog.mdx +2 -2
- package/src/stories/Contributing.mdx +2 -2
- package/src/stories/GettingStarted.mdx +5 -5
- package/src/stories/SupportAndOnboarding.mdx +6 -6
- package/src/types/AxisDefinition.ts +0 -2
- package/src/types/Chart.ts +9 -7
- package/src/types/DoughnutData.ts +8 -0
- package/src/types/GenericData.ts +10 -10
- package/src/types/LineChart.ts +4 -4
- package/src/types/RadarData.ts +33 -29
- package/src/types/TooltipChartType.ts +7 -7
- package/src/vite-env.d.ts +3 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// RadarChart.stories.ts
|
|
2
2
|
|
|
3
|
-
import type { Meta, StoryObj } from
|
|
4
|
-
import RadarChart from
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
4
|
+
import RadarChart from './RadarChart.vue';
|
|
5
5
|
|
|
6
6
|
const meta = {
|
|
7
|
-
title:
|
|
8
|
-
component: RadarChart
|
|
7
|
+
title: 'Charts/Radar',
|
|
8
|
+
component: RadarChart
|
|
9
9
|
} satisfies Meta<typeof RadarChart>;
|
|
10
10
|
|
|
11
11
|
export default meta;
|
|
@@ -13,334 +13,334 @@ type Story = StoryObj<typeof meta>;
|
|
|
13
13
|
|
|
14
14
|
export const Default = {
|
|
15
15
|
args: {
|
|
16
|
-
height:
|
|
17
|
-
labels: [
|
|
16
|
+
height: '400px',
|
|
17
|
+
labels: ['Label 1', 'Label 2', 'Label 3', 'Label 4', 'Label 5'],
|
|
18
18
|
datasets: [
|
|
19
19
|
{
|
|
20
|
-
label:
|
|
20
|
+
label: 'currentYear',
|
|
21
21
|
areaData: [
|
|
22
22
|
{
|
|
23
23
|
value: 88.524115665,
|
|
24
24
|
position: 60.98,
|
|
25
|
-
unit:
|
|
25
|
+
unit: 'D',
|
|
26
26
|
label: null,
|
|
27
27
|
rate: null,
|
|
28
|
-
color:
|
|
28
|
+
color: 'red',
|
|
29
29
|
trendValue: null,
|
|
30
30
|
trendUnit: null,
|
|
31
|
-
tooltips: null
|
|
31
|
+
tooltips: null
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
value: -3.5998021,
|
|
35
35
|
position: 46.4,
|
|
36
|
-
unit:
|
|
36
|
+
unit: '%',
|
|
37
37
|
label: null,
|
|
38
38
|
rate: null,
|
|
39
|
-
color:
|
|
39
|
+
color: 'green',
|
|
40
40
|
trendValue: null,
|
|
41
41
|
trendUnit: null,
|
|
42
|
-
tooltips: null
|
|
42
|
+
tooltips: null
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
value: 3.1604936,
|
|
46
46
|
position: 53.16,
|
|
47
|
-
unit:
|
|
47
|
+
unit: '%',
|
|
48
48
|
label: null,
|
|
49
49
|
rate: null,
|
|
50
|
-
color:
|
|
50
|
+
color: 'green',
|
|
51
51
|
trendValue: null,
|
|
52
52
|
trendUnit: null,
|
|
53
|
-
tooltips: null
|
|
53
|
+
tooltips: null
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
value: 7.787256,
|
|
57
57
|
position: 57.79,
|
|
58
|
-
unit:
|
|
58
|
+
unit: '%',
|
|
59
59
|
label: null,
|
|
60
60
|
rate: null,
|
|
61
|
-
color:
|
|
61
|
+
color: 'green',
|
|
62
62
|
trendValue: null,
|
|
63
63
|
trendUnit: null,
|
|
64
|
-
tooltips: null
|
|
64
|
+
tooltips: null
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
value: 62.2866732,
|
|
68
68
|
position: 79.76,
|
|
69
|
-
unit:
|
|
69
|
+
unit: '%',
|
|
70
70
|
label: null,
|
|
71
71
|
rate: null,
|
|
72
|
-
color:
|
|
72
|
+
color: 'red',
|
|
73
73
|
trendValue: null,
|
|
74
74
|
trendUnit: null,
|
|
75
|
-
tooltips: null
|
|
76
|
-
}
|
|
77
|
-
]
|
|
75
|
+
tooltips: null
|
|
76
|
+
}
|
|
77
|
+
]
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
|
-
label:
|
|
80
|
+
label: 'previousYear',
|
|
81
81
|
areaData: [
|
|
82
82
|
{
|
|
83
83
|
value: 78.752887008,
|
|
84
84
|
position: 67.5,
|
|
85
|
-
unit:
|
|
85
|
+
unit: 'D',
|
|
86
86
|
label: null,
|
|
87
87
|
rate: null,
|
|
88
88
|
color: null,
|
|
89
89
|
trendValue: null,
|
|
90
90
|
trendUnit: null,
|
|
91
|
-
tooltips: null
|
|
91
|
+
tooltips: null
|
|
92
92
|
},
|
|
93
93
|
{
|
|
94
94
|
value: -22.7389942,
|
|
95
95
|
position: 27.26,
|
|
96
|
-
unit:
|
|
96
|
+
unit: '%',
|
|
97
97
|
label: null,
|
|
98
98
|
rate: null,
|
|
99
99
|
color: null,
|
|
100
100
|
trendValue: null,
|
|
101
101
|
trendUnit: null,
|
|
102
|
-
tooltips: null
|
|
102
|
+
tooltips: null
|
|
103
103
|
},
|
|
104
104
|
{
|
|
105
105
|
value: -4.9793614,
|
|
106
106
|
position: 45.02,
|
|
107
|
-
unit:
|
|
107
|
+
unit: '%',
|
|
108
108
|
label: null,
|
|
109
109
|
rate: null,
|
|
110
110
|
color: null,
|
|
111
111
|
trendValue: null,
|
|
112
112
|
trendUnit: null,
|
|
113
|
-
tooltips: null
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
}
|
|
117
|
-
]
|
|
118
|
-
}
|
|
113
|
+
tooltips: null
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
119
|
} satisfies Story;
|
|
120
120
|
|
|
121
121
|
export const MultipleData = {
|
|
122
122
|
args: {
|
|
123
|
-
height:
|
|
123
|
+
height: '400px',
|
|
124
124
|
labels: [
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
125
|
+
'Label 1',
|
|
126
|
+
'Label 2',
|
|
127
|
+
'Label 3',
|
|
128
|
+
'Label 4',
|
|
129
|
+
'Label 5',
|
|
130
|
+
'Label 6',
|
|
131
|
+
'Label 7',
|
|
132
|
+
'Label 8',
|
|
133
|
+
'Label 9'
|
|
134
134
|
],
|
|
135
135
|
datasets: [
|
|
136
136
|
{
|
|
137
|
-
label:
|
|
137
|
+
label: 'currentYear',
|
|
138
138
|
areaData: [
|
|
139
139
|
{
|
|
140
140
|
value: 88.524115665,
|
|
141
141
|
position: 60.98,
|
|
142
|
-
unit:
|
|
142
|
+
unit: 'D',
|
|
143
143
|
label: null,
|
|
144
144
|
rate: null,
|
|
145
|
-
color:
|
|
145
|
+
color: 'red',
|
|
146
146
|
trendValue: null,
|
|
147
147
|
trendUnit: null,
|
|
148
|
-
tooltips: null
|
|
148
|
+
tooltips: null
|
|
149
149
|
},
|
|
150
150
|
{
|
|
151
151
|
value: -3.5998021,
|
|
152
152
|
position: 46.4,
|
|
153
|
-
unit:
|
|
153
|
+
unit: '%',
|
|
154
154
|
label: null,
|
|
155
155
|
rate: null,
|
|
156
|
-
color:
|
|
156
|
+
color: 'green',
|
|
157
157
|
trendValue: null,
|
|
158
158
|
trendUnit: null,
|
|
159
|
-
tooltips: null
|
|
159
|
+
tooltips: null
|
|
160
160
|
},
|
|
161
161
|
{
|
|
162
162
|
value: 3.1604936,
|
|
163
163
|
position: 53.16,
|
|
164
|
-
unit:
|
|
164
|
+
unit: '%',
|
|
165
165
|
label: null,
|
|
166
166
|
rate: null,
|
|
167
|
-
color:
|
|
167
|
+
color: 'green',
|
|
168
168
|
trendValue: null,
|
|
169
169
|
trendUnit: null,
|
|
170
|
-
tooltips: null
|
|
170
|
+
tooltips: null
|
|
171
171
|
},
|
|
172
172
|
{
|
|
173
173
|
value: 7.787256,
|
|
174
174
|
position: 57.79,
|
|
175
|
-
unit:
|
|
175
|
+
unit: '%',
|
|
176
176
|
label: null,
|
|
177
177
|
rate: null,
|
|
178
|
-
color:
|
|
178
|
+
color: 'green',
|
|
179
179
|
trendValue: null,
|
|
180
180
|
trendUnit: null,
|
|
181
|
-
tooltips: null
|
|
181
|
+
tooltips: null
|
|
182
182
|
},
|
|
183
183
|
{
|
|
184
184
|
value: 62.2866732,
|
|
185
185
|
position: 79.76,
|
|
186
|
-
unit:
|
|
186
|
+
unit: '%',
|
|
187
187
|
label: null,
|
|
188
188
|
rate: null,
|
|
189
|
-
color:
|
|
189
|
+
color: 'red',
|
|
190
190
|
trendValue: null,
|
|
191
191
|
trendUnit: null,
|
|
192
|
-
tooltips: null
|
|
192
|
+
tooltips: null
|
|
193
193
|
},
|
|
194
194
|
{
|
|
195
195
|
value: 3.8,
|
|
196
196
|
position: 76,
|
|
197
|
-
unit:
|
|
197
|
+
unit: '*',
|
|
198
198
|
label: null,
|
|
199
199
|
rate: null,
|
|
200
|
-
color:
|
|
200
|
+
color: 'red',
|
|
201
201
|
trendValue: null,
|
|
202
202
|
trendUnit: null,
|
|
203
|
-
tooltips: null
|
|
203
|
+
tooltips: null
|
|
204
204
|
},
|
|
205
205
|
{
|
|
206
206
|
value: 86.8082515,
|
|
207
207
|
position: 89.45,
|
|
208
|
-
unit:
|
|
208
|
+
unit: '%',
|
|
209
209
|
label: null,
|
|
210
210
|
rate: null,
|
|
211
|
-
color:
|
|
211
|
+
color: 'green',
|
|
212
212
|
trendValue: null,
|
|
213
213
|
trendUnit: null,
|
|
214
|
-
tooltips: null
|
|
214
|
+
tooltips: null
|
|
215
215
|
},
|
|
216
216
|
{
|
|
217
217
|
value: 94.8386888,
|
|
218
218
|
position: 79.35,
|
|
219
|
-
unit:
|
|
219
|
+
unit: '%',
|
|
220
220
|
label: null,
|
|
221
221
|
rate: null,
|
|
222
|
-
color:
|
|
222
|
+
color: 'red',
|
|
223
223
|
trendValue: null,
|
|
224
224
|
trendUnit: null,
|
|
225
|
-
tooltips: null
|
|
225
|
+
tooltips: null
|
|
226
226
|
},
|
|
227
227
|
{
|
|
228
228
|
value: 72.2144111,
|
|
229
229
|
position: 54.81,
|
|
230
|
-
unit:
|
|
230
|
+
unit: '%',
|
|
231
231
|
label: null,
|
|
232
232
|
rate: null,
|
|
233
|
-
color:
|
|
233
|
+
color: 'red',
|
|
234
234
|
trendValue: null,
|
|
235
235
|
trendUnit: null,
|
|
236
|
-
tooltips: null
|
|
237
|
-
}
|
|
238
|
-
]
|
|
236
|
+
tooltips: null
|
|
237
|
+
}
|
|
238
|
+
]
|
|
239
239
|
},
|
|
240
240
|
{
|
|
241
|
-
label:
|
|
241
|
+
label: 'previousYear',
|
|
242
242
|
areaData: [
|
|
243
243
|
{
|
|
244
244
|
value: 78.752887008,
|
|
245
245
|
position: 67.5,
|
|
246
|
-
unit:
|
|
246
|
+
unit: 'D',
|
|
247
247
|
label: null,
|
|
248
248
|
rate: null,
|
|
249
249
|
color: null,
|
|
250
250
|
trendValue: null,
|
|
251
251
|
trendUnit: null,
|
|
252
|
-
tooltips: null
|
|
252
|
+
tooltips: null
|
|
253
253
|
},
|
|
254
254
|
{
|
|
255
255
|
value: -22.7389942,
|
|
256
256
|
position: 27.26,
|
|
257
|
-
unit:
|
|
257
|
+
unit: '%',
|
|
258
258
|
label: null,
|
|
259
259
|
rate: null,
|
|
260
260
|
color: null,
|
|
261
261
|
trendValue: null,
|
|
262
262
|
trendUnit: null,
|
|
263
|
-
tooltips: null
|
|
263
|
+
tooltips: null
|
|
264
264
|
},
|
|
265
265
|
{
|
|
266
266
|
value: -4.9793614,
|
|
267
267
|
position: 45.02,
|
|
268
|
-
unit:
|
|
268
|
+
unit: '%',
|
|
269
269
|
label: null,
|
|
270
270
|
rate: null,
|
|
271
271
|
color: null,
|
|
272
272
|
trendValue: null,
|
|
273
273
|
trendUnit: null,
|
|
274
|
-
tooltips: null
|
|
274
|
+
tooltips: null
|
|
275
275
|
},
|
|
276
276
|
{
|
|
277
277
|
value: -22.8576595,
|
|
278
278
|
position: 27.14,
|
|
279
|
-
unit:
|
|
279
|
+
unit: '%',
|
|
280
280
|
label: null,
|
|
281
281
|
rate: null,
|
|
282
282
|
color: null,
|
|
283
283
|
trendValue: null,
|
|
284
284
|
trendUnit: null,
|
|
285
|
-
tooltips: null
|
|
285
|
+
tooltips: null
|
|
286
286
|
},
|
|
287
287
|
{
|
|
288
288
|
value: 65.1835015,
|
|
289
289
|
position: 83.07,
|
|
290
|
-
unit:
|
|
290
|
+
unit: '%',
|
|
291
291
|
label: null,
|
|
292
292
|
rate: null,
|
|
293
293
|
color: null,
|
|
294
294
|
trendValue: null,
|
|
295
295
|
trendUnit: null,
|
|
296
|
-
tooltips: null
|
|
296
|
+
tooltips: null
|
|
297
297
|
},
|
|
298
298
|
{
|
|
299
299
|
value: 4.181034483,
|
|
300
300
|
position: 83.62,
|
|
301
|
-
unit:
|
|
301
|
+
unit: '*',
|
|
302
302
|
label: null,
|
|
303
303
|
rate: null,
|
|
304
304
|
color: null,
|
|
305
305
|
trendValue: null,
|
|
306
306
|
trendUnit: null,
|
|
307
|
-
tooltips: null
|
|
307
|
+
tooltips: null
|
|
308
308
|
},
|
|
309
309
|
{
|
|
310
310
|
value: 86.8082515,
|
|
311
311
|
position: 89.45,
|
|
312
|
-
unit:
|
|
312
|
+
unit: '%',
|
|
313
313
|
label: null,
|
|
314
314
|
rate: null,
|
|
315
315
|
color: null,
|
|
316
316
|
trendValue: null,
|
|
317
317
|
trendUnit: null,
|
|
318
|
-
tooltips: null
|
|
318
|
+
tooltips: null
|
|
319
319
|
},
|
|
320
320
|
{
|
|
321
321
|
value: 98.120897,
|
|
322
322
|
position: 92.48,
|
|
323
|
-
unit:
|
|
323
|
+
unit: '%',
|
|
324
324
|
label: null,
|
|
325
325
|
rate: null,
|
|
326
326
|
color: null,
|
|
327
327
|
trendValue: null,
|
|
328
328
|
trendUnit: null,
|
|
329
|
-
tooltips: null
|
|
329
|
+
tooltips: null
|
|
330
330
|
},
|
|
331
331
|
{
|
|
332
332
|
value: 97.2715978,
|
|
333
333
|
position: 94.54,
|
|
334
|
-
unit:
|
|
334
|
+
unit: '%',
|
|
335
335
|
label: null,
|
|
336
336
|
rate: null,
|
|
337
337
|
color: null,
|
|
338
338
|
trendValue: null,
|
|
339
339
|
trendUnit: null,
|
|
340
|
-
tooltips: null
|
|
341
|
-
}
|
|
342
|
-
]
|
|
343
|
-
}
|
|
344
|
-
]
|
|
345
|
-
}
|
|
340
|
+
tooltips: null
|
|
341
|
+
}
|
|
342
|
+
]
|
|
343
|
+
}
|
|
344
|
+
]
|
|
345
|
+
}
|
|
346
346
|
} satisfies Story;
|
|
@@ -22,11 +22,14 @@ import { Radar } from 'vue-chartjs';
|
|
|
22
22
|
import type { ActiveElement, ChartData } from 'chart.js';
|
|
23
23
|
import {
|
|
24
24
|
Context,
|
|
25
|
-
GenericTooltipService
|
|
25
|
+
GenericTooltipService
|
|
26
26
|
} from '../../services/GenericTooltipService';
|
|
27
27
|
import { formatWithThousandsSeprators } from '../../services/FormatUtilities';
|
|
28
28
|
import { TooltipChartType } from '../../types/TooltipChartType';
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
drawLabels,
|
|
31
|
+
splitLabelIfTooLong
|
|
32
|
+
} from '../../services/RadarChartFunctions';
|
|
30
33
|
import type { Chart, ChartItem } from '../../services/ChartsCommonLegend';
|
|
31
34
|
import { addAlpha } from '../../services/ColorFunctions';
|
|
32
35
|
import {
|
|
@@ -38,7 +41,7 @@ import {
|
|
|
38
41
|
RadialLinearScale,
|
|
39
42
|
Title,
|
|
40
43
|
Tooltip,
|
|
41
|
-
Plugin
|
|
44
|
+
Plugin
|
|
42
45
|
} from 'chart.js';
|
|
43
46
|
|
|
44
47
|
import {
|
|
@@ -48,7 +51,7 @@ import {
|
|
|
48
51
|
createLegendElementWithSquareArea,
|
|
49
52
|
getOrCreateLegendList,
|
|
50
53
|
hideAllButThis,
|
|
51
|
-
switchItemVisibility
|
|
54
|
+
switchItemVisibility
|
|
52
55
|
} from '../../services/ChartsCommonLegend';
|
|
53
56
|
|
|
54
57
|
import ChartDesign from '../../services/patterns/ChartDesign';
|
|
@@ -71,28 +74,28 @@ const radarComponentChartProps = defineProps({
|
|
|
71
74
|
*/
|
|
72
75
|
chartId: {
|
|
73
76
|
type: String,
|
|
74
|
-
default: 'radar-chart'
|
|
77
|
+
default: 'radar-chart'
|
|
75
78
|
},
|
|
76
79
|
/**
|
|
77
80
|
* Value of the `height` css property used to define the height of the <canvas> element
|
|
78
81
|
*/
|
|
79
82
|
height: {
|
|
80
83
|
type: String,
|
|
81
|
-
default: '600px'
|
|
84
|
+
default: '600px'
|
|
82
85
|
},
|
|
83
86
|
/**
|
|
84
87
|
* Labels used to label the index axis (default x axes). See [Data structures documentation](https://www.chartjs.org/docs/latest/general/data-structures.html)
|
|
85
88
|
*/
|
|
86
89
|
labels: {
|
|
87
90
|
type: Array as PropType<string[]>,
|
|
88
|
-
default: () => []
|
|
91
|
+
default: () => []
|
|
89
92
|
},
|
|
90
93
|
/**
|
|
91
94
|
* Disable accessibility patterns
|
|
92
95
|
*/
|
|
93
96
|
disableAccessibility: {
|
|
94
97
|
type: Boolean,
|
|
95
|
-
default: false
|
|
98
|
+
default: false
|
|
96
99
|
},
|
|
97
100
|
/**
|
|
98
101
|
* Used to choose the colour set of the charts as defined in the Figma prototypes.
|
|
@@ -103,7 +106,7 @@ const radarComponentChartProps = defineProps({
|
|
|
103
106
|
*/
|
|
104
107
|
colourSet: {
|
|
105
108
|
type: Number,
|
|
106
|
-
default: 0
|
|
109
|
+
default: 0
|
|
107
110
|
},
|
|
108
111
|
/**
|
|
109
112
|
* 6 patterns exist and are not randomly given but follow the order defined in [patternsStandardList](/src/services/patterns/ChartDesign.ts)
|
|
@@ -112,36 +115,36 @@ const radarComponentChartProps = defineProps({
|
|
|
112
115
|
*/
|
|
113
116
|
newPatternsOrder: {
|
|
114
117
|
type: Array as PropType<number[]>,
|
|
115
|
-
default: () => [0, 1, 2, 3, 4, 5]
|
|
118
|
+
default: () => [0, 1, 2, 3, 4, 5]
|
|
116
119
|
},
|
|
117
120
|
/**
|
|
118
121
|
* Value of the `datasets` key present in the `data` object passed to the Chart config
|
|
119
122
|
*/
|
|
120
123
|
datasets: {
|
|
121
124
|
type: Array as PropType<Area[]>,
|
|
122
|
-
default: () => []
|
|
125
|
+
default: () => []
|
|
123
126
|
},
|
|
124
127
|
/**
|
|
125
128
|
* Add custom CSS classes to the <canvas> element
|
|
126
129
|
*/
|
|
127
130
|
cssClasses: {
|
|
128
131
|
default: '',
|
|
129
|
-
type: String
|
|
132
|
+
type: String
|
|
130
133
|
},
|
|
131
134
|
/**
|
|
132
135
|
* Add custom CSS styles to the <canvas> element
|
|
133
136
|
*/
|
|
134
137
|
styles: {
|
|
135
138
|
type: Object as PropType<Partial<CSSStyleDeclaration>>,
|
|
136
|
-
default: () => {}
|
|
139
|
+
default: () => {}
|
|
137
140
|
},
|
|
138
141
|
/**
|
|
139
142
|
* Value of the `plugins` key passed to the Chart config
|
|
140
143
|
*/
|
|
141
144
|
plugins: {
|
|
142
145
|
type: Array as PropType<Plugin<'radar'>[]>,
|
|
143
|
-
default: () => []
|
|
144
|
-
}
|
|
146
|
+
default: () => []
|
|
147
|
+
}
|
|
145
148
|
});
|
|
146
149
|
|
|
147
150
|
const patternsColors = computed(() =>
|
|
@@ -162,7 +165,7 @@ const patternsOrderedList = computed(() =>
|
|
|
162
165
|
|
|
163
166
|
const radarData = computed<ChartData<'radar'>>(() => ({
|
|
164
167
|
labels: getRadarLabels(),
|
|
165
|
-
datasets: getDatasets()
|
|
168
|
+
datasets: getDatasets()
|
|
166
169
|
}));
|
|
167
170
|
|
|
168
171
|
function getDatasets() {
|
|
@@ -180,7 +183,7 @@ function getDatasets() {
|
|
|
180
183
|
pointStyle: index % 2 === 0 ? 'circle' : 'rectRot',
|
|
181
184
|
pointHoverBackgroundColor: patternsColors.value[index],
|
|
182
185
|
pointHoverBorderColor: patternsColors.value[index],
|
|
183
|
-
data: dataset.areaData.map((x: { position: number }) => x.position)
|
|
186
|
+
data: dataset.areaData.map((x: { position: number }) => x.position)
|
|
184
187
|
};
|
|
185
188
|
});
|
|
186
189
|
}
|
|
@@ -197,13 +200,13 @@ const chartOptions: any = {
|
|
|
197
200
|
},
|
|
198
201
|
plugins: {
|
|
199
202
|
htmlLegend: {
|
|
200
|
-
containerID: 'legend-container'
|
|
203
|
+
containerID: 'legend-container'
|
|
201
204
|
},
|
|
202
205
|
legend: {
|
|
203
|
-
display: false
|
|
206
|
+
display: false
|
|
204
207
|
},
|
|
205
208
|
title: {
|
|
206
|
-
display: false
|
|
209
|
+
display: false
|
|
207
210
|
},
|
|
208
211
|
datalabels: {
|
|
209
212
|
display: false
|
|
@@ -220,16 +223,16 @@ const chartOptions: any = {
|
|
|
220
223
|
patternsOrderedList.value,
|
|
221
224
|
radarComponentChartProps.disableAccessibility
|
|
222
225
|
);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
225
228
|
},
|
|
226
229
|
layout: {
|
|
227
230
|
padding: {
|
|
228
231
|
left: 130,
|
|
229
232
|
right: 95,
|
|
230
233
|
top: 95,
|
|
231
|
-
bottom: 95
|
|
232
|
-
}
|
|
234
|
+
bottom: 95
|
|
235
|
+
}
|
|
233
236
|
},
|
|
234
237
|
scales: {
|
|
235
238
|
r: {
|
|
@@ -239,15 +242,15 @@ const chartOptions: any = {
|
|
|
239
242
|
display: false,
|
|
240
243
|
font: {
|
|
241
244
|
weight: 400,
|
|
242
|
-
family: 'Roboto'
|
|
243
|
-
}
|
|
245
|
+
family: 'Roboto'
|
|
246
|
+
}
|
|
244
247
|
},
|
|
245
248
|
ticks: {
|
|
246
249
|
display: false,
|
|
247
|
-
stepSize: 25
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
250
|
+
stepSize: 25
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
251
254
|
};
|
|
252
255
|
const legendContainer = ref(null);
|
|
253
256
|
const selectMode = ref(false);
|
|
@@ -267,7 +270,11 @@ const formatNumber = (numberFromJson: string) => {
|
|
|
267
270
|
return formatWithThousandsSeprators(parseFloat(numberFromJson));
|
|
268
271
|
};
|
|
269
272
|
function createLegendElementWithCheckbox(chart: any, item: ChartItem) {
|
|
270
|
-
const liContent = createLegendCheckbox(
|
|
273
|
+
const liContent = createLegendCheckbox(
|
|
274
|
+
chart,
|
|
275
|
+
item,
|
|
276
|
+
null as unknown as string[]
|
|
277
|
+
);
|
|
271
278
|
liContent.onclick = (e: Event) => {
|
|
272
279
|
switchItemVisibility(chart, item.datasetIndex, selectMode);
|
|
273
280
|
e.stopPropagation();
|
|
@@ -303,14 +310,14 @@ const radarPlugins = [
|
|
|
303
310
|
li.appendChild(createHtmlLegendItemText(item));
|
|
304
311
|
ul.appendChild(li);
|
|
305
312
|
});
|
|
306
|
-
}
|
|
313
|
+
}
|
|
307
314
|
},
|
|
308
315
|
{
|
|
309
316
|
id: 'radarLabelPlugin',
|
|
310
317
|
beforeDraw(chart: any) {
|
|
311
318
|
drawLabels(chart, radarComponentChartProps);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
314
321
|
];
|
|
315
322
|
|
|
316
323
|
const getTooltipData = (context: Context): string => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { App } from
|
|
2
|
-
import RadarChart from
|
|
1
|
+
import type { App } from 'vue';
|
|
2
|
+
import RadarChart from './RadarChart.vue';
|
|
3
3
|
|
|
4
4
|
RadarChart.install = (app: App) => {
|
|
5
|
-
app.component(
|
|
5
|
+
app.component('RadarChart', RadarChart);
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export { RadarChart };
|