Skip to content

Commit d814093

Browse files
committed
Improvement - VueUiNestedDonuts - Improve gradient rendering
1 parent f2ac0d9 commit d814093

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

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

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,16 @@ function segregateDonut(item) {
382382
}
383383
}
384384
385+
const donutThickness = computed(() => {
386+
return donutSize.value / immutableDataset.value.length * FINAL_CONFIG.value.style.chart.layout.donut.spacingRatio
387+
})
388+
389+
const radii = computed(() => {
390+
return mutableDataset.value.map((ds, i) => {
391+
return donutSize.value - (i * donutSize.value / immutableDataset.value.length);
392+
})
393+
})
394+
385395
const donuts = computed(() => {
386396
return mutableDataset.value.map((ds, i) => {
387397
const sizeRatio = i * donutSize.value / immutableDataset.value.length;
@@ -399,7 +409,7 @@ const donuts = computed(() => {
399409
1,
400410
360,
401411
105.25,
402-
donutSize.value / immutableDataset.value.length * FINAL_CONFIG.value.style.chart.layout.donut.spacingRatio
412+
donutThickness.value
403413
)
404414
}
405415
})
@@ -786,9 +796,10 @@ defineExpose({
786796
<svg :xmlns="XMLNS" v-if="isDataset" :class="{ 'vue-data-ui-fullscreen--on': isFullscreen, 'vue-data-ui-fulscreen--off': !isFullscreen }" :viewBox="`0 0 ${svg.width <= 0 ? 0.001 : svg.width} ${svg.height < 0 ? 0.001 : svg.height}`" :style="`max-width:100%; overflow: visible; background:${FINAL_CONFIG.style.chart.backgroundColor};color:${FINAL_CONFIG.style.chart.color}`">
787797
<!-- GRADIENTS -->
788798
<defs>
789-
<radialGradient v-for="(_, i) in gradientSets" :id="`radial_${uid}_${i}`" cx="50%" cy="50%" r="50%" :fr="30 - (1 * (i+1)) + '%'">
799+
<radialGradient v-for="(_, i) in gradientSets" :id="`radial_${uid}_${i}`">
790800
<stop offset="0%" stop-color="#FFFFFF" stop-opacity="0"/>
791-
<stop :offset="70 - (20 * i) + '%'" stop-color="#FFFFFF" :stop-opacity="FINAL_CONFIG.style.chart.gradientIntensity / 100"/>
801+
<stop :offset="`${ (1 - (donutThickness / (radii[i]))) * 100}%`" :stop-color="setOpacity('#FFFFFF', 0)" stop-opacity="0" />
802+
<stop :offset="`${ (1 - (donutThickness / (radii[i]) / 2)) * 100}%`" stop-color="#FFFFFF" :stop-opacity="FINAL_CONFIG.style.chart.gradientIntensity / 100"/>
792803
<stop offset="100%" stop-color="#FFFFFF" stop-opacity="0"/>
793804
</radialGradient>
794805
</defs>
@@ -804,16 +815,6 @@ defineExpose({
804815
<feDropShadow dx="0" dy="0" stdDeviation="10" flood-opacity="0.5" :flood-color="FINAL_CONFIG.style.chart.layout.donut.shadowColor" />
805816
</filter>
806817
</defs>
807-
808-
<!-- UNDERLAYER CIRCLES -->
809-
<circle
810-
v-for="c in donuts"
811-
:cx="svg.width / 2"
812-
:cy="svg.height / 2"
813-
:r="c.radius < 0 ? 0.00001 : c.radius "
814-
:fill="FINAL_CONFIG.style.chart.backgroundColor"
815-
:filter="FINAL_CONFIG.style.chart.layout.donut.useShadow ? `url(#shadow_${uid})`: ''"
816-
/>
817818
818819
<!-- NESTED DONUTS -->
819820
<g v-for="(item, i) in donuts">

0 commit comments

Comments
 (0)