|
@@ -1,6 +1,7 @@
|
|
|
<template >
|
|
|
<div class="legend-label">
|
|
|
- <LegendItem v-for="(item,index) in reverse ? data.reverse() : data"
|
|
|
+ <LegendItem v-for="(item,index) in realData"
|
|
|
+ :key="index"
|
|
|
:color="item.color || item.itemStyle.color"
|
|
|
:name="item.name"
|
|
|
:percent="item.value / total * 100"
|
|
@@ -53,14 +54,15 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
- return {}
|
|
|
- },
|
|
|
- computed: {
|
|
|
- total() {
|
|
|
- return this.data.reduce((total, item) => total + item.value, 0)
|
|
|
+ this.realData = this.data
|
|
|
+ return {
|
|
|
+ total: 1,
|
|
|
}
|
|
|
},
|
|
|
- methods: {}
|
|
|
+ created() {
|
|
|
+ this.realData = this.reverse ? this.data.reverse() : this.data
|
|
|
+ this.total = this.data.reduce((total, item) => total + item.value, 0)
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|