index.vue
5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<template>
<div style="display: flex">
<n-grid :x-gap="12" :y-gap="12" :cols="4" layout-shift-disabled>
<n-gi>
<div :style="{ marginLeft: headLeftInfo.ml + 'px', marginTop: headLeftInfo.mt + 'px' }">
<svg :width="headLeftInfo.w + 'px'" :height="headLeftInfo.h + 'px'">
<polyline
:stroke="colorLefts[0]"
stroke-width="2"
fill="transparent"
:points="`${xLeftPos(0)}, 0 ${xLeftPos(30)}, ${headLeftInfo.h / 2}`"
/>
<polyline
:stroke="colorLefts[0]"
stroke-width="2"
fill="transparent"
:points="`${xLeftPos(20)}, 0 ${xLeftPos(50)}, ${headLeftInfo.h / 2} ${xLeftPos(headLeftInfo.w)}, ${
headLeftInfo.h / 2
}`"
/>
<polyline
:stroke="colorLefts[1]"
fill="transparent"
stroke-width="3"
:points="`${xLeftPos(0)}, ${headLeftInfo.h - 3}, ${xLeftPos(200)}, ${headLeftInfo.h - 3}`"
/>
</svg>
</div>
</n-gi>
<n-gi>
<div :style="{ top: headCenterInfo.mt + 'px', left: headCenterInfo.ml + 'px' }" class="go-border-06">
<svg xmlns="http://www.w3.org/2000/svg" :width="headCenterInfo.w" :height="headCenterInfo.h">
<polygon class="stroke fill" :points="`15.5 6.5 20.5 0.5 50.5 0.5 55.5 6.5 15.5 6.5`" />
<polygon
class="stroke fill"
:points="`15.5 ${headCenterInfo.h - 6.5} 20.5 ${headCenterInfo.h - 0.5} 50.5 ${
headCenterInfo.h - 0.5
} 55.5 ${headCenterInfo.h - 6.5} 15.5 ${headCenterInfo.h - 6.5}`"
/>
<polygon
class="stroke fill"
:points="`${headCenterInfo.w - 15.5} 6.5 ${headCenterInfo.w - 20.5} 0.5 ${headCenterInfo.w - 50.5} 0.5 ${
headCenterInfo.w - 55.5
} 6.5 ${headCenterInfo.w - 15.5} 6.5`"
/>
<polygon
class="stroke fill"
:points="`${headCenterInfo.w - 15.5} ${headCenterInfo.h - 6.5} ${headCenterInfo.w - 20.5} ${
headCenterInfo.h - 0.5
} ${headCenterInfo.w - 50.5} ${headCenterInfo.h - 0.5} ${headCenterInfo.w - 55.5} ${
headCenterInfo.h - 6.5
} ${headCenterInfo.w - 15.5} ${headCenterInfo.h - 6.5}`"
/>
<polygon
class="stroke fill"
:points="`15.5 6.5 0.5 ${headCenterInfo.h / 2} 15.5 ${headCenterInfo.h - 6.5} ${
headCenterInfo.w - 15.5
} ${headCenterInfo.h - 6.5} ${headCenterInfo.w - 0.5} ${headCenterInfo.h / 2} ${
headCenterInfo.w - 15.5
} 6.5 15.5 6.5`"
/>
<polyline
class="stroke fill-none"
:points="`20.5 14.5 8.5 ${headCenterInfo.h / 2} 20.5 ${headCenterInfo.h - 14.5}`"
/>
<polyline
class="stroke fill-none"
:points="`${headCenterInfo.w - 20.5} 14.5 ${headCenterInfo.w - 8.5} ${headCenterInfo.h / 2} ${
headCenterInfo.w - 20.5
} ${headCenterInfo.h - 14.5}`"
/>
</svg>
<span class="text">{{ headCenterInfo.dataset }}</span>
</div>
</n-gi>
<n-gi>
<div :style="{ marginLeft: headRightInfo.ml + 'px', marginTop: headRightInfo.mt + 'px' }">
<svg :width="headRightInfo.w" :height="headRightInfo.h">
<polyline
:stroke="colorRights[0]"
stroke-width="2"
fill="transparent"
:points="`${xRightPos(0)}, 0 ${xRightPos(30)}, ${headRightInfo.h / 2}`"
/>
<polyline
:stroke="colorRights[0]"
stroke-width="2"
fill="transparent"
:points="`${xRightPos(20)}, 0 ${xRightPos(50)}, ${headRightInfo.h / 2} ${xRightPos(headRightInfo.w)}, ${
headRightInfo.h / 2
}`"
/>
<polyline
:stroke="colorRights[1]"
fill="transparent"
stroke-width="3"
:points="`${xRightPos(0)}, ${headRightInfo.h - 3}, ${xRightPos(200)}, ${headRightInfo.h - 3}`"
/>
</svg>
</div>
</n-gi>
</n-grid>
</div>
</template>
<script setup lang="ts">
import { PropType, toRefs } from 'vue'
import { CreateComponentType } from '@/packages/index.d'
const props = defineProps({
chartConfig: {
type: Object as PropType<CreateComponentType>,
required: true
}
})
//默认设置宽高距离位置
props.chartConfig.attr.w = 1920
props.chartConfig.attr.h = 300
props.chartConfig.attr.x = 0
props.chartConfig.attr.y = 0
const { headLeftInfo, headCenterInfo, headRightInfo, colorLefts, colorRights, colorTexts } = toRefs(
props.chartConfig.option
)
const xLeftPos = (pos: number) => {
if (!headLeftInfo.value.headLeftReverse) return pos
return headLeftInfo.value.w - pos
}
const xRightPos = (pos: number) => {
if (!headRightInfo.value.headRightReverse) return pos
return headRightInfo.value.w - pos
}
</script>
<style lang="scss" scoped>
@include go('border-06') {
position: relative;
display: flex;
justify-content: center;
align-items: center;
svg {
position: absolute;
z-index: -1;
}
.fill {
fill: v-bind('colorTexts[0]');
}
.fill-none {
fill: none;
}
.stroke {
stroke: v-bind('colorTexts[1]');
}
.text {
color: v-bind('headCenterInfo.textColor');
font-size: v-bind('headCenterInfo.textSize+"px"');
}
}
</style>