Skip to content

Commit 408f536

Browse files
committed
Improvement - VueUiRidgeline - Add config option to disable gradients; improve pattern slots
1 parent d5f7e61 commit 408f536

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

TestingArena/ArenaVueUiRidgeline.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const model = ref([
101101
{ key: 'style.chart.areas.smooth', def: true, type: 'checkbox'},
102102
{ key: 'style.chart.areas.opacity', def: 0.9, min: 0.1, max: 1, step: 0.01, type: 'number'},
103103
{ key: 'style.chart.areas.useCommonColor', def: false, type: 'checkbox'},
104+
{ key: 'style.chart.areas.useGradient', def: true, type: 'checkbox'},
104105
105106
{ key: 'style.chart.areas.maxPoint.show', def: true, type: 'checkbox'},
106107
{ key: 'style.chart.areas.maxPoint.adaptStrokeToBackground', def: true, type: 'checkbox'},
@@ -189,7 +190,16 @@ const config = computed(() => {
189190
<template #title>VueUiRidgeline</template>
190191

191192
<template #local>
192-
<LocalVueUiRidgeLine :dataset="dataset" :config="config"/>
193+
<LocalVueUiRidgeLine :dataset="dataset" :config="config">
194+
<!-- <template #pattern="{ seriesIndex, patternId }">
195+
<pattern v-if="seriesIndex === 0" :id="patternId" width="70" height="8" patternTransform="scale(2)"
196+
patternUnits="userSpaceOnUse" opacity="0.5">
197+
<rect width="100%" height="100%" fill="#FFFFFF20" />
198+
<path fill="none" stroke="#ecc94b"
199+
d="M-.02 22c8.373 0 11.938-4.695 16.32-9.662C20.785 7.258 25.728 2 35 2s14.215 5.258 18.7 10.338C58.082 17.305 61.647 22 70.02 22M-.02 14.002C8.353 14 11.918 9.306 16.3 4.339 20.785-.742 25.728-6 35-6S49.215-.742 53.7 4.339c4.382 4.967 7.947 9.661 16.32 9.664M70 6.004c-8.373-.001-11.918-4.698-16.3-9.665C49.215-8.742 44.272-14 35-14S20.785-8.742 16.3-3.661C11.918 1.306 8.353 6-.02 6.002" />
200+
</pattern>
201+
</template> -->
202+
</LocalVueUiRidgeLine>
193203
</template>
194204

195205
<template #VDUI-local>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,4 @@
110110
"vitest": "^3.1.1",
111111
"vue": "^3.5.14"
112112
}
113-
}
113+
}

src/components/vue-ui-ridgeline.vue

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -715,25 +715,23 @@ defineExpose({
715715
</template>
716716
</defs>
717717

718-
719-
<g v-if="$slots.pattern">
720-
<defs v-for="(variable, i) in legendSet">
721-
<slot name="pattern" v-bind="{ variable, patternId: `pattern_${uid}_${i}` }" />
722-
</defs>
723-
</g>
724-
725718
<g v-for="(ds, i) in drawableDataset" :key="`ds-${i}`">
726719
<!-- Paths -->
727720
<g v-for="(dp, j) in ds.datapoints" :key="dp.id">
721+
<g v-if="$slots.pattern">
722+
<defs>
723+
<slot name="pattern" v-bind="{ datapointIndex: i, seriesIndex: j, patternId: `pattern_${uid}_${dp.uid}` }" />
724+
</defs>
725+
</g>
728726
<!-- PATH BACKGROUND -->
729-
<path :fill="FINAL_CONFIG.style.chart.backgroundColor" stroke="none" stroke-linecap="round"
727+
<path :fill="$slots.pattern ? `url(#pattern_${uid}_${dp.uid})` : FINAL_CONFIG.style.chart.backgroundColor" stroke="none" stroke-linecap="round"
730728
:d="FINAL_CONFIG.style.chart.areas.smooth ? dp.smoothPath : dp.straightPath" :style="{
731729
opacity: FINAL_CONFIG.style.chart.areas.opacity,
732730
}" />
733731

734732
<!-- PATH -->
735733
<path
736-
:fill="FINAL_CONFIG.style.chart.areas.useCommonColor ? `url(#gradient-${dp.id}-${uid})` : `url(#gradient-single-${uid}-${dp.uid})`"
734+
:fill="!FINAL_CONFIG.style.chart.areas.useGradient ? dp.color : FINAL_CONFIG.style.chart.areas.useCommonColor ? `url(#gradient-${dp.id}-${uid})` : `url(#gradient-single-${uid}-${dp.uid})`"
737735
:stroke="FINAL_CONFIG.style.chart.areas.stroke.useSerieColor ? dp.color : FINAL_CONFIG.style.chart.areas.stroke.color"
738736
:stroke-width="FINAL_CONFIG.style.chart.areas.strokeWidth"
739737
:d="FINAL_CONFIG.style.chart.areas.smooth ? dp.smoothPath : dp.straightPath"

src/useConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5439,6 +5439,7 @@ export function useConfig() {
54395439
smooth: true, // Also applied in dialog chart
54405440
opacity: 0.9,
54415441
useCommonColor: false,
5442+
useGradient: true,
54425443
maxPoint: {
54435444
show: true,
54445445
adaptStrokeToBackground: true,

types/vue-data-ui.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6843,6 +6843,7 @@ declare module "vue-data-ui" {
68436843
rowHeight?: number;
68446844
strokeWidth?: number;
68456845
useCommonColor?: boolean;
6846+
useGradient?: boolean;
68466847
stroke?: {
68476848
useSerieColor?: boolean;
68486849
color?: string;

0 commit comments

Comments
 (0)