@@ -7,7 +7,7 @@ const props = defineProps({
77 type: Array ,
88 default () {
99 return []
10- }
10+ }
1111 },
1212 config: {
1313 type: Object ,
@@ -28,58 +28,77 @@ const props = defineProps({
2828const emit = defineEmits ([' clickMarker' ])
2929
3030function handleClick (legend , i ) {
31- emit (' clickMarker' , { legend, i})
31+ emit (' clickMarker' , { legend, i })
3232}
33-
3433 </script >
3534
3635<template >
37- <div
38- :id =" id"
39- :data-cy =" config.cy"
40- class =" vue-data-ui-legend"
41- :style =" `background:${config.backgroundColor};font-size:${config.fontSize}px;color:${config.color};padding-bottom:${config.paddingBottom}px;padding-top:${config.paddingTop || 12}px;font-weight:${config.fontWeight}`"
42- >
43- <slot name =" legendTitle" :titleSet =" legendSet" ></slot >
44- <div v-for =" (legend, i) in legendSet" :key =" `legend_${i}`" :class =" { 'vue-data-ui-legend-item': true, 'active': clickable }" >
45- <svg @click =" handleClick(legend, i)" v-if =" legend.shape" :height =" config.fontSize" :width =" config.fontSize" :viewBox =" legend.shape && legend.shape === 'star' ? '-10 -10 80 80' : '0 0 60 60'" :style =" `overflow: visible;opacity:${legend.opacity}`" >
46- <Shape
47- :shape =" legend.shape"
48- :radius =" 30"
36+ <div :id =" id" :data-cy =" config.cy" class =" vue-data-ui-legend" :style =" {
37+ background: config.backgroundColor,
38+ color: config.color,
39+ paddingBottom: (config.paddingBottom ?? 0) + 'px',
40+ paddingTop: (config.paddingTop ?? 12) + 'px',
41+ fontWeight: config.fontWeight,
42+ fontSize: `var(--legend-font-size, ${(config.fontSize ?? 14)}px)`
43+ }" >
44+ <slot name =" legendTitle" :titleSet =" legendSet" />
45+ <div v-for =" (legend, i) in legendSet" :key =" `legend_${i}`"
46+ :class =" { 'vue-data-ui-legend-item': true, 'active': clickable }" >
47+ <svg
48+ v-if =" legend.shape"
49+ @click =" handleClick(legend, i)"
50+ height =" 1em"
51+ width =" 1em"
52+ :viewBox =" legend.shape && legend.shape === 'star' ? '-10 -10 80 80' : '0 0 60 60'"
53+ :style =" `overflow: visible; opacity:${legend.opacity}`"
54+ >
55+ <Shape
4956 stroke =" none"
50- :plot =" { x: 30, y: legend.shape === 'triangle' ? 36 : 30 }"
51- :fill =" legend.color"
57+ :shape =" legend.shape"
58+ :radius =" 30"
59+ :plot =" {
60+ x: 30,
61+ y: legend.shape === 'triangle' ? 36 : 30
62+ }"
63+ :fill =" legend.color"
64+ />
65+ <slot
66+ name =" legend-pattern"
67+ v-bind =" {
68+ legend,
69+ index: isValidUserValue(legend.absoluteIndex) ? legend.absoluteIndex : i
70+ }"
5271 />
53- <slot name =" legend-pattern" v-bind =" { legend, index: isValidUserValue(legend.absoluteIndex) ? legend.absoluteIndex : i}" />
5472 </svg >
55- <slot name =" item" :legend =" legend" :index =" i" />
73+ <slot name =" item" :legend =" legend" :index =" i" />
5674 </div >
57-
5875 </div >
5976</template >
6077
6178<style scoped>
6279.vue-data-ui-legend {
63- user-select :none ;
80+ user-select : none ;
6481 height : fit-content ;
65- width :100% ;
82+ width : 100% ;
6683 display : flex ;
67- align-items :center ;
84+ align-items : center ;
6885 flex-wrap : wrap ;
69- justify-content :center ;
86+ justify-content : center ;
7087 column-gap : 18px ;
7188}
89+
7290.vue-data-ui-legend-item {
7391 user-select : none ;
7492 display : flex ;
75- align-items :center ;
93+ align-items : center ;
7694 gap : 6px ;
7795 height : fit-content ;
7896 text-align : left ;
7997 white-space : nowrap ;
8098 overflow : hidden ;
8199 text-overflow : ellipsis ;
82100}
101+
83102.active {
84103 cursor : pointer ;
85104}
0 commit comments