dygraph vertical line

喜欢而已 提交于 2019-12-07 22:57:05

问题


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


回答1:


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.




回答2:


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.




回答3:


  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 .....



来源:https://stackoverflow.com/questions/7353539/dygraph-vertical-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!