@mozaic-ds/chart 0.1.0-beta.4 → 0.1.0-beta.40
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 +85 -9
- package/dist/mozaic-chart.js +4747 -2614
- package/dist/mozaic-chart.umd.cjs +17 -11
- package/dist/style.css +1 -1
- package/package.json +24 -11
- package/src/assets/base.css +1 -1
- package/src/assets/img/bubbles.svg +4 -0
- package/src/components/bar/BarChart.stories.ts +181 -101
- package/src/components/bar/BarChart.vue +370 -139
- package/src/components/bar/index.ts +3 -3
- package/src/components/bubble/BubbleChart.stories.ts +66 -0
- package/src/components/bubble/BubbleChart.vue +432 -0
- package/src/components/bubble/index.ts +8 -0
- package/src/components/doughnut/DoughnutChart.stories.ts +38 -36
- package/src/components/doughnut/DoughnutChart.vue +243 -114
- package/src/components/doughnut/index.ts +3 -3
- package/src/components/index.ts +4 -4
- package/src/components/line/LineChart.stories.ts +52 -27
- package/src/components/line/LineChart.vue +381 -255
- package/src/components/line/index.ts +3 -3
- package/src/components/mixed/MixedBarLineChart.stories.ts +91 -0
- package/src/components/mixed/MixedBarLineChart.vue +469 -0
- package/src/components/mixed/index.ts +8 -0
- package/src/components/radar/RadarChart.stories.ts +102 -102
- package/src/components/radar/RadarChart.vue +222 -167
- package/src/components/radar/index.ts +3 -3
- package/src/main.ts +14 -5
- package/src/plugin.ts +9 -7
- package/src/services/BarChartFunctions.ts +139 -35
- package/src/services/BubbleTooltipService.ts +67 -0
- package/src/services/ChartsCommonLegend.ts +315 -139
- package/src/services/ColorFunctions.ts +1 -1
- package/src/services/DoughnutChartFunctions.ts +132 -55
- package/src/services/FormatUtilities.ts +25 -19
- package/src/services/GenericTooltipService.ts +141 -66
- package/src/services/MixedBarLineFunctions.ts +262 -0
- package/src/services/PatternFunctions.ts +25 -18
- package/src/services/RadarChartFunctions.ts +39 -12
- 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 +6 -0
- package/src/stories/Contributing.mdx +101 -0
- package/src/stories/GettingStarted.mdx +92 -0
- package/src/stories/SupportAndOnboarding.mdx +44 -0
- package/src/types/AxisDefinition.ts +4 -0
- package/src/types/BarData.ts +1 -0
- 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 +5 -4
- package/src/types/MixedBarLineData.ts +7 -0
- package/src/types/RadarData.ts +33 -29
- package/src/types/TooltipChartType.ts +7 -6
- package/src/vite-env.d.ts +3 -3
|
@@ -1,32 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="container">
|
|
3
|
-
<div class=
|
|
3
|
+
<div class="main" :style="{ height }">
|
|
4
4
|
<Radar
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
:style='{ height, cursor:"pointer",}'
|
|
5
|
+
v-if="radarData"
|
|
6
|
+
:id="chartId"
|
|
7
|
+
:data="radarData"
|
|
8
|
+
:options="chartOptions"
|
|
9
|
+
:plugins="radarPlugins"
|
|
10
|
+
:class="cssClasses"
|
|
11
|
+
:style="[{ height, cursor: 'pointer' }, styles]"
|
|
13
12
|
/>
|
|
14
13
|
</div>
|
|
15
|
-
<div ref=
|
|
14
|
+
<div ref="legendContainer" class="legendContainer" />
|
|
16
15
|
</div>
|
|
17
16
|
</template>
|
|
18
17
|
|
|
19
|
-
<script setup lang=
|
|
18
|
+
<script setup lang="ts">
|
|
20
19
|
import { PropType, ref, computed } from 'vue';
|
|
21
20
|
import type { Area } from '../../types/RadarData';
|
|
22
21
|
import { Radar } from 'vue-chartjs';
|
|
23
22
|
import type { ActiveElement, ChartData } from 'chart.js';
|
|
24
|
-
import {
|
|
25
|
-
|
|
23
|
+
import {
|
|
24
|
+
Context,
|
|
25
|
+
GenericTooltipService
|
|
26
|
+
} from '../../services/GenericTooltipService';
|
|
27
|
+
import {formatDecimalNumber, formatWithThousandsSeprators} from '../../services/FormatUtilities';
|
|
26
28
|
import { TooltipChartType } from '../../types/TooltipChartType';
|
|
27
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
drawLabels,
|
|
31
|
+
splitLabel,
|
|
32
|
+
} from '../../services/RadarChartFunctions';
|
|
28
33
|
import type { Chart, ChartItem } from '../../services/ChartsCommonLegend';
|
|
29
|
-
import { addAlpha } from '../../services/ColorFunctions'
|
|
34
|
+
import { addAlpha } from '../../services/ColorFunctions';
|
|
30
35
|
import {
|
|
31
36
|
Chart as ChartJS,
|
|
32
37
|
Filler,
|
|
@@ -58,117 +63,157 @@ ChartJS.register(
|
|
|
58
63
|
RadialLinearScale,
|
|
59
64
|
LineElement,
|
|
60
65
|
PointElement,
|
|
61
|
-
Filler
|
|
66
|
+
Filler
|
|
62
67
|
);
|
|
63
68
|
|
|
64
|
-
const {
|
|
65
|
-
colourSets,
|
|
66
|
-
patternsStandardList
|
|
67
|
-
} = ChartDesign();
|
|
69
|
+
const { colourSets, patternsStandardList } = ChartDesign();
|
|
68
70
|
|
|
69
71
|
const radarComponentChartProps = defineProps({
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Value of the id attribute present on the <canvas> tag element the chart
|
|
74
|
+
*/
|
|
75
|
+
chartId: {
|
|
76
|
+
type: String,
|
|
77
|
+
default: 'radar-chart'
|
|
78
|
+
},
|
|
79
|
+
/**
|
|
80
|
+
* Value of the `height` css property used to define the height of the <canvas> element
|
|
81
|
+
*/
|
|
82
|
+
height: {
|
|
83
|
+
type: String,
|
|
84
|
+
default: '600px'
|
|
85
|
+
},
|
|
86
|
+
/**
|
|
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)
|
|
88
|
+
*/
|
|
89
|
+
labels: {
|
|
79
90
|
type: Array as PropType<string[]>,
|
|
80
91
|
default: () => []
|
|
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
|
-
|
|
92
|
+
},
|
|
93
|
+
/**
|
|
94
|
+
* Disable accessibility patterns
|
|
95
|
+
*/
|
|
96
|
+
disableAccessibility: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: false
|
|
99
|
+
},
|
|
100
|
+
/**
|
|
101
|
+
* Used to choose the colour set of the charts as defined in the Figma prototypes.
|
|
102
|
+
* 7 colour sets are currently defined:
|
|
103
|
+
* - Default 0 corresponds to the current one
|
|
104
|
+
* - 1 to 6 corresponds to the "new" [colour sets](https://www.figma.com/file/Hn6PyvnR385Ta0XN3KqOI9/04.-Dataviz---Documentation-(read-only)?type=design&node-id=1-69316&mode=design&t=sDytQ5BipsryWkuA-0)
|
|
105
|
+
* Note: All the sets are defined in /src/services/patterns/ChartDesign.ts
|
|
106
|
+
*/
|
|
107
|
+
colourSet: {
|
|
108
|
+
type: Number,
|
|
109
|
+
default: 0
|
|
110
|
+
},
|
|
111
|
+
/**
|
|
112
|
+
* 6 patterns exist and are not randomly given but follow the order defined in [patternsStandardList](/src/services/patterns/ChartDesign.ts)
|
|
113
|
+
* Additionally, a pattern has only one possible colour per colour set as defined in the Figma prototype.
|
|
114
|
+
* In some use cases, the chart may need to show a different orders of these patterns, this can be changed using the props newPatternsOrder
|
|
115
|
+
*/
|
|
116
|
+
newPatternsOrder: {
|
|
117
|
+
type: Array as PropType<number[]>,
|
|
118
|
+
default: () => [0, 1, 2, 3, 4, 5]
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* Value of the `datasets` key present in the `data` object passed to the Chart config
|
|
122
|
+
*/
|
|
123
|
+
datasets: {
|
|
124
|
+
type: Array as PropType<Area[]>,
|
|
125
|
+
default: () => []
|
|
126
|
+
},
|
|
127
|
+
/**
|
|
128
|
+
* Add custom CSS classes to the <canvas> element
|
|
129
|
+
*/
|
|
130
|
+
cssClasses: {
|
|
131
|
+
default: '',
|
|
132
|
+
type: String
|
|
133
|
+
},
|
|
134
|
+
/**
|
|
135
|
+
* Add custom CSS styles to the <canvas> element
|
|
136
|
+
*/
|
|
137
|
+
styles: {
|
|
138
|
+
type: Object as PropType<Partial<CSSStyleDeclaration>>,
|
|
139
|
+
default: () => {}
|
|
140
|
+
},
|
|
141
|
+
/**
|
|
142
|
+
* Value of the `plugins` key passed to the Chart config
|
|
143
|
+
*/
|
|
144
|
+
plugins: {
|
|
145
|
+
type: Array as PropType<Plugin<'radar'>[]>,
|
|
146
|
+
default: () => []
|
|
147
|
+
},
|
|
148
|
+
/**
|
|
149
|
+
* Value of the minimum number of fraction digits used to format the data values
|
|
150
|
+
*/
|
|
151
|
+
dataMinimumFractionDigits: {
|
|
152
|
+
type: Number,
|
|
153
|
+
required: false
|
|
154
|
+
},
|
|
155
|
+
/**
|
|
156
|
+
* Value of the maximum number of fraction digits used to format the data values
|
|
157
|
+
*/
|
|
158
|
+
dataMaximumFractionDigits: {
|
|
159
|
+
type: Number,
|
|
160
|
+
required: false
|
|
161
|
+
}
|
|
162
|
+
});
|
|
120
163
|
|
|
121
|
-
const patternsColors = computed(() =>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
)
|
|
164
|
+
const patternsColors = computed(() =>
|
|
165
|
+
radarComponentChartProps.newPatternsOrder.length !== 6
|
|
166
|
+
? colourSets[radarComponentChartProps.colourSet]
|
|
167
|
+
: radarComponentChartProps.newPatternsOrder.map((id) => {
|
|
168
|
+
return colourSets[radarComponentChartProps.colourSet][id];
|
|
169
|
+
})
|
|
170
|
+
);
|
|
125
171
|
|
|
126
|
-
const patternsOrderedList = computed(() =>
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
)
|
|
172
|
+
const patternsOrderedList = computed(() =>
|
|
173
|
+
radarComponentChartProps.newPatternsOrder.length !== 6
|
|
174
|
+
? patternsStandardList
|
|
175
|
+
: radarComponentChartProps.newPatternsOrder.map((id) => {
|
|
176
|
+
return patternsStandardList[id];
|
|
177
|
+
})
|
|
178
|
+
);
|
|
130
179
|
|
|
131
180
|
const radarData = computed<ChartData<'radar'>>(() => ({
|
|
132
181
|
labels: getRadarLabels(),
|
|
133
|
-
datasets:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
pointHitRadius: 55,
|
|
143
|
-
pointRadius: 5,
|
|
144
|
-
pointHoverBackgroundColor: patternsColors.value[0],
|
|
145
|
-
pointHoverBorderColor: patternsColors.value[0],
|
|
146
|
-
data: radarComponentChartProps.areas[0].areaData.map((x: { position: number }) => x.position)
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
label: 'Data Two',
|
|
150
|
-
backgroundColor: addAlpha(patternsColors.value[1], 0.1),
|
|
151
|
-
borderColor: patternsColors.value[1],
|
|
182
|
+
datasets: getDatasets()
|
|
183
|
+
}));
|
|
184
|
+
|
|
185
|
+
function getDatasets() {
|
|
186
|
+
return radarComponentChartProps.datasets.map((dataset, index) => {
|
|
187
|
+
return {
|
|
188
|
+
label: dataset.label,
|
|
189
|
+
backgroundColor: addAlpha(patternsColors.value[index], 0.1),
|
|
190
|
+
borderColor: patternsColors.value[index],
|
|
152
191
|
pointBackgroundColor: '#FFFFFF',
|
|
153
|
-
pointBorderColor: patternsColors.value[
|
|
192
|
+
pointBorderColor: patternsColors.value[index],
|
|
154
193
|
pointBorderWidth: 2,
|
|
155
194
|
borderWidth: 2,
|
|
156
195
|
pointHitRadius: 55,
|
|
157
196
|
pointRadius: 5,
|
|
158
|
-
pointStyle: 'rectRot',
|
|
159
|
-
pointHoverBackgroundColor: patternsColors.value[
|
|
160
|
-
pointHoverBorderColor: patternsColors.value[
|
|
161
|
-
data:
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
}
|
|
197
|
+
pointStyle: index % 2 === 0 ? 'circle' : 'rectRot',
|
|
198
|
+
pointHoverBackgroundColor: patternsColors.value[index],
|
|
199
|
+
pointHoverBorderColor: patternsColors.value[index],
|
|
200
|
+
data: dataset.areaData.map((x: { position: number }) => x.position)
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
}
|
|
165
204
|
|
|
166
205
|
const chartOptions: any = {
|
|
167
|
-
|
|
206
|
+
onClick: (
|
|
207
|
+
_ingnore: unknown,
|
|
208
|
+
clickedElements: ActiveElement[],
|
|
209
|
+
chart: Chart
|
|
210
|
+
) => {
|
|
168
211
|
if (clickedElements[0]) {
|
|
169
212
|
hideAllButThis(chart, clickedElements[0].datasetIndex, selectMode);
|
|
170
213
|
}
|
|
171
214
|
},
|
|
215
|
+
responsive: true,
|
|
216
|
+
maintainAspectRatio: false,
|
|
172
217
|
plugins: {
|
|
173
218
|
htmlLegend: {
|
|
174
219
|
containerID: 'legend-container'
|
|
@@ -179,6 +224,9 @@ const chartOptions: any = {
|
|
|
179
224
|
title: {
|
|
180
225
|
display: false
|
|
181
226
|
},
|
|
227
|
+
datalabels: {
|
|
228
|
+
display: false
|
|
229
|
+
},
|
|
182
230
|
tooltip: {
|
|
183
231
|
enabled: false,
|
|
184
232
|
position: 'nearest' as const,
|
|
@@ -195,16 +243,22 @@ const chartOptions: any = {
|
|
|
195
243
|
}
|
|
196
244
|
},
|
|
197
245
|
layout: {
|
|
198
|
-
padding:
|
|
246
|
+
padding: {
|
|
247
|
+
left: 130,
|
|
248
|
+
right: 95,
|
|
249
|
+
top: 95,
|
|
250
|
+
bottom: 95
|
|
251
|
+
}
|
|
199
252
|
},
|
|
200
253
|
scales: {
|
|
201
254
|
r: {
|
|
202
255
|
min: 0,
|
|
203
256
|
max: 100,
|
|
204
257
|
pointLabels: {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
258
|
+
display: false,
|
|
259
|
+
font: {
|
|
260
|
+
weight: 400,
|
|
261
|
+
family: 'Roboto'
|
|
208
262
|
}
|
|
209
263
|
},
|
|
210
264
|
ticks: {
|
|
@@ -213,37 +267,30 @@ const chartOptions: any = {
|
|
|
213
267
|
}
|
|
214
268
|
}
|
|
215
269
|
}
|
|
216
|
-
|
|
270
|
+
};
|
|
217
271
|
const legendContainer = ref(null);
|
|
218
272
|
const selectMode = ref(false);
|
|
219
|
-
|
|
220
|
-
const radarLimitLabelLength = 15;
|
|
221
|
-
if (axisLabel.length > radarLimitLabelLength && axisLabel.includes(' ', radarLimitLabelLength)) {
|
|
222
|
-
const indexOfFirstSpaceAfterLimit: number = axisLabel.indexOf(' ', radarLimitLabelLength);
|
|
223
|
-
return [
|
|
224
|
-
axisLabel.substring(0, indexOfFirstSpaceAfterLimit),
|
|
225
|
-
axisLabel.substring(indexOfFirstSpaceAfterLimit),
|
|
226
|
-
buildValue
|
|
227
|
-
];
|
|
228
|
-
}
|
|
229
|
-
return [
|
|
230
|
-
axisLabel,
|
|
231
|
-
buildValue
|
|
232
|
-
];
|
|
233
|
-
}
|
|
273
|
+
|
|
234
274
|
const getRadarLabels = () => {
|
|
235
275
|
return radarComponentChartProps.labels.map((label: string, index: number) => {
|
|
236
|
-
const buildValue = radarComponentChartProps.
|
|
237
|
-
|
|
276
|
+
const buildValue = radarComponentChartProps.datasets[0].areaData[index]
|
|
277
|
+
.value
|
|
278
|
+
? `${formatNumber(
|
|
279
|
+
radarComponentChartProps.datasets[0].areaData[index].value + ''
|
|
280
|
+
)} ${radarComponentChartProps.datasets[0].areaData[index].unit}`
|
|
238
281
|
: 'No Data';
|
|
239
|
-
return
|
|
282
|
+
return splitLabel(label, buildValue);
|
|
240
283
|
});
|
|
241
|
-
}
|
|
284
|
+
};
|
|
242
285
|
const formatNumber = (numberFromJson: string) => {
|
|
243
|
-
return formatWithThousandsSeprators(parseFloat(numberFromJson));
|
|
286
|
+
return formatWithThousandsSeprators(parseFloat(numberFromJson), radarComponentChartProps.dataMinimumFractionDigits, radarComponentChartProps.dataMaximumFractionDigits);
|
|
244
287
|
};
|
|
245
|
-
function createLegendElementWithCheckbox
|
|
246
|
-
const liContent = createLegendCheckbox(
|
|
288
|
+
function createLegendElementWithCheckbox(chart: any, item: ChartItem) {
|
|
289
|
+
const liContent = createLegendCheckbox(
|
|
290
|
+
chart,
|
|
291
|
+
item,
|
|
292
|
+
null as unknown as string[]
|
|
293
|
+
);
|
|
247
294
|
liContent.onclick = (e: Event) => {
|
|
248
295
|
switchItemVisibility(chart, item.datasetIndex, selectMode);
|
|
249
296
|
e.stopPropagation();
|
|
@@ -251,44 +298,53 @@ function createLegendElementWithCheckbox (chart: any, item: ChartItem) {
|
|
|
251
298
|
return liContent;
|
|
252
299
|
}
|
|
253
300
|
|
|
254
|
-
const radarPlugins = [
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
ul.firstChild
|
|
260
|
-
|
|
261
|
-
const items = chart.options.plugins.legend.labels.generateLabels(chart).reverse();
|
|
262
|
-
items.forEach((item: ChartItem) => {
|
|
263
|
-
const li = createHtmlLegendListElement(chart, selectMode, item.datasetIndex);
|
|
264
|
-
let liContent;
|
|
265
|
-
li.style.marginRight = '0.625rem';
|
|
266
|
-
if (!selectMode.value) {
|
|
267
|
-
liContent = createLegendElementWithSquareArea(item, true);
|
|
268
|
-
} else {
|
|
269
|
-
liContent = createLegendElementWithCheckbox(chart, item);
|
|
301
|
+
const radarPlugins = [
|
|
302
|
+
{
|
|
303
|
+
id: 'htmlLegend',
|
|
304
|
+
afterUpdate(chart: any) {
|
|
305
|
+
const ul = getOrCreateLegendList(legendContainer, 'row');
|
|
306
|
+
while (ul.firstChild) {
|
|
307
|
+
ul.firstChild.remove();
|
|
270
308
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
309
|
+
const items = chart.options.plugins.legend.labels
|
|
310
|
+
.generateLabels(chart)
|
|
311
|
+
.reverse();
|
|
312
|
+
items.forEach((item: ChartItem) => {
|
|
313
|
+
const li = createHtmlLegendListElement(
|
|
314
|
+
chart,
|
|
315
|
+
selectMode,
|
|
316
|
+
item.datasetIndex
|
|
317
|
+
);
|
|
318
|
+
let liContent;
|
|
319
|
+
li.style.marginRight = '0.625rem';
|
|
320
|
+
if (!selectMode.value) {
|
|
321
|
+
liContent = createLegendElementWithSquareArea(item, true);
|
|
322
|
+
} else {
|
|
323
|
+
liContent = createLegendElementWithCheckbox(chart, item);
|
|
324
|
+
}
|
|
325
|
+
li.appendChild(liContent);
|
|
326
|
+
li.appendChild(createHtmlLegendItemText(item));
|
|
327
|
+
ul.appendChild(li);
|
|
328
|
+
});
|
|
329
|
+
}
|
|
280
330
|
},
|
|
281
|
-
|
|
331
|
+
{
|
|
332
|
+
id: 'radarLabelPlugin',
|
|
333
|
+
beforeDraw(chart: any) {
|
|
334
|
+
drawLabels(chart, radarComponentChartProps);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
];
|
|
282
338
|
|
|
283
339
|
const getTooltipData = (context: Context): string => {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
340
|
+
const datasetIndex = context.tooltip.dataPoints[0].datasetIndex as number;
|
|
341
|
+
const dataIndex = context.tooltip.dataPoints[0].dataIndex as number;
|
|
342
|
+
const data = radarComponentChartProps.datasets[datasetIndex];
|
|
343
|
+
return (
|
|
344
|
+
formatDecimalNumber(data.areaData[dataIndex].value, radarComponentChartProps.dataMinimumFractionDigits, radarComponentChartProps.dataMaximumFractionDigits) +
|
|
345
|
+
' ' +
|
|
346
|
+
data.areaData[dataIndex].unit
|
|
347
|
+
);
|
|
292
348
|
};
|
|
293
349
|
</script>
|
|
294
350
|
|
|
@@ -300,10 +356,9 @@ const getTooltipData = (context: Context): string => {
|
|
|
300
356
|
font-family: 'Roboto', sans-serif;
|
|
301
357
|
}
|
|
302
358
|
.main {
|
|
303
|
-
height: 600px;
|
|
304
359
|
display: flex;
|
|
305
360
|
flex-direction: column;
|
|
306
361
|
justify-content: center;
|
|
307
362
|
align-items: center;
|
|
308
363
|
}
|
|
309
|
-
</style>
|
|
364
|
+
</style>
|
|
@@ -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 };
|
package/src/main.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import BarChart from
|
|
2
|
-
import DoughnutChart from
|
|
3
|
-
import LineChart from
|
|
4
|
-
import RadarChart from
|
|
1
|
+
import BarChart from './components/bar/BarChart.vue';
|
|
2
|
+
import DoughnutChart from './components/doughnut/DoughnutChart.vue';
|
|
3
|
+
import LineChart from './components/line/LineChart.vue';
|
|
4
|
+
import RadarChart from './components/radar/RadarChart.vue';
|
|
5
|
+
import MixedBarLineChart from './components/mixed/MixedBarLineChart.vue';
|
|
6
|
+
import BubbleChart from './components/bubble/BubbleChart.vue';
|
|
5
7
|
|
|
6
|
-
export {
|
|
8
|
+
export {
|
|
9
|
+
BarChart,
|
|
10
|
+
DoughnutChart,
|
|
11
|
+
LineChart,
|
|
12
|
+
RadarChart,
|
|
13
|
+
MixedBarLineChart,
|
|
14
|
+
BubbleChart
|
|
15
|
+
};
|
package/src/plugin.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { App } from
|
|
2
|
-
import * as Components from
|
|
1
|
+
import type { App } from 'vue';
|
|
2
|
+
import * as Components from './components';
|
|
3
3
|
|
|
4
4
|
const MozaicChart = {
|
|
5
5
|
install: (app: App, options: {}) => {
|
|
@@ -7,12 +7,14 @@ const MozaicChart = {
|
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
app.component(name, Components[name]);
|
|
9
9
|
});
|
|
10
|
-
}
|
|
10
|
+
}
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export default MozaicChart;
|
|
14
14
|
|
|
15
|
-
export { BarChart } from
|
|
16
|
-
export { DoughnutChart } from
|
|
17
|
-
export { LineChart } from
|
|
18
|
-
export { RadarChart } from
|
|
15
|
+
export { BarChart } from './components/bar';
|
|
16
|
+
export { DoughnutChart } from './components/doughnut';
|
|
17
|
+
export { LineChart } from './components/line';
|
|
18
|
+
export { RadarChart } from './components/radar';
|
|
19
|
+
export { MixedBarLineChart } from './components/mixed';
|
|
20
|
+
export { BubbleChart } from './components/bubble';
|