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

Passing "disableInteraction: true" to the first sparkline fails composite sparklines #110

Open rockneverdies55 opened 10 years ago

rockneverdies55 commented 10 years ago

I have tested this with both v2.1.1 and v2.1.2 and the problem exists in both.

In order to have double sparklines in the same canvas, you should pass composite: true in the options of the second sparkline.

However if you set disableInteraction to true on the fist sparkline, then it fails to draw the 2nd line without overriding the first line.

Example:

var values = [5, 4, 5, -2, 1, -3],
    values2 = [3, 4, 0.9, 2, -2.5, 3];

// Draw a sparkline for the #sparkline element
$('#sparkline').sparkline(values, {
    sparkMin: -3,
    sparkMax: 5,
    width: 200,
    height: 200,
    lineColor: "blue",
    disableInteraction: false,
    fillColor: ""
});

$('#sparkline').sparkline(values2, {
    composite: true,
    sparkMin: -3,
    sparkMax: 5,
    width: 200,
    height: 200,
    lineColor: "red",    
    fillColor: ""
});

So if you replace disableInteraction: false by disableInteraction: true in the snippet above, you only get one sparkline instead of 2.

corsen2000 commented 10 years ago

:+1: Same issue here

hrstoyanov commented 9 years ago

Please, someone fix it already... 11 months since originally discovered already.

hrstoyanov commented 9 years ago

As workaround, I commented out lines 2880-2884 in v 2.1.2 : // if (!this.interact) { // // not interactive so no need to keep the shapes array // this.shapes = {}; // this.shapeseq = []; // }