|
@@ -6,13 +6,8 @@
|
|
|
</span>
|
|
</span>
|
|
|
</template>
|
|
</template>
|
|
|
<span :style="`color:${numberColor};font-size:${numberSize}px`">
|
|
<span :style="`color:${numberColor};font-size:${numberSize}px`">
|
|
|
- <n-number-animation
|
|
|
|
|
- :from="from"
|
|
|
|
|
- :to="to"
|
|
|
|
|
- :duration="dur * 1000"
|
|
|
|
|
- :show-separator="showSeparator"
|
|
|
|
|
- :precision="precision"
|
|
|
|
|
- ></n-number-animation>
|
|
|
|
|
|
|
+ <n-number-animation :from="option.from" :to="option.to" :duration="dur * 1000" :show-separator="showSeparator"
|
|
|
|
|
+ :precision="precision"></n-number-animation>
|
|
|
</span>
|
|
</span>
|
|
|
<template #suffix>
|
|
<template #suffix>
|
|
|
<span :style="`color:${suffixColor};font-size:${numberSize}px`">
|
|
<span :style="`color:${suffixColor};font-size:${numberSize}px`">
|
|
@@ -23,8 +18,10 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { PropType, toRefs } from 'vue'
|
|
|
|
|
|
|
+import { PropType, toRefs, ref, reactive, watch } from 'vue'
|
|
|
import { CreateComponentType } from '@/packages/index.d'
|
|
import { CreateComponentType } from '@/packages/index.d'
|
|
|
|
|
+import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
|
|
|
|
+import { useChartDataFetch } from '@/hooks'
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
chartConfig: {
|
|
chartConfig: {
|
|
@@ -32,21 +29,44 @@ const props = defineProps({
|
|
|
required: true,
|
|
required: true,
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
-
|
|
|
|
|
|
|
+const option = reactive({
|
|
|
|
|
+ from: 0,
|
|
|
|
|
+ to: 0,
|
|
|
|
|
+})
|
|
|
const { w, h } = toRefs(props.chartConfig.attr)
|
|
const { w, h } = toRefs(props.chartConfig.attr)
|
|
|
-const {
|
|
|
|
|
|
|
+let {
|
|
|
dur,
|
|
dur,
|
|
|
showSeparator,
|
|
showSeparator,
|
|
|
prefixText,
|
|
prefixText,
|
|
|
prefixColor,
|
|
prefixColor,
|
|
|
suffixText,
|
|
suffixText,
|
|
|
suffixColor,
|
|
suffixColor,
|
|
|
- from,
|
|
|
|
|
- to,
|
|
|
|
|
precision,
|
|
precision,
|
|
|
numberSize,
|
|
numberSize,
|
|
|
numberColor,
|
|
numberColor,
|
|
|
} = toRefs(props.chartConfig.option)
|
|
} = toRefs(props.chartConfig.option)
|
|
|
|
|
+
|
|
|
|
|
+const updateNumber = (newData: number) => {
|
|
|
|
|
+ // 原来的目标值作为新的数字动画的起始值
|
|
|
|
|
+ option.from = option.to
|
|
|
|
|
+ option.to = newData
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+watch(
|
|
|
|
|
+ () => props.chartConfig.option.from,
|
|
|
|
|
+ () => {
|
|
|
|
|
+ option.from = props.chartConfig.option.from
|
|
|
|
|
+ }, { immediate: true }
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+watch(
|
|
|
|
|
+ () => props.chartConfig.option.to,
|
|
|
|
|
+ () => {
|
|
|
|
|
+ option.to = props.chartConfig.option.to
|
|
|
|
|
+ }, { immediate: true }
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
|
|
+useChartDataFetch(props.chartConfig, useChartEditStore, updateNumber)
|
|
|
</script>
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
@include go('decorates-number') {
|
|
@include go('decorates-number') {
|