Skip to content

Commit d28bb6c

Browse files
committed
Fix - VueUiOnion - Fix incorrect path calculation
1 parent 3b2af89 commit d28bb6c

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

src/components/vue-ui-onion.vue

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,16 +280,23 @@ const mutableDataset = computed(() => {
280280
});
281281
282282
function peelOnion(radius, percentage) {
283-
const circumference = radius * (1.5 + (percentage / 100 > 1 / 3 ? 0 : 1 - percentage / 100)) * Math.PI;
284-
const bg = radius * 1.5 * Math.PI;
283+
const fullCircumference = 2 * Math.PI * radius;
284+
const trackCircumference = fullCircumference * 0.75;
285+
const dashArray = `${trackCircumference} ${fullCircumference}`;
286+
const dashOffset = trackCircumference * (1 - percentage / 100);
287+
285288
return {
286-
bgDashArray: `${bg} ${bg}`,
287-
bgDashOffset: bg - percentage / 100 * bg,
288-
dashArray: `${circumference} ${circumference}`,
289-
dashOffset: circumference - percentage / 100 * circumference,
289+
bgDashArray: `${trackCircumference} ${fullCircumference}`,
290+
bgDashOffset: 0,
291+
dashArray,
292+
dashOffset,
290293
fullOffset: 0,
291-
active: `M${drawableArea.value.centerX},${drawableArea.value.centerY} A ${radius},${radius} 0 0 0 ${drawableArea.value.right},${drawableArea.value.top}`,
292-
}
294+
active: `
295+
M ${drawableArea.value.centerX},${drawableArea.value.centerY - radius}
296+
A ${radius},${radius} 0 1 1
297+
${drawableArea.value.centerX + radius * Math.cos(Math.PI * 3 / 4)},${drawableArea.value.centerY + radius * Math.sin(Math.PI * 3 / 4)}
298+
`.trim(),
299+
};
293300
}
294301
295302
const emit = defineEmits(['selectLegend']);

0 commit comments

Comments
 (0)