2013-01-18 43 views
0

我使用flot來繪製特定月份的計劃賬單付款。我該如何區分相對於當天繪製的線形圖的顏色,即過去的日期應該有一種顏色,未來的日期應該有不同的顏色?使用jquery flot在同一佔位符中繪製兩個不同圖表

我使用下面的代碼:

$.plot($("#placeholder1"), [current_d1,current_d2],options_current); 

current_d1current_d2是我的兩個陣列和options_current是佔位符定義的選項。

var options_current= { 

    series: { 
     //dashes: { show: true, shadowSize: 0, steps:true}, 
    lines: { show: true,lineWidth:5,steps:true}, 
     points: { show: true,radius:4 }, 
     color: ('#0000ff'), 
     threshold: {below:0, color: "#DF0101"} 
     }, 
    xaxis: {min:1,max :max_value_current, tickFormatter: dayFormatter,tickColor: "rgba(255, 255, 255, 0)", tickDecimals:0,ticks:max_value} , 
    yaxis: {min:1,tickFormatter: dollarFormatter} , 

     grid: { hoverable: true, clickable: true, 

      borderWidth: 0, 

       markings: [ 
        {xaxis: {from:temp_day, to: temp_day}, color: '#A4A4A4'}, 
        {xaxis: {from:1, to: 1}, color: '#000000'}, 
        {yaxis: {from:1, to: 1}, color: '#000000'}      

          ] 

      }, 

       legend: { position: 'se'} 

    }; 

回答

2

您正在爲所有行提供全局「顏色」選項,這會強制它們全部使用相同的顏色(藍色)。您只需要省略該選項,Flot將爲每個系列選擇不同的顏色。

如果你真的想強制特定的顏色,那麼看看文檔;在頂部,在Data Format之下,請注意,一系列可以是原始數據或具有屬性的對象。如果您使用後面的幾個段落進行解釋,那麼您可以爲每個系列提供不同的線條選項以及不同的顏色。

相關問題