javascript - Highcharts and jquery .load() -
i have problem or question. (sorry english, i'm french).
i use hightcharts show lot of charts on 1 page (~55 charts) , create them consume lot of time. that's why, want keep charts, don't want recreate them after change page , redisplay them later. make jsfiddle.example simulate want. http://jsfiddle.net/huhwj/2/
simple htlm page
<div id="container" style="height: 400px"></div> <button id="button">set new data</button> <button id="buttonget">get container</button> <button id="buttonset">set container</button> <button id="empty">empty container</button>
javascript
var chart = new highcharts.chart({ chart: { renderto: 'container' }, series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] }] }); var containerdata=''; var toggle=0; // button action $('#button').click(function() { if (toggle%2 == 0) { chart.series[0].setdata([129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4] ); } else { chart.series[0].setdata([29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] ); } toggle++; }); $('#buttonget').click(function() { containerdata=$("#container").html(); }); $('#buttonset').click(function() { $("#container").html(containerdata); chart.series[0].setdata([129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4] ); chart.redraw(); }); $('#empty').click(function() { $("#container").empty(); });
first, "set new data" button show active chart. "get container" capture div contant. now, if empty container "empty container" button (simulate change page jquery .load()), , fill "set container", chart appear inactive. question how can activate div container whith chart ? tryed setdate or redraw nothing seems ok. have idea ?
thanks help
Comments
Post a Comment