开发者

dygraph vertical line

开发者 https://www.devze.com 2023-04-04 02:49 出处:网络
Is there a way to make a ver开发者_运维问答tical line in the js graph library dygraph? I am loading data and would like to put vertical lines like graphite does to show events

Is there a way to make a ver开发者_运维问答tical line in the js graph library dygraph?

I am loading data and would like to put vertical lines like graphite does to show events

is there some special context to add vertical lines

dygraph vertical line


You've probably figured this out by now, or stopped caring, but the way to do this is with a custom underlay (see http://dygraphs.com/tests/highlighted-region.html and http://dygraphs.com/tests/underlay-callback.html for examples). You provide an underlayCallback function when creating the graph, and it gets called with the canvas element, area (which helps with coordinate math), and a reference to the Dygraph object.


Here is a simple solution.

Use the crosshair demo (http://dygraphs.com/tests/crosshair.html) on the Dygraph site.

Once you disable the horizontal bar on the crosshair sample, you are getting a vertical bar.


  g4.updateOptions({ pointClickCallback: function(event, p) {
    var div_vertical_style="top:0px;left:"+g4.toDomCoords(p.xval,-20)[0]+"px;width:1px;height:"+g4.plotter_.area.h+";background-color:black;position:absolute;";
    $("#graphdiv4").append("<div style="+div_vertical_style+"></div>")
   }}); 

//my idea , add div .....

0

精彩评论

暂无评论...
验证码 换一张
取 消