大屏 环形图组件
This commit is contained in:
127
project/dvui/layout/AiDvSummary/components/Summary8.vue
Normal file
127
project/dvui/layout/AiDvSummary/components/Summary8.vue
Normal file
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div class="Summary8">
|
||||
<div class="summary5-item" v-for="(item, index) in arr" :key="index">
|
||||
<div class="left">
|
||||
<DonutChart :ratio="item.ratio"></DonutChart>
|
||||
</div>
|
||||
<div class="right">
|
||||
<h2>{{ item[keys] }}</h2>
|
||||
<p>{{ item[value] }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DonutChart from './DonutChart'
|
||||
export default {
|
||||
name: 'Summary8',
|
||||
|
||||
components: {
|
||||
DonutChart
|
||||
},
|
||||
|
||||
props: {
|
||||
data: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
|
||||
keys: {
|
||||
type: String,
|
||||
default: 'key'
|
||||
},
|
||||
|
||||
value: {
|
||||
type: String,
|
||||
default: 'value'
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
data: {
|
||||
handler (v) {
|
||||
if (!v.length) return []
|
||||
|
||||
let sum = 0
|
||||
v.forEach(x => {
|
||||
sum = x[this.value] + sum
|
||||
})
|
||||
|
||||
this.arr = v.map(v => {
|
||||
console.log(v[this.value] / sum)
|
||||
return {
|
||||
...v,
|
||||
ratio: Number((v[this.value] / sum).toFixed(2)) * 100
|
||||
}
|
||||
})
|
||||
|
||||
console.log(this.arr)
|
||||
},
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
|
||||
data () {
|
||||
return {
|
||||
arr: []
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.Summary8 {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
div {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.summary5-item {
|
||||
display: flex;
|
||||
position: relative;
|
||||
align-items: center;
|
||||
|
||||
.right {
|
||||
min-width: 90px;
|
||||
}
|
||||
|
||||
.left {
|
||||
display: flex;
|
||||
position: relative;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 20px;
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin-bottom: 12px;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 26px;
|
||||
font-weight: bold;
|
||||
color: #CEE1FF;
|
||||
text-shadow: 0px 2px 4px rgba(117, 9, 9, 0.1);
|
||||
background: linear-gradient(180deg, #FFF6C7 0%, #FF9A02 100%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user