echarts柱状图随机色设置方法
柱状的颜色,写在series[{里;
series : [ { name: '功夫码柱状图', type: 'bar', itemStyle: { normal: { color: function (params) { //定制显示(按顺序,可避免clolrList索引超出) var colorList = ['#dc3545', '#ffc107', '#007bff', '#28a745', '#20c997', '#e83e8c', '#17a2b8', '#92d1ea']; var index = params.dataIndex > (colorList.length - 1) ? params.dataIndex - colorList.length : params.dataIndex; return colorList[index]; //随机显示 //return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16); }, } }, barWidth: '30',//柱子宽度 data:[100,99,77,55,33],// 数据 } ]
本文来源:功夫码(gongfuma.com)
声明:本文系功夫码原创稿件,版权属[功夫码 gongfuma.com]所有。
未经授权不得转载,已经协议授权的媒体下载使用时须注明"稿件来源:功夫码",违者将依法追究责任。