index.vue
2.65 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
<template>
<div class="go-animat">
<div class="go-svg" :style="{ marginLeft: animat.x + 'px', marginTop: animat.y + 'px' }">
<svg :width="w" :height="h">
<polyline
fill="transparent"
stroke-width="3"
:points="`0,${h / 5} ${w / 5.555555555555556},${h / 5} ${w / 5},${h / 2.5} ${w / 4},${h / 2.5} ${
w / 3.703703703703704
},${h / 1.666666666666667} ${w / 1.388888888888889},${h / 1.666666666666667} ${w / 1.333333333333333},${
h / 2.5
} ${w / 1.25},${h / 2.5} ${w / 1.219512195121951},${h / 5} ${w},${h / 5}`"
:stroke="animat.colors[0]"
>
<animate
attributeName="stroke-dasharray"
attributeType="XML"
:from="`0, 969.031002232793, 0, 969.031002232793`"
:to="`0, 0, 1938.062004465586, 0`"
dur="3s"
begin="0s"
calcMode="spline"
keyTimes="0;1"
keySplines="0.4,1,0.49,0.98"
repeatCount="indefinite"
></animate>
</polyline>
<polyline
fill="transparent"
stroke-width="2"
:points="`${w / 3.333333333333333},${h / 1.25} ${w / 1.428571428571429},${h / 1.25}`"
:stroke="animat.colors[1]"
>
<animate
attributeName="stroke-dasharray"
attributeType="XML"
from="0, 384, 0, 384"
to="0, 0, 768, 0"
dur="3s"
begin="0s"
calcMode="spline"
keyTimes="0;1"
keySplines=".4,1,.49,.98"
repeatCount="indefinite"
></animate>
</polyline>
</svg>
</div>
<div class="go-text" :style="{ top: animat.textPos.y + '%', left: animat.textPos.x + '%' }">
<n-gradient-text :size="animat.size" :gradient="animat.gradient">
{{ dataset }}
</n-gradient-text>
</div>
</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=180
const { w, h } = toRefs(props.chartConfig.attr)
const { animat, dataset } = toRefs(props.chartConfig.option)
</script>
<style lang="scss" scoped>
.go-animat {
width: v-bind('w+"px"');
height: v-bind('h+"px"');
display: flex;
justify-content: center;
align-items: center;
position: relative;
.go-svg {
}
.go-text {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
}
</style>