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

Redraw on window resize #171

Open iadj opened 8 years ago

iadj commented 8 years ago

When I load my page containing a sparkline container inside of a fluid div, and I resize the window to show a larger graph, the line chart becomes very low resolution. Is there a way to make it responsive or to redraw it with a window resize?

sivajisanapala commented 7 years ago

function sparkline() { $("#yourspark-chart").sparkline([209, 210, 209, 210, 210, 211, 212, 210], { type: 'line', width: '96%', height: '30' }); } sparkline(); You may call the function on window resize $( window ).resize(function() { sparkline(); }); It works fine for me hope Will help you @iadj

zedtux commented 7 years ago

@sivajisanapala it isn't working for me.

UPDATE Sorry, I went too fast, it's working but it's slow.

UPDATE 2 Using CSS is working like a charm:

.sparkline
  canvas
    width: 100%