mindok/contex

Tooltip on a line chart

Opened this issue · 1 comments

ev94 commented

Hi,

Thanks for the great work.
Is there a way to display a tooltip on a line chart to display the value in the graph?

Thx

mindok commented

Hi @ev94,

Unfortunately it is pretty much impossible using SVG by itself. SVG supports "tooltips" via a <title> element that may be embedded in another element. For bar charts it is possible to embed a title in each rectangle, and for point plots it is possible to embed within the point (not currently implemented), but for line charts there is only one SVG element for each series so it would only be possible to embed a single value. Javascript based libraries show the values using Javascript event handlers, but I don't really want to add the complexity of packaging JS hooks to do this.

The only other option I can think of is to draw markers for each point (using a circle or rect element rather than the line markers) on top of the line and have a title on that. It would require quite a lot of work to implement in the library, but you could have a go by combining the code for PointPlot and LinePlot and adding a <title> element to the <circle> element drawn by the point plot code.