gwatts / jquery.sparkline

A plugin for the jQuery javascript library to generate small sparkline charts directly in the browser
http://omnipotent.net/jquery.sparkline/
1.24k stars 278 forks source link

sp.currentRegion in tooltipFormatter callback always undefined #82

Closed net3k closed 11 years ago

net3k commented 11 years ago

tooltipFormatter: function(sp, options, fields) {}

actual behaviour: sp.currentRegion is always undefined expected behaviour: sp.currentRegion contains the index of the bar that has the tooltip

net3k commented 11 years ago

I found this function that explicitly sets this.currentRegion to undefined. If this line is commented out, the callback behaves as expected.

/**
 * Reset any currently highlighted item
 */
clearRegionHighlight: function () {
    if (this.currentRegion !== undefined) {
        this.removeHighlight();
//      this.currentRegion = undefined;
        return true;
    }
    return false;
}

Thing is that I am not sure about side effects.

net3k commented 11 years ago

Got it. Just use: sp.getCurrentRegionFields() to access the current index/offset.