Is it possible to label an arbitrary point on a graph?

187 Views Asked by At

I think the answer is no to this question, but I wanted to make sure I wasn't overlooking some workaround.

I am using underlayCallback to highlight several regions in a series, but there is no way to label the highlighted areas as far as I can tell. I would like to just add a div at a fixed x,y location on the graph. Is there a way I can accomplish this?

I also looked at hairlines, but I would rather use the highlight feature. I can add a div on the graph outside the chart, but it does not move with the data as it changes or zooms. Right now I just have a legend on the side of the chart that explains the highlights, but is not the look I am going for.

Any other ideas out there?

1

There are 1 best solutions below

0
On

Your approach of using an external <div> is reasonable. The only trick is that you'll have to reposition it every time that your underlayCallback is called. dygraphs itself does something similar for axis labels and annotations.

The toDomCoords method will help you convert x, y data values into DOM coordinates for absolutely positioning a <div>.