Skip to content

Commit 625e0b5

Browse files
committed
VueUiDonutEvolution improve donuts layout
1 parent 0790909 commit 625e0b5

File tree

4 files changed

+40
-22
lines changed

4 files changed

+40
-22
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": "1.9.68",
4+
"version": "1.9.69",
55
"type": "module",
66
"description": "A user-empowering data visualization Vue components library",
77
"keywords": [

src/App.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3898,7 +3898,7 @@ const moodRadarConfig = ref({
38983898
</template>
38993899
</Box>
39003900

3901-
<Box open @copy="copyConfig(PROD_CONFIG.vue_ui_mood_radar)">
3901+
<Box @copy="copyConfig(PROD_CONFIG.vue_ui_mood_radar)">
39023902
<template #title>
39033903
<BaseIcon name="chartMoodRadar"/>
39043904
VueUiMoodRadar
@@ -3981,7 +3981,7 @@ const moodRadarConfig = ref({
39813981
</template>
39823982
</Box>
39833983

3984-
<Box @copy="copyConfig(PROD_CONFIG.vue_ui_donut_evolution)">
3984+
<Box open @copy="copyConfig(PROD_CONFIG.vue_ui_donut_evolution)">
39853985
<template #title>
39863986
<BaseIcon name="chartDonutEvolution"/>
39873987
VueUiDonutEvolution
@@ -4246,7 +4246,7 @@ const moodRadarConfig = ref({
42464246
</template>
42474247
</Box>
42484248

4249-
<Box open @copy="copyConfig(PROD_CONFIG.vue_ui_candlestick)">
4249+
<Box @copy="copyConfig(PROD_CONFIG.vue_ui_candlestick)">
42504250
<template #title>
42514251
<BaseIcon name="chartCandlestick" />
42524252
VueUiCandleStick

src/components/vue-ui-donut-evolution.vue

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ const drawableDataset = computed(() => {
120120
const maxSubtotal = Math.max(...arr.map(a => a.subtotal))
121121
122122
return arr.map((a, i) => {
123-
const radiusReference = (slit.value / 2) * 0.5;
123+
const radiusReference = (slit.value / 2) * 0.7;
124124
const radius = radiusReference > svg.value.width / 16 ? svg.value.width / 16 : radiusReference;
125-
const activeRadius = hoveredIndex.value === a.index ? svg.value.width / 20 : radius;
125+
const activeRadius = hoveredIndex.value === a.index ? svg.value.width / 16 : radius;
126126
const y = svg.value.absoluteHeight - padding.value.bottom - (svg.value.height * a.subtotal / calculateNiceScale(minSubtotal, maxSubtotal, 10).max);
127127
return {
128128
...a,
@@ -136,7 +136,16 @@ const drawableDataset = computed(() => {
136136
value: s.values[i] ?? 0
137137
}
138138
})
139-
}, a.x, y, activeRadius, activeRadius),
139+
}, a.x, y, activeRadius, activeRadius, 1.99999, 2, 1, 360, 105.25, slit.value / 5 > 16 ? 16 : slit.value / 5),
140+
donutHover: makeDonut({
141+
series: mutableDataset.value.map((s, k) => {
142+
return {
143+
color: s.color,
144+
name: s.name,
145+
value: s.values[i] ?? 0
146+
}
147+
})
148+
}, a.x, y, activeRadius, activeRadius, 1.99999, 2, 1, 360, 105.25, 12),
140149
donutFocus: makeDonut({
141150
series: mutableDataset.value.map((s, k) => {
142151
return {
@@ -145,7 +154,7 @@ const drawableDataset = computed(() => {
145154
value: s.values[i] ?? 0
146155
}
147156
})
148-
}, svg.value.centerX, svg.value.centerY, svg.value.height / 5, svg.value.height / 5),
157+
}, svg.value.centerX, svg.value.centerY, svg.value.height / 3.6, svg.value.height / 3.6, 1.99999, 2, 1, 360, 105.25, svg.value.height / 6),
149158
}
150159
})
151160
})
@@ -556,13 +565,22 @@ defineExpose({
556565
:r="3"
557566
:fill="donutEvolutionConfig.style.chart.color"
558567
/>
568+
<g v-else-if="hoveredIndex !== null && hoveredIndex === i">
569+
<path
570+
v-for="(arc, k) in datapoint.donutHover"
571+
:d="arc.arcSlice"
572+
:fill="`${arc.color}`"
573+
:stroke-width="1"
574+
:stroke="donutEvolutionConfig.style.chart.backgroundColor"
575+
/>
576+
</g>
559577
<g v-else>
560578
<path
561579
v-for="(arc, k) in datapoint.donut"
562-
:d="arc.path"
563-
:stroke="`${arc.color}`"
564-
:stroke-width="hoveredIndex === i ? 12 : slit / 5 > 16 ? 16 : slit / 5"
565-
fill="none"
580+
:d="arc.arcSlice"
581+
:fill="`${arc.color}`"
582+
:stroke-width="0.5"
583+
:stroke="donutEvolutionConfig.style.chart.backgroundColor"
566584
/>
567585
</g>
568586
</g>
@@ -571,7 +589,7 @@ defineExpose({
571589
v-if="datapoint.subtotal"
572590
:cx="datapoint.x"
573591
:cy="datapoint.y"
574-
:r="hoveredIndex === datapoint.index ? svg.width / 22 : slit / 6"
592+
:r="hoveredIndex === datapoint.index ? svg.width / 30 : slit / 10"
575593
:fill="donutEvolutionConfig.style.chart.backgroundColor"
576594
/>
577595
</g>
@@ -662,7 +680,7 @@ defineExpose({
662680
663681
<g v-for="arc in fixedDatapoint.donutFocus">
664682
<path
665-
:d="calcNutArrowPath(arc, {x: arc.center.endX, y: arc.center.endY}, 12, 12, { x: svg.width / 2 + padding.left, y: padding.top + svg.height / 2}, true)"
683+
:d="calcNutArrowPath(arc, {x: svg.centerX, y: svg.centerY}, 12, 12, false, false, 1)"
666684
:stroke="arc.color"
667685
stroke-width="1"
668686
stroke-linecap="round"
@@ -678,16 +696,16 @@ defineExpose({
678696
/>
679697
<path
680698
v-for="(arc, k) in fixedDatapoint.donutFocus"
681-
:d="arc.path"
682-
:stroke="`${arc.color}`"
683-
:stroke-width="svg.height / 7"
684-
fill="none"
699+
:d="arc.arcSlice"
700+
:fill="`${arc.color}`"
701+
:stroke-width="1"
702+
:stroke="donutEvolutionConfig.style.chart.backgroundColor"
685703
/>
686704
<g v-for="(arc, i) in fixedDatapoint.donutFocus">
687705
<text
688706
:data-cy="`donut-datalabel-value-${i}`"
689-
:text-anchor="calcMarkerOffsetX(arc, true, 0).anchor"
690-
:x="calcMarkerOffsetX(arc, true, 3).x"
707+
:text-anchor="calcMarkerOffsetX(arc, true, 20).anchor"
708+
:x="calcMarkerOffsetX(arc, true, 10).x"
691709
:y="calcMarkerOffsetY(arc)"
692710
:fill="donutEvolutionConfig.style.chart.layout.grid.yAxis.dataLabels.color"
693711
:font-size="10"

0 commit comments

Comments
 (0)