11<script setup>
22import { ref , computed , nextTick } from " vue" ;
3- import { makeDonut , palette , convertColorToHex , opacity , makeXls } from ' ../lib' ;
3+ import { calcMarkerOffsetX , calcMarkerOffsetY , calcNutArrowPath , makeDonut , palette , convertColorToHex , opacity , makeXls } from ' ../lib' ;
44import pdf from " ../pdf" ;
55import img from " ../img" ;
66import mainConfig from " ../default_configs.json" ;
@@ -314,7 +314,7 @@ defineExpose({
314314
315315<template >
316316 <div :ref =" `donutChart`" :class =" `vue-ui-donut ${donutConfig.useCssAnimation ? '' : 'vue-ui-dna'}`" :style =" `font-family:${donutConfig.style.fontFamily};width:100%; text-align:center;${donutConfig.userOptions.show ? 'padding-top:36px' : ''}`" :id =" `donut__${uid}`" >
317- <div v-if =" (!mutableConfig.inside || isPrinting) && donutConfig.style.chart.title.text" :style =" `width:100%;background:${donutConfig.style.chart.backgroundColor}`" >
317+ <div v-if =" (!mutableConfig.inside || isPrinting) && donutConfig.style.chart.title.text" :style =" `width:100%;background:${donutConfig.style.chart.backgroundColor};padding-bottom:24px `" >
318318 <!-- TITLE AS DIV -->
319319 <Title
320320 :config =" {
@@ -391,7 +391,7 @@ defineExpose({
391391 :font-size =" donutConfig.style.chart.title.fontSize"
392392 :fill =" donutConfig.style.chart.title.color"
393393 :x =" svg.width / 2"
394- :y =" 48 "
394+ :y =" 24 "
395395 text-anchor =" middle"
396396 :style =" `font-weight:${donutConfig.style.chart.title.bold ? 'bold' : ''}`"
397397 >
@@ -403,13 +403,35 @@ defineExpose({
403403 :font-size =" donutConfig.style.chart.title.subtitle.fontSize"
404404 :fill =" donutConfig.style.chart.title.subtitle.color"
405405 :x =" svg.width / 2"
406- :y =" 48 + donutConfig.style.chart.title.fontSize"
406+ :y =" 24 + donutConfig.style.chart.title.fontSize"
407407 text-anchor =" middle"
408408 :style =" `font-weight:${donutConfig.style.chart.title.subtitle.bold ? 'bold' : ''}`"
409409 >
410410 {{ donutConfig.style.chart.title.subtitle.text }}
411411 </text >
412412 </g >
413+
414+ <!-- LABEL CONNECTOR -->
415+ <g v-for =" (arc, i) in currentDonut" >
416+ <path
417+ v-if =" isArcBigEnough(arc) && mutableConfig.dataLabels.show"
418+ :d =" calcNutArrowPath(arc, {x: svg.width / 2, y: svg.height / 2})"
419+ :stroke =" arc.color"
420+ stroke-width =" 1"
421+ stroke-linecap =" round"
422+ stroke-linejoin =" round"
423+ fill =" none"
424+ :class =" !defaultConfig.useBlurOnHover || [null, undefined].includes(selectedSerie) || selectedSerie === i ? '' : 'vue-ui-donut-blur'"
425+ />
426+ </g >
427+
428+ <path
429+ v-for =" (arc, i) in currentDonut"
430+ :stroke =" donutConfig.style.chart.backgroundColor"
431+ :d =" arc.path"
432+ :stroke-width =" defaultConfig.style.chart.layout.donut.strokeWidth"
433+ fill =" #FFFFFF"
434+ />
413435 <path
414436 v-for =" (arc, i) in currentDonut"
415437 class =" vue-ui-donut-arc-path"
@@ -503,9 +525,22 @@ defineExpose({
503525 <text
504526 :data-cy =" `donut-datalabel-value-${i}`"
505527 v-if =" isArcBigEnough(arc) && mutableConfig.dataLabels.show"
506- text-anchor =" middle"
507- :x =" calcDonutMarkerLabelPositionX(arc)"
508- :y =" arc.center.endY - donutConfig.style.chart.layout.labels.percentage.fontSize / 2"
528+ :text-anchor =" calcMarkerOffsetX(arc, true).anchor"
529+ :x =" calcMarkerOffsetX(arc).x"
530+ :y =" calcMarkerOffsetY(arc)"
531+ :fill =" arc.color"
532+ :font-size =" donutConfig.style.chart.layout.labels.percentage.fontSize * 0.8"
533+ font-family =" Arial"
534+ :class =" !defaultConfig.useBlurOnHover || [null, undefined].includes(selectedSerie) || selectedSerie === i ? '' : 'vue-ui-donut-blur'"
535+ >
536+ ⬤
537+ </text >
538+ <text
539+ :data-cy =" `donut-datalabel-value-${i}`"
540+ v-if =" isArcBigEnough(arc) && mutableConfig.dataLabels.show"
541+ :text-anchor =" calcMarkerOffsetX(arc, true, 20).anchor"
542+ :x =" calcMarkerOffsetX(arc, true, 20).x"
543+ :y =" calcMarkerOffsetY(arc)"
509544 :fill =" donutConfig.style.chart.layout.labels.percentage.color"
510545 :font-size =" donutConfig.style.chart.layout.labels.percentage.fontSize"
511546 :style =" `font-weight:${donutConfig.style.chart.layout.labels.percentage.bold ? 'bold': ''}`"
@@ -514,10 +549,10 @@ defineExpose({
514549 </text >
515550 <text
516551 :data-cy =" `donut-datalabel-name-${i}`"
517- v-if =" isArcBigEnough(arc) && mutableConfig.dataLabels.show"
518- text-anchor =" middle "
519- :x =" calcDonutMarkerLabelPositionX (arc) "
520- :y =" arc.center.endY + donutConfig.style.chart.layout.labels.percentage.fontSize / 2 "
552+ v-if =" isArcBigEnough(arc, true, 20 ) && mutableConfig.dataLabels.show"
553+ : text-anchor =" calcMarkerOffsetX(arc).anchor "
554+ :x =" calcMarkerOffsetX (arc, true, 20).x "
555+ :y =" calcMarkerOffsetY( arc) + donutConfig.style.chart.layout.labels.percentage.fontSize"
521556 :fill =" donutConfig.style.chart.layout.labels.name.color"
522557 :font-size =" donutConfig.style.chart.layout.labels.name.fontSize"
523558 :style =" `font-weight:${donutConfig.style.chart.layout.labels.name.bold ? 'bold': ''}`"
0 commit comments