Skip to content

Commit 3e6ede8

Browse files
committed
Fix - VueUiDonut - Fix layout when only one serie is visible in polar mode
1 parent 28e8dc8 commit 3e6ede8

File tree

1 file changed

+62
-31
lines changed

1 file changed

+62
-31
lines changed

src/components/vue-ui-donut.vue

Lines changed: 62 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -804,22 +804,34 @@ defineExpose({
804804
</template>
805805

806806
<template v-if="total && FINAL_CONFIG.type === 'polar'">
807-
<path
808-
v-for="(arc, i) in currentDonut"
809-
:stroke="FINAL_CONFIG.style.chart.backgroundColor"
810-
:d="polarAreas[i].path"
811-
fill="#FFFFFF"
812-
/>
813-
<path
814-
v-for="(arc, i) in currentDonut"
815-
class="vue-ui-donut-arc-path"
816-
:data-cy="`donut-arc-${i}`"
817-
:d="polarAreas[i].path"
818-
:fill="FINAL_CONFIG.style.chart.useGradient ? `url(#polar_gradient_${i}_${uid})` : arc.color"
819-
:stroke="FINAL_CONFIG.style.chart.backgroundColor"
820-
:stroke-width="FINAL_CONFIG.style.chart.layout.donut.borderWidth"
821-
:filter="getBlurFilter(i)"
822-
/>
807+
<g v-if="currentDonut.length > 1">
808+
<path
809+
v-for="(arc, i) in currentDonut"
810+
:stroke="FINAL_CONFIG.style.chart.backgroundColor"
811+
:d="polarAreas[i].path"
812+
fill="#FFFFFF"
813+
/>
814+
<path
815+
v-for="(arc, i) in currentDonut"
816+
class="vue-ui-donut-arc-path"
817+
:data-cy="`donut-arc-${i}`"
818+
:d="polarAreas[i].path"
819+
:fill="FINAL_CONFIG.style.chart.useGradient ? `url(#polar_gradient_${i}_${uid})` : arc.color"
820+
:stroke="FINAL_CONFIG.style.chart.backgroundColor"
821+
:stroke-width="FINAL_CONFIG.style.chart.layout.donut.borderWidth"
822+
:filter="getBlurFilter(i)"
823+
/>
824+
</g>
825+
<g v-else>
826+
<circle
827+
:cx="svg.width / 2"
828+
:cy="svg.height / 2"
829+
:r="minSize"
830+
:fill="FINAL_CONFIG.style.chart.useGradient ? `url(#polar_gradient_${0}_${uid})` : currentDonut[0].color"
831+
:stroke="FINAL_CONFIG.style.chart.backgroundColor"
832+
:stroke-width="FINAL_CONFIG.style.chart.layout.donut.borderWidth"
833+
/>
834+
</g>
823835
</template>
824836

825837
<template v-else>
@@ -844,21 +856,40 @@ defineExpose({
844856

845857
<!-- TOOLTIP TRAPS -->
846858
<template v-if="total">
847-
<path
848-
v-for="(arc, i) in currentDonut"
849-
:data-cy="`donut-trap-${i}`"
850-
data-cy-donut-trap
851-
:d="FINAL_CONFIG.type === 'classic' ? arc.arcSlice : polarAreas[i].path"
852-
:fill="selectedSerie === i ? 'rgba(0,0,0,0.1)' : 'transparent'"
853-
@mouseenter="useTooltip({
854-
datapoint: arc,
855-
relativeIndex: i,
856-
seriesIndex: arc.seriesIndex,
857-
show: true
858-
})"
859-
@mouseleave="isTooltip = false; selectedSerie = null"
860-
@click="selectDatapoint(arc, i)"
861-
/>
859+
<g v-if="currentDonut.length > 1 || FINAL_CONFIG.type === 'classic'">
860+
<path
861+
v-for="(arc, i) in currentDonut"
862+
:data-cy="`donut-trap-${i}`"
863+
data-cy-donut-trap
864+
:d="FINAL_CONFIG.type === 'classic' ? arc.arcSlice : polarAreas[i].path"
865+
:fill="selectedSerie === i ? 'rgba(0,0,0,0.1)' : 'transparent'"
866+
@mouseenter="useTooltip({
867+
datapoint: arc,
868+
relativeIndex: i,
869+
seriesIndex: arc.seriesIndex,
870+
show: true
871+
})"
872+
@mouseleave="isTooltip = false; selectedSerie = null"
873+
@click="selectDatapoint(arc, i)"
874+
/>
875+
</g>
876+
<g v-else>
877+
<circle
878+
:cx="svg.width / 2"
879+
:cy="svg.height / 2"
880+
:r="minSize"
881+
:fill="selectedSerie === i ? 'rgba(0,0,0,0.1)' : 'transparent'"
882+
data-cy-donut-trap
883+
@mouseenter="useTooltip({
884+
datapoint: currentDonut[0],
885+
relativeIndex: 0,
886+
seriesIndex: currentDonut[0].seriesIndex,
887+
show: true
888+
})"
889+
@mouseleave="isTooltip = false; selectedSerie = null"
890+
@click="selectDatapoint(currentDonut[0], i)"
891+
/>
892+
</g>
862893
</template>
863894

864895
<!-- HOLLOW LABELS (Classic donut only )-->

0 commit comments

Comments
 (0)