Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery composite sparklines

I am new to sparklines and need help with something. I get data from mysql and populate a span tag with class=sparks. The graph is generated but when I create another span tag with the same class, but different data (composite line), I get the following message:

Attempted to attach a composite sparkline to an element with no existing sparkline.

My JavaScript:

$(".sparks").sparkline( 'html', {
  composite:'true',
  type:'line',
  width:'900px',
  height:'400px',
  disableHiddenCheck:'true'
});
like image 459
user1391915 Avatar asked Sep 11 '26 05:09

user1391915


2 Answers

Try to avoid making a selection on the class. It's better to draw one, and then on the next ones you set the flag composite equal to true. And be sure that all the drawings are pointing to the same div.

Following this note, remember to set changeRangeMin and chartRangeMax having the same values.

Note: You'll usually want to lock the axis on both charts using chartRangeMin and chartRangeMax if you want the same value on each chart to occupy the same point.

A working example: https://jsfiddle.net/sLphjqoc/2/

like image 62
blasrodri Avatar answered Sep 12 '26 18:09

blasrodri


The second sparkline needs to be applied to the same span tag in order to work as a composite.

Sparklines will then draw onto the existing canvas element that it creates within the initial span.

like image 39
mibbler Avatar answered Sep 12 '26 20:09

mibbler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!