krzysu / flot.tooltip

tooltip plugin for wonderful Flot plotting library
https://github.com/krzysu/flot.tooltip
187 stars 153 forks source link

Allow tooltipsOpts.content function to not return a string #102

Closed EvilDrW closed 9 years ago

EvilDrW commented 9 years ago

Some of the flot charts I make have lots and lots of series on them, but only a few of those are important enough to merit having a tooltip. Right now I can achieve this by appending an additional property to my series:

graphObject.data = 
   [{
      data: iso,
      color: '#C0C0C0',
      isBackground: true
   }, ...]

Then test for this property in my .content function:

graphObject.options.tooltipOpts = {
   content: function(label, xval, yval, flotItem) {
      if (!flotItem.series.isBackground)
         return "%s: (P: %y, H: %x)";
      else
         return false;
   }
}

This gets me the effect I want, but throws endless Uncaught TypeError: Cannot read property 'match' of undefined errors to the console.