不同属性的点击事件获取
this.chartsDom.on("click", "属性名(title、graphic等)", (params) => {
params 可以获取到点击事件的具体内容以及参数值
});
graphic设置中心文本
graphic: [
{
type: "text",
left: "center",
top: "51%",
style: {
text: `${get_data.count}`,
textAlign: "center",
fill: "#0A75D7",
width: 30,
height: 30,
fontSize: 22,
fontWeight: 500,
},
},
{
type: "text",
left: "center",
top: "63%",
silent: true,
style: {
text: "存在异常",
textAlign: "center",
fill: "#484848",
fontSize: 17,
fontWeight: 500,
},
},
],
径向颜色
color:{
type: 'radial',
x: 0.5,
y: 0.5,
r: 0.5,
colorStops: [{
offset: 0, color: 'red'
}, {
offset: 1, color: 'blue'
}],
global: false
}
series的鼠标移入变大事件
emphasis: {
scale: true,
label: {
show: false,
fontSize: "20",
fontWeight: "bold",
},
},
饼图高亮设置
this.veryImportantChart.dispatchAction({
type: "highlight",
seriesIndex: 0,
dataIndex: 0,
});
this.veryImportantChart.on("mouseover", (e) => {
if (e.dataIndex == 0) {
return;
} else {
this.veryImportantChart.dispatchAction({
type: "downplay",
seriesIndex: 0,
dataIndex: 0,
});
}
});
this.veryImportantChart.on("mouseout", () => {
this.veryImportantChart.dispatchAction({
type: "highlight",
seriesIndex: 0,
dataIndex: 0,
});
});
圆环图设置(属性单独设置)
let placeHolderStyle = {
label: {
show: false,
position: "center",
},
labelLine: {
show: false,
},
color: "rgba(0,0,0,0)",
borderColor: "rgba(0,0,0,0)",
borderWidth: 0,
};
let seriesData = [];
_getSourceClassData.forEach((item, index) => {
let _totle = (this.objSourceAnomalyClass.dataSourceTotal - item.count) / 10;
seriesData.push({
name: item.name,
type: "pie",
clockwise: true,
emphasis: {
scale: false,
},
minAngle: 13,
radius: [110 - index * 15, 94 - index * 16],
label: {
show: false,
},
labelLine: {
show: false,
},
itemStyle: {
borderColor: "#fff",
borderWidth: 3,
},
startAngle: 80,
data: [
{
value: item.count,
name: item.name,
},
{
value: parseInt(_totle),
name: "信源总量",
itemStyle: placeHolderStyle,
emphasis: {
itemStyle: {
color: "#dedede",
borderColor: "#dedede",
borderWidth: 0,
},
disabled: true,
scale: false
},
tooltip: {
show: false
}
},
],
});
});
let my_option = {
backgroundColor: "#fff",
color: ["#3986FE", "#F57F50", "#F9D237", "#35CACA", "#73E6BF "],
legend: {
top: "13%",
x: "left",
left: "1%",
itemWidth: 0,
itemHeight: 0,
data: labelName,
itemGap: 4,
textStyle: {
color: "black",
align: "right",
x: "right",
textAlign: "right",
},
selectedMode: true,
orient: "vertical",
},
title: {
show: _getSourceClassData.length === 0,
textStyle: {
color: "#ccc",
fontSize: 20,
fontWeight: 600,
},
text: "暂无数据",
left: "center",
top: "center",
},
tooltip: {
trigger: "item",
},
series: seriesData,
};