@@ -42,13 +42,6 @@ import { throttle } from '../canvas-lib';
42
42
import { useResponsive } from ' ../useResponsive' ;
43
43
import themes from " ../themes.json" ;
44
44
45
- /**
46
- *
47
- * - Diplay percentages per group (#donut)
48
- * - Add grab cursor when mousedown
49
- *
50
- */
51
-
52
45
const { vue_ui_chord: DEFAULT_CONFIG } = useConfig ();
53
46
54
47
const props = defineProps ({
@@ -290,7 +283,8 @@ function computeChord(matrix, padAngle) {
290
283
endAngle,
291
284
name: formattedDataset .value .labels [i],
292
285
id: createUid (),
293
- color: formattedDataset .value .colors [i]
286
+ color: formattedDataset .value .colors [i],
287
+ proportion: groupSums[i] / totalSum
294
288
});
295
289
currentAngle = endAngle + padAngle;
296
290
}
@@ -910,6 +904,7 @@ defineExpose({
910
904
: style= " {
911
905
overflow: 'visible'
912
906
}"
907
+ : class = " {'vue-ui-chord-rotating': dragging, 'vue-ui-chord-idle': !rotating }"
913
908
@mousedown .prevent = " onDown"
914
909
@touchstart .prevent = " onDown"
915
910
>
@@ -1121,13 +1116,18 @@ defineExpose({
1121
1116
< g v- if = " FINAL_CONFIG.style.chart.arcs.labels.show" >
1122
1117
< template v- if = " FINAL_CONFIG.style.chart.arcs.labels.curved" >
1123
1118
< text
1124
- v- for = " (_g , i) in chordData.groups"
1119
+ v- for = " (g , i) in chordData.groups"
1125
1120
: key= " `curved-label-${i}`"
1126
1121
: font- size= " FINAL_CONFIG.style.chart.arcs.labels.fontSize"
1127
1122
: font- weight= " FINAL_CONFIG.style.chart.arcs.labels.bold ? 'bold' : 'normal'"
1128
1123
: fill= " FINAL_CONFIG.style.chart.arcs.labels.adaptColorToBackground ? adaptColorToBackground(formattedDataset.colors[i]) : FINAL_CONFIG.style.chart.arcs.labels.color" >
1129
1124
< 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
+ }) : ' ' }}
1131
1131
< / textPath>
1132
1132
< / text>
1133
1133
< / template>
@@ -1143,8 +1143,14 @@ defineExpose({
1143
1143
: text- anchor= " rotatedMidAngle(g) > Math.PI ? 'end' : 'start'"
1144
1144
: font- size= " FINAL_CONFIG.style.chart.arcs.labels.fontSize"
1145
1145
: 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
+ }) : ' ' }}
1148
1154
< / text>
1149
1155
< / template>
1150
1156
< / g>
@@ -1324,4 +1330,12 @@ defineExpose({
1324
1330
transform: rotate (- 90deg )
1325
1331
}
1326
1332
}
1333
+
1334
+ .vue - ui- chord- idle {
1335
+ cursor: grab;
1336
+ }
1337
+
1338
+ .vue - ui- chord- rotating {
1339
+ cursor: grabbing;
1340
+ }
1327
1341
< / style>
0 commit comments