Skip to content

Commit 6d4e813

Browse files
Alec ProbertAlec Probert
authored andcommitted
VueUiNestedDonuts added display donut name option
1 parent 38a323a commit 6d4e813

File tree

6 files changed

+40
-10
lines changed

6 files changed

+40
-10
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-data-ui",
33
"private": false,
4-
"version": "2.0.27",
4+
"version": "2.0.28",
55
"type": "module",
66
"description": "A user-empowering data visualization Vue components library",
77
"keywords": [

src/App.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,11 +2616,14 @@ function selectHistoDatapoint({ datapoint, index }) {
26162616
const nestedDonutsConfig = ref({
26172617
style: {
26182618
chart: {
2619-
backgroundColor: '#1A1A1A',
2620-
tooltip: {
2621-
customFormat: ({ datapoint, seriesIndex, series, config }) => {
2622-
console.log({ datapoint, seriesIndex, series, config })
2623-
return 'TEST'
2619+
layout: {
2620+
labels: {
2621+
dataLabels: {
2622+
showDonutName: true,
2623+
boldDonutName: true,
2624+
donutNameAbbreviation: false,
2625+
donutNameOffsetY: 0
2626+
}
26242627
}
26252628
}
26262629
}

src/components/vue-ui-nested-donuts.vue

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ function useTooltip({ datapoint, _relativeIndex, seriesIndex }){
245245
}
246246
}
247247
}
248-
tooltipContent.value = `<div>${html}</div>`;
248+
tooltipContent.value = `<div style="font-size:${donutConfig.value.style.chart.tooltip.fontSize}px">${html}</div>`;
249249
}
250250
isTooltip.value = true;
251251
}
@@ -516,6 +516,23 @@ defineExpose({
516516
</g>
517517
</g>
518518
519+
<g v-if="donutConfig.style.chart.layout.labels.dataLabels.showDonutName">
520+
<g v-for="(item, i) in mutableDataset">
521+
<g v-for="(arc, j) in item.donut">
522+
<text
523+
v-if="j === 0"
524+
:x="svg.width / 2"
525+
:y="arc.startY - donutConfig.style.chart.layout.labels.dataLabels.fontSize + donutConfig.style.chart.layout.labels.dataLabels.donutNameOffsetY"
526+
text-anchor="middle"
527+
:font-size="donutConfig.style.chart.layout.labels.dataLabels.fontSize"
528+
:font-weight="donutConfig.style.chart.layout.labels.dataLabels.boldDonutName ? 'bold': 'normal'"
529+
>
530+
{{ donutConfig.style.chart.layout.labels.dataLabels.donutNameAbbreviation ? abbreviate({ source: item.name, length: donutConfig.style.chart.layout.labels.dataLabels.donutNameMaxAbbreviationSize }) : item.name }}
531+
</text>
532+
</g>
533+
</g>
534+
</g>
535+
519536
<!-- DATALABELS -->
520537
<g v-if="donutConfig.style.chart.layout.labels.dataLabels.show">
521538
<g v-for="(item, i) in mutableDataset">

src/default_configs.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,12 @@
510510
"boldValue": false,
511511
"boldPercentage": true,
512512
"roundingValue": 0,
513-
"roundingPercentage": 0
513+
"roundingPercentage": 0,
514+
"showDonutName": true,
515+
"boldDonutName": true,
516+
"donutNameAbbreviation": true,
517+
"donutNameMaxAbbreviationSize": 3,
518+
"donutNameOffsetY": 0
514519
}
515520
},
516521
"donut": {

types/vue-data-ui.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2336,6 +2336,11 @@ declare module 'vue-data-ui' {
23362336
showValue?: boolean;
23372337
suffix?: string;
23382338
useSerieColor?: boolean;
2339+
showDonutName?: boolean;
2340+
boldDonutName?: boolean;
2341+
donutNameAbbreviation?: boolean;
2342+
donutNameOffsetY?: number;
2343+
donutNameMaxAbbreviationSize?: number;
23392344
};
23402345
};
23412346
donut?: {

0 commit comments

Comments
 (0)