perf: 优化仪表盘资产类型占比

This commit is contained in:
“huailei000” 2023-02-09 19:58:19 +08:00 committed by huailei
parent 4409c3e1d3
commit 8ecd2cfc6a

View File

@ -42,23 +42,26 @@ export default {
options() {
const seriesList = []
const labels = this.data.map(item => item.label)
for (let i = 0; i < this.data.length; i++) {
const total = _.sumBy(this.data, function(i) { return i.total })
for (let i = 0, len = this.data.length; i < len; i++) {
const current = this.data[i]
const num = (current.total / total) * 100
const color = '#' + Math.floor(Math.random() * (256 * 256 * 256 - 1)).toString(16)
seriesList.push({
type: 'bar',
stack: 'total',
barWidth: 32,
name: current.label,
itemStyle: {
borderRadius: 0
},
data: [{
value: current.total,
itemStyle: {
color: this.colors[i]
borderRadius: 0,
color: () => {
return this.colors[i] || color
}
}],
color: this.colors[i]
},
data: [num],
color: () => {
return this.colors[i] || color
}
})
}
return {
@ -69,8 +72,9 @@ export default {
itemHeight: 10,
textStyle: {
color: '#000',
lineHeight: 30
lineHeight: 10
},
bottom: 30,
data: labels
},
@ -126,11 +130,11 @@ export default {
}
},
grid: {
top: '0%',
top: '60%',
containLabel: true,
bottom: '-50%',
bottom: '0',
left: '0%',
right: '0%'
right: 1
},
series: seriesList,
xAxis: {