dyrgraphs系列选项不起作用

时间:2014-04-30 18:57:20

标签: dygraphs

我试图为每个系列设置图表选项,但我没有运气。在这个例子中,我希望看到系列“不保留”#39;和'主持人'作为点,系列'不保持趋势'和主机趋势'作为线条。实际结果仅为分数。我做错了什么?

http://jsfiddle.net/Bc58h/

   drawPoints: "true",
   colors: [ "orange", "blue", "black", "violet" ],
   strokeWidth: 0,
   series: {
      'Hosts trend': {
         strokeWitdh: 1,
         pointSize: 0
      },
      'Not kept trend': {
         strokeWitdh: 1,
         pointSize: 0
      }
   }

1 个答案:

答案 0 :(得分:0)

你有三个问题导致你的问题:

  1. 每个系列设置中拼写错误的strokeWidth。
  2. 要使两者之间具有空值的行,您需要添加connectSeparatedPoints: true参数。
  3. 在CSV列标题中,您需要删除逗号后的空格,以便它们不会成为系列名称的一部分:"Date,Not kept,Hosts,Not kept trend,Hosts trend\n"+
  4. 所以你的完整代码应该是这样的:

    g = new Dygraph(
    
       // containing div
       document.getElementById("dr1"),
       "Date,Not kept,Hosts,Not kept trend,Hosts trend\n"+
       "2014-03-31, , , 73, 6\n"+
       "2014-04-01, 50, 10, , \n"+
       "2014-04-02, 63, 11, , \n"+
       "2014-04-03, 120, 12, , \n"+
       "2014-04-04, 55, 20, , \n"+
       "2014-04-05, 60, 22, , \n"+
       "2014-04-06, 63, 25, , \n"+
       "2014-04-07, 52, 24, , \n"+
       "2014-04-14, , , 46, 46\n",
    
       // options
    {
       xRangePad: 10,
       yRangePad: 10,
       title: "Promises not kept",
    
       // legend options
       legend: "always",
       labelsDiv: "dr1_labels",
       labelsSeparateLines: "true",
       connectSeparatedPoints: true,
       drawPoints: "true",
       colors: [ "orange", "blue", "black", "violet" ],
       strokeWidth: 0,
       series: {
          'Hosts trend': {
             strokeWidth: 1,
             pointSize: 0
          },
          'Not kept trend': {
             strokeWidth: 1,
             pointSize: 0
          }
       }
    }
    );
    
      

    以下是您更新的 FIDDLE