Skip to content

Commit 355e480

Browse files
committed
resolve legend key property interference
1 parent cbe2196 commit 355e480

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/core/guide/CoreGuide.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ const binds = computed(() => {
3333
let result = { scales: scales.map(([s]) => s) }
3434
if (type == "legendkey") {
3535
result.appearances = {
36-
text: obj_merge(...scales.flatMap(([s, a]) => [a.text, a.markdown])),
36+
tile: obj_merge(...scales.flatMap(([s, a]) => [a.rect, a.tile, a.polygon, a.ellipse])),
3737
line: obj_merge(...scales.flatMap(([s, a]) => [a.line, a.linerange, a.curve])),
3838
point: obj_merge(...scales.flatMap(([s, a]) => [a.point])),
39-
tile: obj_merge(...scales.flatMap(([s, a]) => [a.rect, a.tile, a.polygon, a.ellipse])),
39+
text: obj_merge(...scales.flatMap(([s, a]) => [a.text, a.markdown])),
4040
}
4141
} else if (type == "gradientbar") {
4242
let max = scales.map(([s]) => s.limits?.max).filter(v => v != null).reduce((a, b) => Math.min(a, b), Infinity)

src/core/guide/CoreGuideLegendkey.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,24 @@ const guide_breaks = computed(() => {
1616
}))
1717
let binds = categorize(keys.map(v => v.bind))
1818
let group = Map.groupBy(keys.map(v => v.label), (v, i) => binds.categories[binds[i]])
19-
return Array.from(group).map(([bind, labels]) => ({
20-
bind, label: labels.join('; ')
21-
}))
19+
20+
return Array.from(group).map(([$bind, labels]) => {
21+
let bind = { tile: {}, line: {}, point: {}, text: {} }
22+
for (let geom in bind) {
23+
for (let prop of Object.keys(element[geom].props)) {
24+
if ($bind[prop]) bind[geom][prop] = $bind[prop]
25+
}
26+
}
27+
return { bind, label: labels.join('; ') }
28+
})
2229
})
2330
const geoms = computed(() => {
2431
let { text, line, point, tile } = appearances
2532
let result = {}
26-
if (text != null) result.text = { size: 4, text: 'a', ...text }
33+
if (tile != null) result.tile = { width: 10, height: 10, fill: 'transparent', ...tile }
2734
if (line != null) result.line = { x1: -5, x2: 5, color: 'black', ...line }
2835
if (point != null) result.point = { size: 6, ...point }
29-
if (tile != null) result.tile = { width: 10, height: 10, fill: 'transparent', ...tile }
36+
if (text != null) result.text = { size: 4, text: 'a', ...text }
3037
return result
3138
})
3239
const width = ref(0)
@@ -42,7 +49,7 @@ watch(guide_breaks, async () => {
4249
<svg :height="guide_breaks.length * 20" :width="width" ref="svg">
4350
<g v-for="v, i in guide_breaks" :transform="`translate(0, ${i * 20})`">
4451
<g :transform="`translate(10, 10)`">
45-
<component :is="element[geom]" v-for="bind, geom in geoms" v-bind="{ ...bind, ...v.bind }" />
52+
<component :is="element[geom]" v-for="bind, geom in geoms" v-bind="{ ...bind, ...v.bind[geom] }" />
4653
</g>
4754
<text x="20" y="10" alignment-baseline="central">{{ v.label }}</text>
4855
</g>

0 commit comments

Comments
 (0)