@@ -31,6 +31,7 @@ import {
31
31
setOpacity ,
32
32
themePalettes ,
33
33
XMLNS ,
34
+ checkNaN ,
34
35
} from " ../lib" ;
35
36
import { throttle } from " ../canvas-lib" ;
36
37
import { useNestedProp } from " ../useNestedProp" ;
@@ -183,17 +184,19 @@ function animateWithGhost(finalValues, duration = 1000, stagger = 50) {
183
184
const ghostByGroup = [];
184
185
let cursor = 0 ;
185
186
props .dataset .forEach ((ds , groupIndex ) => {
186
- const realTotal = ds .series .reduce (
187
+ const realTotal = checkNaN ( ds .series .reduce (
187
188
(sum , s ) =>
188
- sum + sanitizeArray (s .values ).reduce ((a , b ) => a + b, 0 ),
189
+ sum + checkNaN ( sanitizeArray (s .values ).reduce ((a , b ) => a + b, 0 ) ),
189
190
0
190
- );
191
- const animatedTotal = animatedValues .value
191
+ ));
192
+
193
+ const animatedTotal = checkNaN (animatedValues .value
192
194
.slice (cursor, cursor + ds .series .length )
193
- .reduce ((a , b ) => a + b, 0 );
195
+ .reduce ((a , b ) => a + b, 0 ));
196
+
194
197
const ghostValue = realTotal - animatedTotal;
195
198
196
- if (ghostValue > 0.001 ) {
199
+ if (ghostValue > Number . MIN_VALUE ) {
197
200
ghostByGroup .push ({
198
201
name: " __ghost__" ,
199
202
arcOf: ds .name ,
@@ -629,18 +632,19 @@ const radii = computed(() => {
629
632
630
633
const donuts = computed (() => {
631
634
return mutableDataset .value .map ((ds , i ) => {
632
- const radius =
633
- donutSize .value - (i * donutSize .value ) / mutableDataset .value .length ;
635
+ const hasData = Math . abs ( ds . series . map ( s => s . value ). reduce (( a , b ) => a + b, 0 )) > 0 ;
636
+ const radius = donutSize .value - (i * donutSize .value ) / mutableDataset .value .length ;
634
637
const ghost = isFirstLoad .value
635
638
? ghostSlices .value .find ((g ) => g .datasetIndex === i)
636
639
: null ;
637
- const series = [... ds .series , ... (ghost ? [ghost] : [])].map ((s ) => ({
638
- ... s,
639
- value: s .value < 0.001 ? 0.001 : s .value ,
640
- }));
641
-
640
+ const series = [... ds .series , ... (ghost ? [ghost] : [])].map ((s ) => ({
641
+ ... s,
642
+ value: s .value < 0.00000000001 ? Number . MIN_VALUE : s .value ,
643
+ }));
644
+
642
645
return {
643
646
... ds,
647
+ hasData,
644
648
radius,
645
649
donut: makeDonut (
646
650
{ series },
@@ -1181,12 +1185,14 @@ defineExpose({
1181
1185
1182
1186
<!-- NESTED DONUTS -->
1183
1187
<g v-for="(item, i) in donuts">
1184
- <g v-for="(arc, j) in item.donut.filter((el) => !el.ghost)">
1185
- <path data-cy="datapoint-arc" class="vue-ui-donut-arc-path" :d="arc.arcSlice"
1186
- :fill="setOpacity(arc.color, 80)" :stroke="FINAL_CONFIG.style.chart.backgroundColor"
1187
- :stroke-width="FINAL_CONFIG.style.chart.layout.donut.borderWidth"
1188
- :filter="getBlurFilter(arc, j)" />
1189
- </g>
1188
+ <template v-if="item.hasData">
1189
+ <g v-for="(arc, j) in item.donut.filter((el) => !el.ghost)">
1190
+ <path data-cy="datapoint-arc" class="vue-ui-donut-arc-path" :d="arc.arcSlice"
1191
+ :fill="setOpacity(arc.color, 80)" :stroke="FINAL_CONFIG.style.chart.backgroundColor"
1192
+ :stroke-width="FINAL_CONFIG.style.chart.layout.donut.borderWidth"
1193
+ :filter="getBlurFilter(arc, j)" />
1194
+ </g>
1195
+ </template>
1190
1196
</g>
1191
1197
1192
1198
<g v-if="FINAL_CONFIG.style.chart.useGradient">
0 commit comments