监管权限

master
lion 7 months ago
parent 40e3d4bcd3
commit 94d7581923

@ -51,39 +51,47 @@ export default {
itemWidth: 8, itemWidth: 8,
itemHeight: 5 itemHeight: 5
}, },
color: ['#446df6', '#f2a93f', '#56b7f9'], color: ['#f2a93f', '#446df6', '#56b7f9'],
series: [ series: [
{ {
type: 'pie', type: 'pie',
radius: ['50%', '70%'], radius: ['50%', '70%'],
center: ['50%', '36%'], center: ['50%', '36%'],
padAngle: 4, selectedMode: 'single',
padAngle: 0,
selectedOffset: 0,
hoverOffset: 0,
itemStyle: { itemStyle: {
borderRadius: 10, borderRadius: 0,
padding: 10 borderWidth: 0,
borderColor: 'transparent'
}, },
label: { label: {
show: true, show: false
position: 'center',
formatter: `{b}\n{d}%`
}, },
avoidLabelOverlap: true, // avoidLabelOverlap: true, //
emphasis: { // emphasis: { //
scale: true // item scale: true, // item
label: {
show: true,
position: 'center',
formatter: `{b}\n{d}%`
}
}, },
labelLine: { labelLine: {
show: false show: false
}, },
data: (() => { data: this.chartData.map((item, index) => ({ ...item, selected: index === 0 }))
if (this.percent || this.percent === 0) { // (() => {
return [ // if (this.percent || this.percent === 0) {
{ value: parseFloat(this.percent), name: `${this.title}` }, // return [
{ value: 100 - parseFloat(this.percent), name: `${this.title}` } // { value: parseFloat(this.percent), name: `${this.title}` },
] // { value: 100 - parseFloat(this.percent), name: `${this.title}` }
} else { // ]
return this.chartData // } else {
} // return this.chartData
})() // }
// })()
} }
], ],
graphic: { graphic: {
@ -109,6 +117,88 @@ export default {
}, },
setOptions() { setOptions() {
this.chart?.setOption(this.options) this.chart?.setOption(this.options)
if (this.chart && Array.isArray(this.chartData) && this.chartData.length > 0) {
try {
this.chart.dispatchAction({ type: 'downplay', seriesIndex: 0 })
this.chart.dispatchAction({ type: 'highlight', seriesIndex: 0, dataIndex: 0 })
} catch (e) {
// ignore
}
// persistent center label via graphic
const data = this.chartData
const total = data.reduce((s, it) => s + Number(it.value || 0), 0)
const first = data[0]
const percent = total > 0 ? Math.round((Number(first.value || 0) / total) * 10000) / 100 : 0
this.chart.setOption({
graphic: {
elements: [
{
type: 'text',
left: 'center',
top: '36%',
style: {
text: `${first.name}\n${percent}%`,
textAlign: 'center',
fill: '#333',
fontSize: 14,
fontWeight: 500
},
z: 100
}
]
}
})
// update on hover and restore on mouse out
this.chart.off('mouseover')
this.chart.off('globalout')
this.chart.on('mouseover', { seriesIndex: 0 }, (params) => {
if (!params || typeof params.dataIndex === 'undefined') return
const item = data[params.dataIndex]
const p = total > 0 ? Math.round((Number(item.value || 0) / total) * 10000) / 100 : 0
this.chart.setOption({
graphic: {
elements: [
{
type: 'text',
left: 'center',
top: '36%',
style: {
text: `${item.name}\n${p}%`,
textAlign: 'center',
fill: '#333',
fontSize: 14,
fontWeight: 500
},
z: 100
}
]
}
})
})
this.chart.on('globalout', () => {
this.chart.setOption({
graphic: {
elements: [
{
type: 'text',
left: 'center',
top: '36%',
style: {
text: `${first.name}\n${percent}%`,
textAlign: 'center',
fill: '#333',
fontSize: 14,
fontWeight: 500
},
z: 100
}
]
}
})
})
}
// this.setGraphics() // this.setGraphics()
}, },
setGraphics() { setGraphics() {

@ -50,7 +50,7 @@
width="145px" width="145px"
height="145px" height="145px"
title="执行率" title="执行率"
:chart-data="[{value:progress.money_total_2 ? progress.money_total_2 : progress.money_total_1,name:'合计金额'},{value:progress.use_money_total,name:'已用金额'}]" :chart-data="[{value:progress.use_money_total,name:'已用金额'},{value:progress.money_total_2 ? progress.money_total_2 - progress.use_money_total: progress.money_total_1-progress.use_money_total,name:'未执行金额'}]"
/> />
</div> </div>
</div> </div>

Loading…
Cancel
Save