Skip to content

Commit

Permalink
VueUiDonut add @selectDatapoint emit
Browse files Browse the repository at this point in the history
  • Loading branch information
graphieros committed Mar 14, 2024
1 parent 90561cd commit 2698fde
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-data-ui",
"private": false,
"version": "2.0.20",
"version": "2.0.21",
"type": "module",
"description": "A user-empowering data visualization Vue components library",
"keywords": [
Expand Down
11 changes: 9 additions & 2 deletions src/components/vue-ui-donut.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const svg = computed(() => {
}
});
const emit = defineEmits(['selectLegend'])
const emit = defineEmits(['selectLegend', 'selectDatapoint'])
const segregated = ref([]);
Expand Down Expand Up @@ -340,6 +340,10 @@ function toggleFullscreen(state) {
step.value += 1;
}
function selectDatapoint(datapoint, index) {
emit('selectDatapoint', { datapoint, index })
}
defineExpose({
getData,
generatePdf,
Expand Down Expand Up @@ -491,7 +495,7 @@ defineExpose({
show: true
})"
@mouseleave="isTooltip = false; selectedSerie = null"
@click="segregate(i)"
@click="selectDatapoint(arc, i)"
/>

<circle
Expand Down Expand Up @@ -560,6 +564,7 @@ defineExpose({
:font-size="donutConfig.style.chart.layout.labels.percentage.fontSize * 0.8"
font-family="Arial"
:class="!defaultConfig.useBlurOnHover || [null, undefined].includes(selectedSerie) || selectedSerie === i ? '' : 'vue-ui-donut-blur'"
@click="selectDatapoint(arc, i)"
>
</text>
Expand All @@ -572,6 +577,7 @@ defineExpose({
:fill="donutConfig.style.chart.layout.labels.percentage.color"
:font-size="donutConfig.style.chart.layout.labels.percentage.fontSize"
:style="`font-weight:${donutConfig.style.chart.layout.labels.percentage.bold ? 'bold': ''}`"
@click="selectDatapoint(arc, i)"
>
{{ 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})})` : '' }}
</text>
Expand All @@ -584,6 +590,7 @@ defineExpose({
:fill="donutConfig.style.chart.layout.labels.name.color"
:font-size="donutConfig.style.chart.layout.labels.name.fontSize"
:style="`font-weight:${donutConfig.style.chart.layout.labels.name.bold ? 'bold': ''}`"
@click="selectDatapoint(arc, i)"
>
{{ arc.name}}
</text>
Expand Down

0 comments on commit 2698fde

Please sign in to comment.