简体   繁体   中英

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

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 .

Alternatively, use the new legendFormatter option. (Until v2 is released, this will require you to build dygraphs from HEAD .)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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