@@ -397,6 +397,12 @@ function toggleFullscreen(state) {
397397 step .value += 1 ;
398398}
399399
400+ const isSafari = computed (() => {
401+ return / ^ ((?!chrome| android). )* safari/ i .test (navigator .userAgent );
402+ })
403+
404+ console .log (isSafari .value )
405+
400406function selectDatapoint (datapoint , index ) {
401407 emit (' selectDatapoint' , { datapoint, index })
402408}
@@ -617,46 +623,70 @@ defineExpose({
617623
618624 <!-- DATALABELS -->
619625 <g v-for =" (arc, i) in currentDonut" :filter =" getBlurFilter(i)" >
620- <text
621- :data-cy =" `donut-datalabel-value-${i}`"
622- v-if =" isArcBigEnough(arc) && mutableConfig.dataLabels.show"
623- :text-anchor =" calcMarkerOffsetX(arc, true).anchor"
624- :x =" calcMarkerOffsetX(arc).x"
625- :y =" calcMarkerOffsetY(arc)"
626- :fill =" arc.color"
627- :font-size =" donutConfig.style.chart.layout.labels.percentage.fontSize * 0.8"
628- font-family =" Arial"
629- :filter =" !defaultConfig.useBlurOnHover || [null, undefined].includes(selectedSerie) || selectedSerie === i ? ``: `url(#blur_${uid})`"
630- @click =" selectDatapoint(arc, i)"
631- >
632- ⬤
633- </text >
634- <text
635- :data-cy =" `donut-datalabel-value-${i}`"
636- v-if =" isArcBigEnough(arc) && mutableConfig.dataLabels.show"
637- :text-anchor =" calcMarkerOffsetX(arc, true, 20).anchor"
638- :x =" calcMarkerOffsetX(arc, true, 20).x"
639- :y =" calcMarkerOffsetY(arc)"
640- :fill =" donutConfig.style.chart.layout.labels.percentage.color"
641- :font-size =" donutConfig.style.chart.layout.labels.percentage.fontSize"
642- :style =" `font-weight:${donutConfig.style.chart.layout.labels.percentage.bold ? 'bold': ''}`"
643- @click =" selectDatapoint(arc, i)"
644- >
645- {{ displayArcPercentage(arc, currentDonut) }} {{ donutConfig.style.chart.layout.labels.value.show ? `(${dataLabel({p: donutConfig.style.chart.layout.labels.dataLabels.prefix, v: arc.value, s: donutConfig.style.chart.layout.labels.dataLabels.suffix, rounding: donutConfig.style.chart.layout.labels.value.rounding})})` : '' }}
646- </text >
647- <text
648- :data-cy =" `donut-datalabel-name-${i}`"
649- v-if =" isArcBigEnough(arc, true, 20) && mutableConfig.dataLabels.show"
650- :text-anchor =" calcMarkerOffsetX(arc).anchor"
651- :x =" calcMarkerOffsetX(arc, true, 20).x"
652- :y =" calcMarkerOffsetY(arc) + donutConfig.style.chart.layout.labels.percentage.fontSize"
653- :fill =" donutConfig.style.chart.layout.labels.name.color"
654- :font-size =" donutConfig.style.chart.layout.labels.name.fontSize"
655- :style =" `font-weight:${donutConfig.style.chart.layout.labels.name.bold ? 'bold': ''}`"
656- @click =" selectDatapoint(arc, i)"
657- >
658- {{ arc.name }}
659- </text >
626+ <g v-if =" donutConfig.style.chart.layout.labels.dataLabels.useLabelSlots" >
627+ <foreignObject
628+ :x =" calcMarkerOffsetX(arc, true).anchor === 'end' ? calcMarkerOffsetX(arc).x - 120 : calcMarkerOffsetX(arc, true).anchor === 'middle' ? calcMarkerOffsetX(arc).x - 60 : calcMarkerOffsetX(arc).x"
629+ :y =" calcMarkerOffsetY(arc) - (isSafari ? 20 : 0)"
630+ width =" 120"
631+ height =" 60"
632+ style =" overflow : visible ;"
633+ >
634+ <div :class =" {'vue-ui-donut-datalabel-slot': true, 'vue-ui-donut-datalabel-slot-not-safari' : !isSafari}" >
635+ <slot name =" dataLabel" v-bind =" {
636+ datapoint: arc,
637+ isBlur: !defaultConfig.useBlurOnHover || [null, undefined].includes(selectedSerie) || selectedSerie === i,
638+ isSafari: isSafari,
639+ isVisible: isArcBigEnough(arc) && mutableConfig.dataLabels.show,
640+ textAlign: calcMarkerOffsetX(arc, true, 16, true).anchor,
641+ flexAlign: calcMarkerOffsetX(arc, true, 16).anchor,
642+ percentage: displayArcPercentage(arc, currentDonut),
643+ }" />
644+ </div >
645+ </foreignObject >
646+ </g >
647+
648+ <g v-else >
649+ <text
650+ :data-cy =" `donut-datalabel-value-${i}`"
651+ v-if =" isArcBigEnough(arc) && mutableConfig.dataLabels.show"
652+ :text-anchor =" calcMarkerOffsetX(arc, true).anchor"
653+ :x =" calcMarkerOffsetX(arc).x"
654+ :y =" calcMarkerOffsetY(arc)"
655+ :fill =" arc.color"
656+ :font-size =" donutConfig.style.chart.layout.labels.percentage.fontSize * 0.8"
657+ font-family =" Arial"
658+ :filter =" !defaultConfig.useBlurOnHover || [null, undefined].includes(selectedSerie) || selectedSerie === i ? ``: `url(#blur_${uid})`"
659+ @click =" selectDatapoint(arc, i)"
660+ >
661+ ⬤
662+ </text >
663+ <text
664+ :data-cy =" `donut-datalabel-value-${i}`"
665+ v-if =" isArcBigEnough(arc) && mutableConfig.dataLabels.show"
666+ :text-anchor =" calcMarkerOffsetX(arc, true, 20).anchor"
667+ :x =" calcMarkerOffsetX(arc, true, 20).x"
668+ :y =" calcMarkerOffsetY(arc)"
669+ :fill =" donutConfig.style.chart.layout.labels.percentage.color"
670+ :font-size =" donutConfig.style.chart.layout.labels.percentage.fontSize"
671+ :style =" `font-weight:${donutConfig.style.chart.layout.labels.percentage.bold ? 'bold': ''}`"
672+ @click =" selectDatapoint(arc, i)"
673+ >
674+ {{ displayArcPercentage(arc, currentDonut) }} {{ donutConfig.style.chart.layout.labels.value.show ? `(${dataLabel({p: donutConfig.style.chart.layout.labels.dataLabels.prefix, v: arc.value, s: donutConfig.style.chart.layout.labels.dataLabels.suffix, rounding: donutConfig.style.chart.layout.labels.value.rounding})})` : '' }}
675+ </text >
676+ <text
677+ :data-cy =" `donut-datalabel-name-${i}`"
678+ v-if =" isArcBigEnough(arc, true, 20) && mutableConfig.dataLabels.show"
679+ :text-anchor =" calcMarkerOffsetX(arc).anchor"
680+ :x =" calcMarkerOffsetX(arc, true, 20).x"
681+ :y =" calcMarkerOffsetY(arc) + donutConfig.style.chart.layout.labels.percentage.fontSize"
682+ :fill =" donutConfig.style.chart.layout.labels.name.color"
683+ :font-size =" donutConfig.style.chart.layout.labels.name.fontSize"
684+ :style =" `font-weight:${donutConfig.style.chart.layout.labels.name.bold ? 'bold': ''}`"
685+ @click =" selectDatapoint(arc, i)"
686+ >
687+ {{ arc.name }}
688+ </text >
689+ </g >
660690 </g >
661691
662692 <!-- LEGEND AS G -->
@@ -801,4 +831,16 @@ path {
801831 width :100% ;
802832}
803833
834+ .vue-ui-donut-datalabel-slot {
835+ width : 100% ;
836+ height : -webkit-fit-content ;
837+ height : fit-content ;
838+ }
839+
840+ .vue-ui-donut-datalabel-slot-not-safari {
841+ position : absolute ;
842+ top :0 ;
843+ transform : translateY (-50% );
844+ }
845+
804846 </style >
0 commit comments