Skip to content

Commit d71ee1e

Browse files
committed
Allowed the use of name colors & improved error detection
1 parent fc69d70 commit d71ee1e

27 files changed

+602
-349
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-data-ui",
33
"private": false,
4-
"version": "2.0.94",
4+
"version": "2.0.95",
55
"type": "module",
66
"description": "A user-empowering data visualization Vue components library",
77
"keywords": [

src/App.vue

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,25 @@ const gaugeDataset = ref({
528528
],
529529
});
530530
531+
const gaugeDatasetTest = ref({
532+
base: 0,
533+
value: 4.2,
534+
series: [
535+
{
536+
from: 0,
537+
to: 3,
538+
},
539+
{
540+
from: 3,
541+
to: 4,
542+
},
543+
{
544+
from: 4,
545+
to: 5,
546+
},
547+
],
548+
});
549+
531550
const chestnutDataset = ref([
532551
{
533552
name: "Root1",
@@ -3204,7 +3223,7 @@ const bar3dConfig = ref({
32043223
style: {
32053224
shape: 'bar',
32063225
chart: {
3207-
// backgroundColor: '#1A1A1A',
3226+
backgroundColor: '#1A1A1A',
32083227
// color: '#CCCCCC',
32093228
title: {
32103229
text: "Title",
@@ -4479,7 +4498,7 @@ const tableHeatmapDataset = ref([
44794498
</VueDataUiTest>
44804499
</template>
44814500
<template #prod>
4482-
<VueDataUi
4501+
<!-- <VueDataUi
44834502
component="VueUiDonut"
44844503
ref="donuttest"
44854504
:dataset="donutDataset"
@@ -4489,7 +4508,7 @@ const tableHeatmapDataset = ref([
44894508
<template #svg="{ svg }">
44904509
<circle :cx="svg.width / 2" :cy="svg.height / 2" :r="30" fill="#FF000033"/>
44914510
</template>
4492-
</VueDataUi>
4511+
</VueDataUi> -->
44934512
</template>
44944513
<template #config>
44954514
{{ PROD_CONFIG.vue_ui_donut }}
@@ -4959,7 +4978,7 @@ const tableHeatmapDataset = ref([
49594978
<VueDataUiTest
49604979
component="VueUiGauge"
49614980
ref="gaugetest"
4962-
:dataset="gaugeDataset"
4981+
:dataset="gaugeDatasetTest"
49634982
>
49644983
<template #svg="{ svg }">
49654984
<circle :cx="svg.width / 2" :cy="svg.height / 2" :r="30" fill="#FF000033"/>
@@ -4971,7 +4990,7 @@ const tableHeatmapDataset = ref([
49714990
<VueDataUi
49724991
component="VueUiGauge"
49734992
ref="gaugetest"
4974-
:dataset="gaugeDataset"
4993+
:dataset="gaugeDatasetTest"
49754994
>
49764995
<template #svg="{ svg }">
49774996
<circle :cx="svg.width / 2" :cy="svg.height / 2" :r="30" fill="#FF000033"/>

src/components/vue-ui-3d-bar.vue

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
dataLabel,
1212
downloadCsv,
1313
error,
14+
getMissingDatasetAttributes,
1415
lightenHexColor,
1516
makeDonut,
1617
objectIsEmpty,
@@ -132,6 +133,48 @@ onMounted(() => {
132133
componentName: 'VueUi3dBar',
133134
type: 'dataset'
134135
})
136+
} else {
137+
if(!props.dataset.series) {
138+
getMissingDatasetAttributes({
139+
datasetObject: props.dataset,
140+
requiredAttributes: ['percentage']
141+
}).forEach(attr => {
142+
error({
143+
componentName: 'VueUi3dBar',
144+
type: 'datasetAttribute',
145+
property: attr
146+
})
147+
})
148+
} else {
149+
props.dataset.series.forEach((serie, i) => {
150+
getMissingDatasetAttributes({
151+
datasetObject: serie,
152+
requiredAttributes: ['name', 'value']
153+
}).forEach(attr => {
154+
error({
155+
componentName: 'VueUi3dBar',
156+
type: 'datasetSerieAttribute',
157+
property: attr,
158+
index: i
159+
})
160+
});
161+
if(serie.breakdown) {
162+
serie.breakdown.forEach((b, j) => {
163+
getMissingDatasetAttributes({
164+
datasetObject: b,
165+
requiredAttributes: ['name', 'value']
166+
}).forEach(attr => {
167+
error({
168+
componentName: 'VueUi3dBar',
169+
type: 'datasetSerieAttribute',
170+
property: attr,
171+
index: `${i} - ${j}`
172+
})
173+
})
174+
})
175+
}
176+
})
177+
}
135178
}
136179
137180
let acceleration = 0;

src/components/vue-ui-chestnut.vue

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
createUid,
1111
downloadCsv,
1212
error,
13+
getMissingDatasetAttributes,
1314
makeDonut,
1415
objectIsEmpty,
1516
opacity,
@@ -105,35 +106,50 @@ const treeTotal = computed(() => {
105106
const mutableDataset = computed(() => {
106107
107108
props.dataset.forEach((ds, i) => {
108-
if ([null, undefined].includes(ds.name)) {
109+
getMissingDatasetAttributes({
110+
datasetObject: ds,
111+
requiredAttributes: ['name', 'branches']
112+
}).forEach(attr => {
109113
error({
110114
componentName: 'VueUiChestnut',
111115
type: 'datasetSerieAttribute',
112-
property: 'name (string)',
116+
property: attr,
113117
index: i
114-
})
115-
}
116-
if([null, undefined].includes(ds.branches)) {
117-
error({
118-
componentName: 'VueUiChestnut',
119-
type: 'datasetSerieAttribute',
120-
property: 'branches',
121-
index: i
122-
})
123-
} else {
118+
});
119+
});
120+
121+
if(ds.branches) {
124122
ds.branches.forEach((branch, j) => {
125-
if([null, undefined].includes(branch.name)) {
123+
getMissingDatasetAttributes({
124+
datasetObject: branch,
125+
requiredAttributes: ['name', 'value']
126+
}).forEach(attr => {
126127
error({
127128
componentName: 'VueUiChestnut',
128129
type: 'datasetSerieAttribute',
129-
property: 'name',
130-
index: j,
131-
key: `branch (at index ${i})`
132-
})
130+
property: attr,
131+
index: `${i} - ${j}`
132+
});
133+
});
134+
135+
if(branch.breakdown) {
136+
branch.breakdown.forEach((b, k) => {
137+
getMissingDatasetAttributes({
138+
datasetObject: b,
139+
requiredAttributes: ['name', 'value']
140+
}).forEach(attr => {
141+
error({
142+
componentName: 'VueUiChestnut',
143+
type: 'datasetSerieAttribute',
144+
property: attr,
145+
index: `${i} - ${j} - ${k}`
146+
});
147+
});
148+
});
133149
}
134-
})
150+
});
135151
}
136-
})
152+
});
137153
138154
return props.dataset.map((root, i) => {
139155
const rootTotal = root.branches.map(branch => branch.value).reduce((a, b) => a + b);

src/components/vue-ui-donut-evolution.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
createUid,
1212
downloadCsv,
1313
error,
14+
getMissingDatasetAttributes,
1415
makeDonut,
1516
objectIsEmpty,
1617
opacity,
@@ -52,6 +53,22 @@ onMounted(() => {
5253
componentName: 'VueUiDonutEvolution',
5354
type: 'dataset'
5455
})
56+
} else {
57+
if(props.dataset.length) {
58+
props.dataset.forEach((ds, i) => {
59+
getMissingDatasetAttributes({
60+
datasetObject: ds,
61+
requiredAttributes: ['name', 'values']
62+
}).forEach(attr => {
63+
error({
64+
componentName: 'VueUiDonutEvolution',
65+
type: 'datasetSerieAttribute',
66+
property: attr,
67+
index: i
68+
})
69+
})
70+
})
71+
}
5572
}
5673
})
5774

src/components/vue-ui-donut.vue

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
downloadCsv,
1212
error,
1313
functionReturnsString,
14+
getMissingDatasetAttributes,
1415
isFunction,
1516
makeDonut,
1617
objectIsEmpty,
@@ -43,8 +44,13 @@ const props = defineProps({
4344
},
4445
});
4546
46-
const isDataset = computed(() => {
47-
return !!props.dataset && props.dataset.length
47+
const isDataset = computed({
48+
get() {
49+
return !!props.dataset && props.dataset.length
50+
},
51+
set(bool) {
52+
return bool
53+
}
4854
})
4955
5056
onMounted(() => {
@@ -55,14 +61,18 @@ onMounted(() => {
5561
})
5662
} else {
5763
props.dataset.forEach((ds, i) => {
58-
if([null, undefined].includes(ds.name)) {
64+
getMissingDatasetAttributes({
65+
datasetObject: ds,
66+
requiredAttributes: ['name', 'values']
67+
}).forEach(attr => {
68+
isDataset.value = false;
5969
error({
6070
componentName: 'VueUiDonut',
6171
type: 'datasetSerieAttribute',
62-
property: 'name (string)',
72+
property: attr,
6373
index: i
6474
})
65-
}
75+
})
6676
})
6777
}
6878
})
@@ -148,21 +158,19 @@ function getData() {
148158
const donutSet = computed(() => {
149159
props.dataset.forEach((ds, i) => {
150160
if([null, undefined].includes(ds.values)) {
151-
error({
152-
componentName: 'VueUiDonut',
153-
type: 'datasetSerieAttribute',
154-
property: 'values (number[])',
155-
index: i
156-
});
161+
return {
162+
...ds,
163+
values: []
164+
}
157165
}
158166
})
159167
return props.dataset
160168
.map((serie, i) => {
161169
return {
162170
name: serie.name,
163171
color: convertColorToHex(serie.color) || palette[i] || palette[i % palette.length],
164-
value: serie.values.reduce((a,b) => a + b, 0),
165-
absoluteValues: serie.values,
172+
value: (serie.values || []).reduce((a,b) => a + b, 0),
173+
absoluteValues: serie.values || [],
166174
seriesIndex: i
167175
}
168176
})
@@ -176,15 +184,15 @@ const legendSet = computed(() => {
176184
return {
177185
name: serie.name,
178186
color: convertColorToHex(serie.color) || palette[i] || palette[i % palette.length],
179-
value: serie.values.reduce((a,b) => a + b, 0),
187+
value: (serie.values || []).reduce((a,b) => a + b, 0),
180188
shape: 'circle',
181189
}
182190
})
183191
.sort((a,b) => b.value - a.value)
184192
.map((el, i) => {
185193
return {
186194
...el,
187-
proportion: el.value / props.dataset.map(m => m.values.reduce((a, b) => a + b, 0)).reduce((a, b) => a + b, 0),
195+
proportion: el.value / props.dataset.map(m => (m.values || []).reduce((a, b) => a + b, 0)).reduce((a, b) => a + b, 0),
188196
opacity: segregated.value.includes(i) ? 0.5 : 1
189197
}
190198
})

src/components/vue-ui-galaxy.vue

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
downloadCsv,
1010
error,
1111
functionReturnsString,
12+
getMissingDatasetAttributes,
1213
isFunction,
1314
objectIsEmpty,
1415
palette,
@@ -49,6 +50,20 @@ onMounted(() => {
4950
componentName: 'VueUiGalaxy',
5051
type: 'dataset'
5152
})
53+
} else {
54+
props.dataset.forEach((ds, i) => {
55+
getMissingDatasetAttributes({
56+
datasetObject: ds,
57+
requiredAttributes: ['name', 'values']
58+
}).forEach(attr => {
59+
error({
60+
componentName: 'VueUiGalaxy',
61+
type: 'datasetSerieAttribute',
62+
property: attr,
63+
index: i
64+
})
65+
})
66+
})
5267
}
5368
});
5469
@@ -143,16 +158,6 @@ const segregatedSet = computed(() => {
143158
})
144159
145160
const galaxySet = computed(() => {
146-
props.dataset.forEach((ds, i) => {
147-
if([null, undefined].includes(ds.values)) {
148-
error({
149-
componentName: 'VueUiGalaxy',
150-
type: 'datasetSerieAttribute',
151-
property: 'values (number[])',
152-
index: i
153-
});
154-
}
155-
})
156161
157162
const res = [];
158163
let start = 0;

0 commit comments

Comments
 (0)