markrcote/flot-hiddengraphs

Using hiddengraphs with the tracking example.

chrisrapson opened this issue · 1 comments

I would like to use the crosshair plugin to continually update the legend entry, as in the tracking example http://www.flotcharts.org/flot/examples/tracking/index.html

I would also like to be able to hide series using your plugin. But it seems that after I update the series label, based on cursor position, the function findPlotSeries(label) doesn't work anymore. Is there I'm something I'm doing wrong? (See http://jsfiddle.net/8xLSq/2/)

Perhaps there's a better way to detect which series should be "found"? I looked at another plugin with similar functionality: https://github.com/jamesinc/flot which goes about it completely differently, but I'm not convinced I want to change yet. e.g. I couldn't hack the labelformatter there (yet).

Hi, sorry for taking so long to look at this. Not sure if this is still useful to you, but I believe I've figured this out.

I'm pretty sure that the root of the confusion is that hiddengraphs overwrites options.legend.labelFormatter. This is not good, and I am going to file a separate issue for it.

At this moment, you have two options: call draw() after setupGrid() in your updateLegend() function, or set the contents of the span that hiddengraph sets (class 'graphlabel'). Neither is great; the first does all kinds of unnecessary extra work, but there's (currently) no hook between the clearing of the legend (and thus hiddengraphs's events) and the end of setupGrid(). The second works but assumes knowledge of the internals of hiddengraph. I would suggest the second, with a big comment in your code, because it's the least invasive. All you need to do is delete the call to setupGrid() and replace the line above it with

$('.graphlabel').eq(jj).text(series.label);

I'm going to close this issue out because there's a workaround, but as I say I'll file an issue for the labelFormatter overwriting.