0

我正在使用 flot 来绘制特定月份的预定账单支付。如何区分相对于当天绘制的折线图的颜色,即过去的日期应该有一种颜色,而未来的日期应该有不同的颜色?

我正在使用以下代码:

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

current_d1并且current_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'}

  };
4

1 回答 1

2

您正在为所有线条提供全局“颜色”选项,这会强制它们全部使用相同的颜色(蓝色)。您只需省略该选项,Flot 将为每个系列选择不同的颜色。

如果您真的想强制使用特定颜色,请查看文档;在顶部的Data Format下,请注意系列可以是原始数据或具有属性的对象。如果您使用后面几段解释的后一种形式,那么您可以为每个系列提供不同的线路选项,从而提供不同的颜色。

于 2013-01-18T12:05:55.970 回答