1
1
<script setup>
2
2
import { 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' ;
4
4
import pdf from " ../pdf" ;
5
5
import img from " ../img" ;
6
6
import mainConfig from " ../default_configs.json" ;
@@ -314,7 +314,7 @@ defineExpose({
314
314
315
315
<template >
316
316
<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 `" >
318
318
<!-- TITLE AS DIV -->
319
319
<Title
320
320
:config =" {
@@ -391,7 +391,7 @@ defineExpose({
391
391
:font-size =" donutConfig.style.chart.title.fontSize"
392
392
:fill =" donutConfig.style.chart.title.color"
393
393
:x =" svg.width / 2"
394
- :y =" 48 "
394
+ :y =" 24 "
395
395
text-anchor =" middle"
396
396
:style =" `font-weight:${donutConfig.style.chart.title.bold ? 'bold' : ''}`"
397
397
>
@@ -403,13 +403,35 @@ defineExpose({
403
403
:font-size =" donutConfig.style.chart.title.subtitle.fontSize"
404
404
:fill =" donutConfig.style.chart.title.subtitle.color"
405
405
:x =" svg.width / 2"
406
- :y =" 48 + donutConfig.style.chart.title.fontSize"
406
+ :y =" 24 + donutConfig.style.chart.title.fontSize"
407
407
text-anchor =" middle"
408
408
:style =" `font-weight:${donutConfig.style.chart.title.subtitle.bold ? 'bold' : ''}`"
409
409
>
410
410
{{ donutConfig.style.chart.title.subtitle.text }}
411
411
</text >
412
412
</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
+ />
413
435
<path
414
436
v-for =" (arc, i) in currentDonut"
415
437
class =" vue-ui-donut-arc-path"
@@ -503,9 +525,22 @@ defineExpose({
503
525
<text
504
526
:data-cy =" `donut-datalabel-value-${i}`"
505
527
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)"
509
544
:fill =" donutConfig.style.chart.layout.labels.percentage.color"
510
545
:font-size =" donutConfig.style.chart.layout.labels.percentage.fontSize"
511
546
:style =" `font-weight:${donutConfig.style.chart.layout.labels.percentage.bold ? 'bold': ''}`"
@@ -514,10 +549,10 @@ defineExpose({
514
549
</text >
515
550
<text
516
551
: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"
521
556
:fill =" donutConfig.style.chart.layout.labels.name.color"
522
557
:font-size =" donutConfig.style.chart.layout.labels.name.fontSize"
523
558
:style =" `font-weight:${donutConfig.style.chart.layout.labels.name.bold ? 'bold': ''}`"
0 commit comments