简体   繁体   English

Dygraph如何始终在图例中显示值

[英]Dygraph how to always show values in the legend

Is it possible to always show the values of the signals in the legend even when the mouse is not over the figure? 即使鼠标不在图形上方,也可以始终在图例中显示信号的值吗?

I think values appearing and disappearing when the mouse is not over the figure are a bit annoying and I would like to come up with a solution which: 我认为当鼠标不在图形上方时出现和消失的值有点烦人,我想提出一种解决方案:

  • Until the user goes over the figure with the mouse, the legend shows signal names and their values at x = 0 直到用户用鼠标翻过图,图例才在x = 0处显示信号名称及其值。
  • While the user moves the mouse on the figure the legend should work as usual (ie being interactive) 当用户在图形上移动鼠标时,图例应照常运行(即处于交互状态)
  • When the mouse is no longer over the figure the legend shows last values pointed 当鼠标不再位于图形上方时,图例显示指向的最后一个值

Would it be possible to get something like this? 会得到这样的东西吗? If yes, how? 如果是,怎么办?

EDIT: I found out there are callbacks sensitive to mouse events. 编辑:我发现有对鼠标事件敏感的回调。 In particular, highlightCallback and unhighlightCallback may be used to obtain what I want. 特别是, highlightCallbackunhighlightCallback可以用来获取我想要的东西。 Unfortunately, I do not find any example that shows how to change what's shown in the legend, I've only found examples which add HTML below the figure, like in this callback example . 不幸的是,我找不到任何显示如何更改图例中显示内容的示例,仅找到了在该图下方添加HTML的示例,如该回调示例

The numbers in the legend reflect the current selection. 图例中的数字反映了当前的选择。 If there's no selection, there will be no numbers. 如果没有选择,将没有数字。 So try calling setSelection in unhighlightCallback . 因此,尝试在unhighlightCallback调用setSelection

Alternatively, use the new legendFormatter option. 或者,使用新的legendFormatter选项。 (Until v2 is released, this will require you to build dygraphs from HEAD .) (直到v2发布,这将要求您从HEAD构建图表。)

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

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