option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
data: [
120,
200,
150,
80,
70,
110,
130
],
// 随机颜色
// itemStyle: {
// normal: {
// color:function(){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);}
// },
// },
// 指定颜色
itemStyle: {
normal: {
color: function(params) {
var colorarrays = ['#0769CB', '#00ABBD', '#ffd886', "#9F2E61", "#4D670C",'#0769CB', '#00ABBD'];
return colorarrays[params.dataIndex];
}
}
},
type: 'bar'
}
]
};
echerts添加饼状图随机颜色
最新推荐文章于 2024-05-07 20:04:35 发布