要修改每个类别的显示颜色,需要给每个数据项配置 具体方法为:在series里面给data数组的每个元素设置itemSytle就可以了
var myTestCharts = echarts.init(document.getElementById('myTest'));option如下:
myOption = { title : { text: '场馆内各类人数量' }, tooltip : { trigger: 'axis' }, xAxis : [ { type : 'value', axisLabel : { formatter: '{value} 人' } } ], yAxis : [ { type : 'category', data : ['男人','女人','老人','小孩'] } ], series : [ { type:'bar', data:[ { value:70, itemStyle:{ normal:{color:'blue'} } }, { value:45, itemStyle:{ normal:{color:'purple'} } }, { value:16, itemStyle:{ normal:{color:'yellow'} } }, { value:91, itemStyle:{ normal:{color:'red'} } } ] } ] };将图表显示出来:
myTestCharts.setOption(myOption);效果图: