关于echarts中柱形条颜色一样的问题
代码如下:
function doFindMonthLevel() {
jQuery.ajax({
url : ctx+"/info/ajaxListSum",
type : "post",
cache : false,
scriptCharset : "utf-8",
async : false,
dataType : "json",
success : function(data) {
require.config({
paths : {
echarts : ctx+'/js/echarts/echarts',
'echarts/chart/bar' : '${ctx}/js/echarts/bar'
}
});
/***/
require([ 'echarts', 'echarts/chart/bar' ], function(ec) {
// --- 折柱 ---
var myChart = ec.init(document
.getElementById('placeholder2'));
myChart.setOption({
tooltip : {
formatter: function (params,ticket,callback) {
return params[0]+"</br>¥"+params[2];
}
},
toolbox : {
show : true,
x : '320',
y : '22',
feature : {
mark : {
show : true
},
magicType : {
show : true,
type : [ 'line', 'bar' ]
},
restore : {
show : true
},
saveAsImage : {
show : true
}
}
},
calculable : true,
xAxis : [ {
type : 'category',
//splitLine: {show:false},
data : data.userName
} ],
yAxis : [ {
type : 'value'
} ],
series : [
{
name:'总计',
type:'bar',
stack: '总量',
itemStyle : { normal: {label : {show: true, position: 'top'}}},
data:data.d
}
]
});
/** *************** */
});
}
});
}
同一系列颜色是相同的。
你可以换成多个系列。或者直接指定data级的itemStyle颜色。或者把color配置为function通过参数返回不同的颜色都能解决。
这样好像不行吧