饼状图颜色修改

This commit is contained in:
hongchao 2025-11-25 16:43:58 +08:00
parent fc978978cf
commit 8735684339
1 changed files with 49 additions and 21 deletions

View File

@ -51,7 +51,7 @@ export default {
},
mounted() {
console.log('🚀 ~ mounted ~ this.state:', this.state)
console.log('state-->', this.pieValues)
console.log('statexxxxxxxxxxxxxxx-->', this.pieValues)
setTimeout(() => {
this.query = this.state
this.initPieChart()
@ -73,27 +73,55 @@ export default {
// console.log('🚀 ~ initPieChart ~ chartDom:', chartDom)
if (!chartDom) return
const myChart = echarts.init(chartDom)
//
const pieColors = ['#69A6C9', '#7DDBBA', '#ffc300']
const option = {
tooltip: {
trigger: 'item',
},
series: [
{
name: '装备年限',
type: 'pie',
radius: '39%',
avoidLabelOverlap: false,
label: {
show: true,
formatter: '{b}\n{d}%',
color: '#A3D6F8',
},
labelLine: {
show: true,
length: 8, // 线
length2: 5, // 线
},
color: pieColors, //
tooltip: {
trigger: 'item',
},
//
// legend: {
// show: false
// },
series: [
{
name: '装备年限',
type: 'pie',
radius: '39%',
avoidLabelOverlap: false,
// ++
label: {
show: true,
// +
formatter: function(params) {
// + +
return `{percent|${params.percent.toFixed(0)}%}\n{name|${params.name}}`;
},
// /
rich: {
percent: {
fontSize: 16, //
fontWeight: 'bold',
color: 'inherit'
},
name: {
fontSize: 12, //
color: '#fff', //
marginTop: 2
}
},
//
position: 'outside'
},
labelLine: {
show: true,
length: 8,
length2: 5,
lineStyle: {
color: '#fff' // 线
}
},
data: this.pieData,
},