2015-09-15 91 views

回答

0

一种选择是将您的数据系列分为两个,一个用于填充区域,另一个用于其他区域。然后,您可以设置fillGraph只是填充系列:

new Dygraph(div, 
[ 
    [1, 3, null], 
    [2, 6, null], 
    [3, 8, null], 
    [4, 9, 9 ], 
    [5, null, 9 ], 
    [6, 8, 8 ], 
    [7, 6, null], 
    [8, 3, null] 
], { 
    // note: second 'Y' series has a space, to distinguish it. (hack!) 
    labels: ['X', 'Y', 'Y '], 
    series: { 
     'Y': { 
      color: 'blue' 
     }, 
     'Y ': { 
      fillGraph: true, 
      color: 'blue' 
     } 
    } 
}); 

this fiddle

看起来是正确的,但确实存在使数据更加复杂的缺点&当您将鼠标悬停在转换点上时,图例中会显示两个y值。

另一种方法是编写仅填充特定区域的custom plotter。你可以看看this demothis question的灵感。

+0

非常感谢!我想我需要按照你的建议写一个自定义绘图仪。 – spidersharma

+0

用例基本上是说在一个速度时间图中填充图的部分,并显示曲线下面的区域(使用自定义绘图仪填充)基本上是距离。另外我会做一个绘图仪,在给定的点显示切线,以显示各种物理/数学概念。我会更新,一旦我写这些自定义绘图仪,并希望将它们集成在dygraph中。一旦感谢,并继续关于dygraph的伟大工作! – spidersharma

相关问题