mirror of
https://github.com/jumpserver/lina.git
synced 2025-07-15 07:51:58 +00:00
perf: 优化仪表盘资产类型占比
This commit is contained in:
parent
4409c3e1d3
commit
8ecd2cfc6a
@ -42,23 +42,26 @@ export default {
|
|||||||
options() {
|
options() {
|
||||||
const seriesList = []
|
const seriesList = []
|
||||||
const labels = this.data.map(item => item.label)
|
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 current = this.data[i]
|
||||||
|
const num = (current.total / total) * 100
|
||||||
|
const color = '#' + Math.floor(Math.random() * (256 * 256 * 256 - 1)).toString(16)
|
||||||
seriesList.push({
|
seriesList.push({
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
stack: 'total',
|
stack: 'total',
|
||||||
barWidth: 32,
|
barWidth: 32,
|
||||||
name: current.label,
|
name: current.label,
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
borderRadius: 0
|
borderRadius: 0,
|
||||||
},
|
color: () => {
|
||||||
data: [{
|
return this.colors[i] || color
|
||||||
value: current.total,
|
}
|
||||||
itemStyle: {
|
},
|
||||||
color: this.colors[i]
|
data: [num],
|
||||||
|
color: () => {
|
||||||
|
return this.colors[i] || color
|
||||||
}
|
}
|
||||||
}],
|
|
||||||
color: this.colors[i]
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@ -69,8 +72,9 @@ export default {
|
|||||||
itemHeight: 10,
|
itemHeight: 10,
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: '#000',
|
color: '#000',
|
||||||
lineHeight: 30
|
lineHeight: 10
|
||||||
},
|
},
|
||||||
|
bottom: 30,
|
||||||
data: labels
|
data: labels
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -126,11 +130,11 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
grid: {
|
grid: {
|
||||||
top: '0%',
|
top: '60%',
|
||||||
containLabel: true,
|
containLabel: true,
|
||||||
bottom: '-50%',
|
bottom: '0',
|
||||||
left: '0%',
|
left: '0%',
|
||||||
right: '0%'
|
right: 1
|
||||||
},
|
},
|
||||||
series: seriesList,
|
series: seriesList,
|
||||||
xAxis: {
|
xAxis: {
|
||||||
|
Loading…
Reference in New Issue
Block a user