Skip to content

Commit 5a20ea9

Browse files
committed
VueUiQuadrant improve tooltip, fix legend print css issues
1 parent a4d6f32 commit 5a20ea9

File tree

7 files changed

+273
-225
lines changed

7 files changed

+273
-225
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.15",
4+
"version": "1.9.16",
55
"type": "module",
66
"description": "A user-empowering data visualization Vue components library",
77
"keywords": [

src/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3629,7 +3629,7 @@ function copyConfig(c) {
36293629
<QuadrantTest
36303630
ref="quadranttest"
36313631
:dataset="quadrantDataset"
3632-
:config="{useCssAnimation: false, style: { chart: { title: { text: 'Title', subtitle: { text: 'Subtitle'}}}}}"
3632+
:config="{useCssAnimation: false, style: { chart: { title: { text: 'Title', subtitle: { text: 'Subtitle'}}},layout:{grid:{xAxis:{name:'xAxis'},yAxis:{name:'yAxis'}}}}}"
36333633
@selectPlot="selectPlot"
36343634
@selectSide="selectSide"
36353635
@selectLegend="selectQuadrantLegend"
@@ -3639,7 +3639,7 @@ function copyConfig(c) {
36393639
<VueUiQuadrant
36403640
ref="quadranttest"
36413641
:dataset="quadrantDataset"
3642-
:config="{useCssAnimation: false, style: { chart: { title: { text: 'Title', subtitle: { text: 'Subtitle'}}}}}"
3642+
:config="{useCssAnimation: false, style: { chart: { title: { text: 'Title', subtitle: { text: 'Subtitle'}}},layout:{grid:{xAxis:{name:'xAxis'},yAxis:{name:'yAxis'}}}}}"
36433643
@selectPlot="selectPlot"
36443644
@selectSide="selectSide"
36453645
@selectLegend="selectQuadrantLegend"

src/atoms/Shape.vue

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<script setup>
2+
import { computed } from "vue";
3+
import { createPolygonPath, createStar } from "../lib";
4+
5+
const props = defineProps({
6+
color: String,
7+
isSelected: {
8+
type: Boolean,
9+
default: false,
10+
},
11+
limit: {
12+
type: Number,
13+
default: 3
14+
},
15+
plot: Object,
16+
radius: Number,
17+
shape: String,
18+
stroke: String,
19+
strokeWidth: Number,
20+
zoom: {
21+
type: Number,
22+
default: 1.3
23+
}
24+
});
25+
26+
const emit = defineEmits(['mouseover', 'mouseout', 'click']);
27+
28+
function getPolygonConfigFromName(name){
29+
return {
30+
circle: {
31+
points: 1,
32+
rotation: 0
33+
},
34+
line: {
35+
points: 2,
36+
rotation: 0
37+
},
38+
triangle: {
39+
points: 3,
40+
rotation: 0.52
41+
},
42+
square: {
43+
points: 4,
44+
rotation: 0.8
45+
},
46+
diamond: {
47+
points: 4,
48+
rotation: 0
49+
},
50+
pentagon: {
51+
points: 5,
52+
rotation: 0.95
53+
},
54+
hexagon: {
55+
points: 6,
56+
rotation: 0
57+
}
58+
}[name]
59+
}
60+
61+
const config = computed(() => {
62+
return getPolygonConfigFromName(props.shape)
63+
});
64+
65+
const starPoints = computed(() => {
66+
if (props.shape !== 'star') return null;
67+
return createStar({
68+
plot: { x: props.plot.x, y: props.plot.y },
69+
radius: props.radius * (props.isSelected ? props.zoom : 1)
70+
})
71+
})
72+
73+
const d = computed(() => {
74+
return createPolygonPath({
75+
plot: { x: props.plot.x, y: props.plot.y },
76+
radius: props.radius * (props.isSelected ? props.zoom : 1),
77+
sides: config.value.points,
78+
rotation: config.value.rotation
79+
}).path;
80+
});
81+
82+
</script>
83+
84+
<template>
85+
<g>
86+
<circle
87+
v-if="config && config.points === 1"
88+
:cx="plot.x"
89+
:cy="plot.y"
90+
:r="props.radius * (props.isSelected ? props.zoom : 1)"
91+
:fill="color"
92+
:stroke="stroke"
93+
:stroke-width="strokeWidth"
94+
@mouseover="emit('mouseover')"
95+
@mouseout="emit('mouseout')"
96+
@click="emit('click')"
97+
/>
98+
<path
99+
v-if="config && config.points >= limit"
100+
:d="d"
101+
:fill="color"
102+
:stroke="stroke"
103+
:stroke-width="strokeWidth"
104+
@mouseover="emit('mouseover')"
105+
@mouseout="emit('mouseout')"
106+
@click="emit('click')"
107+
/>
108+
<polygon
109+
v-if="starPoints"
110+
:points="starPoints"
111+
:fill="color"
112+
:stroke="stroke"
113+
:stroke-width="strokeWidth"
114+
@mouseover="emit('mouseover')"
115+
@mouseout="emit('mouseout')"
116+
@click="emit('click')"
117+
/>
118+
</g>
119+
</template>

src/atoms/Tooltip.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ const position = computed(() => {
4747
class="vue-data-ui-tooltip"
4848
v-if="show"
4949
:style="`top:${position.top}px;left:${position.left}px;background:${props.backgroundColor};color:${props.color};max-width:${props.maxWidth}`"
50-
v-html="content"
51-
/>
50+
>
51+
<slot/>
52+
<div v-html="content"/>
53+
</div>
5254
</template>
5355

5456
<style scoped>

0 commit comments

Comments
 (0)