flot - jQuery 柱状统计图颜色怎么自定义啊。。。图为默认颜色。求自定义 5
$(function(){(function($){functioninit(plot){varmultiple=false;varsArray=[];vartotWid...
$(function(){(function ($) { function init(plot) { var multiple = false; var sArray = []; var totWidth = 0; function procRawData(plot, series, data, datapoints) { if(series.bars.show) { sArray.push(series); } } function procDatapoints(plot, series, datapoints) { //Ensure we only process these once if(series.bars.show && series.bars.barLeft==undefined) { if(totWidth==0) { for(var j = 0; j < sArray.length; j++) { totWidth+=sArray[j].bars.barWidth; } } var runWidth=0; for(var k = 0; k < sArray.length; k++) { s=sArray[k]; if(s==series) { break; } runWidth+=s.bars.barWidth; } series.bars.barLeft = runWidth-(totWidth/2); } } function checkMultipleBarsEnabled(plot, options) { if (options.multiplebars) { multiple = options.multiplebars; sArray=[]; totWidth=0; plot.hooks.processRawData.push(procRawData); plot.hooks.processDatapoints.push(procDatapoints); } } plot.hooks.processOptions.push(checkMultipleBarsEnabled); } var options = { multiplebars: false }; $.plot.plugins.push({ init: init, options: options, name: "multiplebars", version: "0.1" });})(jQuery); /* end of multi plugin */var datevv = [10,20,30,];// setup some random datavar d1 = [10,20,30,40,50,60,70];for (var i = 0; i <= 6; i += 1) d1.push([i,d1[i]]);var d2 = [15,25,35,45,55,65,75];for (var i = 0; i <= 6; i += 1) d2.push([i,d2[i]]);var d3 = [30,40,50,60,70,80,90];for (var i = 0; i <= 6; i += 1) d3.push([i,d3[i]]);// plot!$.plot($("#placeholder"), [ d1, d2, d3 ], { series: { bars: { show: true, barWidth:0.2, align:'center',horizontal: false } }, multiplebars:true });});
展开
2个回答
展开全部
$.plot("#placeholderZH", [data,data1], {
series: {
bars: {
show: true,
barWidth: 0.6,
align: "center"
}
},
xaxis: {
mode: "categories",
tickLength: 10,
min: -1,
max: 2
},
colors: ["#DC5625", "#007ACC"]//这里就是颜色自定义的地方。
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询