Tales of an IT Nobody

devbox:~$ iptables -A OUTPUT -j DROP

JQuery – Sparkline: Re-draw on resize / responsive sparklines August 8, 2012

I’ve been suckered in by the awesome JQuery Sparkline plugin – I won’t go over how it works or what it does, but rather a quick ‘fix’ for fixing issues with how the output deals with browser resizing. (Long story short, it doesn’t by default).

Here’s a visual of the issue I’m talking about with responsive/resizing layouts

 

Normal:

After resize:

 

The fix:

Assign your Sparkline initialization to a variable as a function.

Then call the function to intialize, and bind it to JQuery’s $.resize() method.

I also used a short setTimeout() to avoid excessive redrawing during the resize operation.

And voila!

 

5 Comments on JQuery – Sparkline: Re-draw on resize / responsive sparklines
Categories: Design purdy