2016-11-28 28 views
1

請參閱例如小提琴:谷歌Visulisation動畫a.slice不是一個函數

http://jsfiddle.net/15t87L60/

var options = { 
     title: 'Test', 
     animation: { 
     duration: 300, 
     easing: 'out', 
     startup: true 
    } 

有證據顯示「a.slice是不是一個函數」的錯誤(火狐)或「對象不支持屬性或方法'切片'「(IE)。

我承諾,它可能試圖在非數組對象上切片,我可能已縮小到啓動:在動畫屬性中爲true。只是因爲刪除這不會導致錯誤。

任何想法如何我可以保留啓動屬性,但沒有錯誤?

由於

回答

0

的問題似乎是與列定義

"label"應該是一個字符串(包裹在引號"2013")與一個數字(2013

這 - >{"id":"","label":"2013","type":"number"}

不是 - >{"id":"","label":2013,"type":"number"}

看到下面的工作片段...

google.charts.load('current', { 
 
    callback: drawChart, 
 
    packages: ['corechart'] 
 
}); 
 

 
function drawChart() { 
 
    var data =new google.visualization.DataTable('{"cols":[{"id":"","label":"Age range","type":"string"},{"id":"","label":"2013","type":"number"},{"id":"","label":"2014","type":"number"},{"id":"","label":"2012","type":"number"},{"id":"","label":"2015","type":"number"},{"id":"","label":"2016","type":"number"}],"rows":[{"c":[{"v":"21-30"},{"v":89},{"v":187},{"v":0},{"v":0},{"v":0}]},{"c":[{"v":"31-40"},{"v":0},{"v":0},{"v":96},{"v":284},{"v":0}]},{"c":[{"v":"41-50"},{"v":210},{"v":0},{"v":0},{"v":0},{"v":92}]}]}'); 
 

 
    var options = { 
 
    animation: { 
 
     duration: 300, 
 
     easing: 'out', 
 
     startup: true 
 
    }, 
 
    title: 'Test' 
 
    }; 
 

 
    var chart = new google.visualization.BarChart(document.getElementById('chart_div')); 
 
    chart.draw(data, options); 
 
}
<script src="https://www.gstatic.com/charts/loader.js"></script> 
 
<div align="middle"> 
 
    <div id="chart_div" style="width: 600px; height: 300px;"></div> 
 
</div>

建議使用較新的庫...
<script src="https://www.gstatic.com/charts/loader.js"></script>

根據release notes ...

ve通過jsapi加載程序保持可用的Google圖表的rsion不再一致地更新。從現在起請使用新的gstatic裝載機(loader.js)。

這隻會改變load聲明(見上面的代碼中)

+0

就解決它,謝謝 – Ant