简体   繁体   English

dygraph垂直线

[英]dygraph vertical line

Is there a way to make a vertical line in the js graph library dygraph? 有没有办法在js图库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 是否有一些特殊的上下文来添加垂直线

在此输入图像描述

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). 您可能已经想到了这一点,或者停止了关怀,但是这样做的方法是使用自定义底层(请参阅http://dygraphs.com/tests/highlighted-region.htmlhttp://dygraphs.com /tests/underlay-callback.html例子)。 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. 您在创建图形时提供了underlayCallback函数,并使用canvas元素, area (有助于坐标数学)和Dygraph对象的引用来调用它。

Here is a simple solution. 这是一个简单的解决方案。

Use the crosshair demo (http://dygraphs.com/tests/crosshair.html) on the Dygraph site. 在Dygraph网站上使用十字准线演示(http://dygraphs.com/tests/crosshair.html)。

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 ..... //我的想法,添加div .....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM