Skip to content

Commit 0fcea8b

Browse files
authored
Merge pull request #117 from 2113ic/fix/vue-ui-sparkstackbar
Fix/vue ui sparkstackbar
2 parents 3eb958b + 2169aa2 commit 0fcea8b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/components/vue-ui-sparkstackbar.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,18 @@ const total = computed(() => {
171171
172172
const absoluteDataset = computed(() => {
173173
return safeDatasetCopy.value.map((d, i) => {
174+
const dValue = d.value || 0;
175+
const _dProportion = dValue / total.value;
176+
const dProportion = isNaN(_dProportion) ? 0 : _dProportion;
177+
const dWidth = dProportion * svg.value.width;
178+
174179
return {
175180
...d,
176-
value: d.value || 0,
177-
proportion: (d.value || 0) / total.value,
178-
width: (d.value || 0) / total.value * svg.value.width,
181+
value: dValue,
182+
proportion: dProportion,
183+
width: dWidth || svg.value.width / safeDatasetCopy.value.length,
179184
proportionLabel: dataLabel({
180-
v: (d.value || 0) / total.value * 100,
185+
v: dProportion * 100,
181186
s: '%',
182187
r: FINAL_CONFIG.value.style.legend.percentage.rounding
183188
}),

0 commit comments

Comments
 (0)