admin管理员组

文章数量:1287622

Is there a way to make a vertical 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

Is there a way to make a vertical 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

Share Improve this question asked Sep 8, 2011 at 19:41 BobBob 6711 gold badge7 silver badges12 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 8

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./tests/highlighted-region.html and http://dygraphs./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./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 .....

本文标签: javascriptdygraph vertical lineStack Overflow