@@ -31,6 +31,7 @@ import {
3131 setOpacity ,
3232 themePalettes ,
3333 XMLNS ,
34+ checkNaN ,
3435} from " ../lib" ;
3536import { throttle } from " ../canvas-lib" ;
3637import { useNestedProp } from " ../useNestedProp" ;
@@ -183,17 +184,19 @@ function animateWithGhost(finalValues, duration = 1000, stagger = 50) {
183184 const ghostByGroup = [];
184185 let cursor = 0 ;
185186 props .dataset .forEach ((ds , groupIndex ) => {
186- const realTotal = ds .series .reduce (
187+ const realTotal = checkNaN ( ds .series .reduce (
187188 (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 ) ),
189190 0
190- );
191- const animatedTotal = animatedValues .value
191+ ));
192+
193+ const animatedTotal = checkNaN (animatedValues .value
192194 .slice (cursor, cursor + ds .series .length )
193- .reduce ((a , b ) => a + b, 0 );
195+ .reduce ((a , b ) => a + b, 0 ));
196+
194197 const ghostValue = realTotal - animatedTotal;
195198
196- if (ghostValue > 0.001 ) {
199+ if (ghostValue > Number . MIN_VALUE ) {
197200 ghostByGroup .push ({
198201 name: " __ghost__" ,
199202 arcOf: ds .name ,
@@ -629,18 +632,19 @@ const radii = computed(() => {
629632
630633const donuts = computed (() => {
631634 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 ;
634637 const ghost = isFirstLoad .value
635638 ? ghostSlices .value .find ((g ) => g .datasetIndex === i)
636639 : 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+
642645 return {
643646 ... ds,
647+ hasData,
644648 radius,
645649 donut: makeDonut (
646650 { series },
@@ -1181,12 +1185,14 @@ defineExpose({
11811185
11821186 <!-- NESTED DONUTS -->
11831187 <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>
11901196 </g>
11911197
11921198 <g v-if="FINAL_CONFIG.style.chart.useGradient">
0 commit comments