highcharts animation multiple charts -
hi going have lot of charts on page, build on highcharts js. want animation of chart begin when reach section on page.
i have set testing, can make 1 chart animate. why chart number 2 not animate ?
<div class="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div> <div class="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div> $(function () { var test = [ { name: 'firefox', y: 45.0 }, { name: 'ie', y: 26.8 }, { name: 'chrome', y: 12.8, sliced: true, selected: true }, { name: 'safari', y: 8.5 }, { name: 'opera', y: 6.2 }, { name: 'others', y: 0.7 } ]; $('.container').each(function() { $(this).highcharts({ chart: { plotbackgroundcolor: null, plotborderwidth: null, plotshadow: false }, title: { text: 'browser market shares @ specific website, 2010' }, tooltip: { pointformat: '{series.name}: <b>{point.percentage:.1f}%</b>' }, plotoptions: { pie: { allowpointselect: true, cursor: 'pointer', datalabels: { enabled: true, color: '#000000', connectorcolor: '#000000', format: '<b>{point.name}</b>: <br /> {point.percentage:.1f} %' } } }, series: [{ type: 'pie', name: 'browser share', data: test, animation : false }] }); }) var chart = $('.container').highcharts(), s = chart.series, slen = s.length; settimeout(function() { for(var =0; < slen; i++){ s[i].update({ animation: true }, false); } chart.redraw(); }, 1000);
});
it's caused using $(".container").highcharts()
return first chart. instead create example array of charts, stored, have simple access them. see: http://jsfiddle.net/rtxvb/1/
var test = [{ name: 'firefox', y: 45.0 }, { name: 'ie', y: 26.8 }, { name: 'chrome', y: 12.8, sliced: true, selected: true }, { name: 'safari', y: 8.5 }, { name: 'opera', y: 6.2 }, { name: 'others', y: 0.7 }]; var charts = [] $('.container').each(function () { charts.push(new highcharts.chart({ chart: { renderto: }, series: [{ type: 'pie', name: 'browser share', data: test, animation: false }] })); }) $(charts).each(function (ind, chart) { var s = chart.series, slen = s.length; settimeout(function () { (var = 0; < slen; i++) { s[i].update({ animation: true }, false); } chart.redraw(); }, 1000); });
Comments
Post a Comment