普通饼图
只是记录一下做项目时遇到的部分设置,真想搞明白,还是看文档
<div class="table" ref="myChartsCapital"></div>
let myChart = this.$echarts.init(this.$refs.myChartsCapital)
myChart.setOption({
title: {
show: true,
text: '饼图主标题',
subtext: '饼图副标题',
itemGap: 6,
left: 'center',
textStyle: {
color: "#fff",
fontStyle: "normal",
fontWeight: "normal",
fontFamily: "sans-serif",
fontSize: 18,
lineHeight: "30",
},
subtextStyle: {}
},
graphic: [
{
type: "text",
left: "center",
top: "center",
style: {
text: "添加文本,还没看能不能设置不同的样式",
textAlign: "center",
fill: "#32373C",
fontSize: 18,
},
},
],
tooltip: {
show:true,
trigger: 'item',
triggerOn:"mousemove",
textStyle: {},
formatter: (value) => {
return value.name + ''
}
},
legend: {
orient: 'vertical',
data: data,
icon: 'circle',
itemGap: 10,
itemWidth: 10,
itemHeight: 10,
left: 'center',
padding: [5, 5, 5, 5],
formatter: (name) => {
let data = this.data;
let value;
let per
for (let i = 0, l = data.length; i < l; i++) {
if (data[i].name == name) {
value = data[i].value;
per = data[i].per
}
}
let arr = [
'{a|' + name + '}',
'{b|' + value + '件}' + '{c|' + per + '%}' + '{d|' + ' ' + '}'
]
return arr.join('\n')
},
textStyle: {
rich: {
a: {
fontFamily: 'PingFang SC',
fontSize: '0.1rem',
fontWeight: 'Bold',
color: '#333',
align: 'left',
padding: [28, 0, 0, 0],
},
b: {
width: 200
},
c: {}
}
},
},
series: [
{
name: '环形图',
type: 'pie',
radius: ['40%', '70%'],
center: ['50%', '50%'],
selectedMode: 'single',
avoidLabelOverlap: false,
data: this.data,
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
label: {
show: false,
position: 'center'
},
labelLine: {
show: false
},
emphasis: {
label: {
show: false,
fontSize: '40',
fontWeight: 'bold'
}
},
},
{...}
]
})
window.addEventListener("resize", function () {
myChart.resize();
});
|