1
嗨我要在一個頁面上有很多圖表,都建立在highcharts js上。但是當我到達頁面上的一個部分時,我希望圖表的動畫開始。highcharts動畫多個圖表
我已經設置了一些測試,但我只能製作一個圖表動畫。爲什麼圖表2不是動畫?
<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 at a 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 i =0; i < sLen; i++){
s[i].update({
animation: true
}, false);
}
chart.redraw();
}, 1000);
});
ahh。有道理..謝謝 – Johansrk