Skip to content

Commit

Permalink
Merge pull request #464 from kiva/vue-3-donut-chart
Browse files Browse the repository at this point in the history
fix: pie chart not animating in vue 3
  • Loading branch information
emuvente authored Oct 4, 2024
2 parents 95526e5 + c15efec commit ef04ad7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions @kiva/kv-components/vue/KvPieChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
v-for="(slice, index) in slices"
:key="index"
class="tw-origin-center tw-transition-transform"
:style="activeSlice === slice ? { transform: 'scale(1.1)' } : {}"
:style="isSliceActive(slice) ? { transform: 'scale(1.1)' } : {}"
:d="slice.path"
:stroke="slice.color"
:stroke-width="lineWidth"
Expand Down Expand Up @@ -174,7 +174,7 @@ export default {
const end = start + value.percent;
const [startX, startY] = circumPointFromAngle(cX, cY, r, start * Math.PI * 2);
let path = `M ${startX},${startY} `;
if (value.percent === 1) {
if (value.percent > 0.99) {
// Draw a full circle in two arcs
const [midX, midY] = circumPointFromAngle(cX, cY, r, (start + end) * Math.PI);
path += `A ${r},${r} 0 0,1 ${midX},${midY} `;
Expand Down Expand Up @@ -210,6 +210,10 @@ export default {
}
};
const isSliceActive = (slice) => {
return activeSlice.value === slice;
};
const setActiveSlice = (slice) => {
activeSlice.value = slice;
emit('click', slice.label);
Expand All @@ -228,6 +232,7 @@ export default {
pageCount,
prevPage,
nextPage,
isSliceActive,
setActiveSlice,
};
},
Expand Down

0 comments on commit ef04ad7

Please sign in to comment.