方法一:颜色池子
color: function(params) {
// build a color map as your need.
var colorList = [ '#C1232B','#B5C334','#FCCE10','#E87C25','#27727B',
'#FE8463','#9BCA63','#FAD860','#F3A43B','#60C0DD',
'#D7504B','#C6E579','#F4E001','#F0805A','#26C0C0'
];
return colorList[params.dataIndex]
}
方法一改进:
echo "<input id='forColorList' value=".$str1." hidden='hidden'>";
var str1 = document.getElementById('forColorList').value;
var forColorList = str1.split(',');
color: function(params) {
// build a color map as your need.
var colorList = forColorList;
return colorList[params.dataIndex]
}
方法二: 随机生成颜色
var color=createColorCode('#'+Math.floor(Math.random()*16777215).toString(16),colorArr);
//生成不同的颜色代码
function createColorCode(code,colorArr){
if($.inArray(code, colorArr)==-1 && code.length>6){
colorArr[0]=code;
}else{
code='#'+Math.floor(Math.random()*16777215).toString(16);
createColorCode(code,colorArr);
}
return colorArr;
}
"color":color[0].split(',')
转载至:https://blog.csdn.net/qq_35052627/article/details/79499684