@@ -42,13 +42,6 @@ import { throttle } from '../canvas-lib';
4242import { useResponsive } from ' ../useResponsive' ;
4343import themes from " ../themes.json" ;
4444
45- /**
46- *
47- * - Diplay percentages per group (#donut)
48- * - Add grab cursor when mousedown
49- *
50- */
51-
5245const { vue_ui_chord: DEFAULT_CONFIG } = useConfig ();
5346
5447const props = defineProps ({
@@ -290,7 +283,8 @@ function computeChord(matrix, padAngle) {
290283 endAngle,
291284 name: formattedDataset .value .labels [i],
292285 id: createUid (),
293- color: formattedDataset .value .colors [i]
286+ color: formattedDataset .value .colors [i],
287+ proportion: groupSums[i] / totalSum
294288 });
295289 currentAngle = endAngle + padAngle;
296290 }
@@ -910,6 +904,7 @@ defineExpose({
910904 : style= " {
911905 overflow: 'visible'
912906 }"
907+ : class = " {'vue-ui-chord-rotating': dragging, 'vue-ui-chord-idle': !rotating }"
913908 @mousedown .prevent = " onDown"
914909 @touchstart .prevent = " onDown"
915910 >
@@ -1121,13 +1116,18 @@ defineExpose({
11211116 < g v- if = " FINAL_CONFIG.style.chart.arcs.labels.show" >
11221117 < template v- if = " FINAL_CONFIG.style.chart.arcs.labels.curved" >
11231118 < text
1124- v- for = " (_g , i) in chordData.groups"
1119+ v- for = " (g , i) in chordData.groups"
11251120 : key= " `curved-label-${i}`"
11261121 : font- size= " FINAL_CONFIG.style.chart.arcs.labels.fontSize"
11271122 : font- weight= " FINAL_CONFIG.style.chart.arcs.labels.bold ? 'bold' : 'normal'"
11281123 : fill= " FINAL_CONFIG.style.chart.arcs.labels.adaptColorToBackground ? adaptColorToBackground(formattedDataset.colors[i]) : FINAL_CONFIG.style.chart.arcs.labels.color" >
11291124 < textPath : href= " `#labelPath-${i}_${uid}`" startOffset= " 50%" text- anchor= " middle" >
1130- {{ formattedDataset .labels [i] }}
1125+ {{ formattedDataset .labels [i] }}{{ FINAL_CONFIG .style .chart .arcs .labels .showPercentage ? dataLabel ({
1126+ p: ' (' ,
1127+ v: isNaN (g .proportion ) ? 0 : g .proportion * 100 ,
1128+ s: ' %)' ,
1129+ r: FINAL_CONFIG .style .chart .arcs .labels .roundingPercentage
1130+ }) : ' ' }}
11311131 < / textPath>
11321132 < / text>
11331133 < / template>
@@ -1143,8 +1143,14 @@ defineExpose({
11431143 : text- anchor= " rotatedMidAngle(g) > Math.PI ? 'end' : 'start'"
11441144 : font- size= " FINAL_CONFIG.style.chart.arcs.labels.fontSize"
11451145 : font- weight= " FINAL_CONFIG.style.chart.arcs.labels.bold ? 'bold' : 'normal'"
1146- : fill= " FINAL_CONFIG.style.chart.arcs.labels.color" >
1147- {{ formattedDataset .labels [i] }}
1146+ : fill= " FINAL_CONFIG.style.chart.arcs.labels.color"
1147+ >
1148+ {{ formattedDataset .labels [i] }}{{ FINAL_CONFIG .style .chart .arcs .labels .showPercentage ? dataLabel ({
1149+ p: ' (' ,
1150+ v: isNaN (g .proportion ) ? 0 : g .proportion * 100 ,
1151+ s: ' %)' ,
1152+ r: FINAL_CONFIG .style .chart .arcs .labels .roundingPercentage
1153+ }) : ' ' }}
11481154 < / text>
11491155 < / template>
11501156 < / g>
@@ -1324,4 +1330,12 @@ defineExpose({
13241330 transform: rotate (- 90deg )
13251331 }
13261332}
1333+
1334+ .vue - ui- chord- idle {
1335+ cursor: grab;
1336+ }
1337+
1338+ .vue - ui- chord- rotating {
1339+ cursor: grabbing;
1340+ }
13271341< / style>
0 commit comments