series: [
{
type: "bar",
barMaxWidth: 25,
data: this.YList.map((item) => {
// 循环
return {
value: item,
label: {
show: true, //开启显示
position: item > 0 ? "top" : "bottom", //判断正负值上方显示还是下方
formatter: "{c}%",//单位
textStyle: {
//数值样式
color: item < 0 ? "#229D45" : "#E93030", //数值颜色
fontSize: "18px",
},
},
};
}),
itemStyle: {//柱体背景色
normal: {
color: (val) => {
var index_color = val.value;
return index_color > 0 ? "#E93030" : "#229D45";
},
},
},
},
],