2015-11-05 91 views
-1

我不熟悉谷歌圖表。我的HTML文件根本沒有輸出。我在哪裏做錯了?谷歌折線圖不會顯示

我試圖堅持原始示例(https://google-developers.appspot.com/chart/interactive/docs/gallery/linechart),但我找不到任何區別。我基本上也只是修改了「數據代碼」。

感謝和問候,anumpho

<html> 
<head> 
    <script type="text/javascript" src="https://www.google.com/jsapi"></script> 
    <script type="text/javascript"> 
    google.load('visualization', '1.1', {packages: ['line']}); 
    google.setOnLoadCallback(drawChart); 

    function drawChart() { 

     var data = new google.visualization.DataTable(); 
data.addColumn('number'), 'Year'); 
data.addColumn('number'), 'Gesamt'); 
data.addColumn('number'), 'Allgemein bildende Pflichtschulen'); 
data.addColumn('number'), 'Neue Mittelschulen'); 
data.addColumn('number'), 'Allgemein bildende hoehere Schulen'); 
data.addColumn('number'), 'Sonstige allgemein bildende (Statut-)Schulen'); 
data.addColumn('number'), 'Berufsschulen'); 
data.addColumn('number'), 'Berufsbildende mittlere und hoehere Schulen'); 
data.addColumn('number'), 'Lehrerbildende Schulen'); 
data.addColumn('number'), 'Schulen und Akademien im Gesundheitswesen'); 


     data.addRows([ 
[2004, 211.612, 103.473, 0,  55.534,  0,  17.726,  31.089,  3.790,  0], 
[2005, 212.343, 102.780, 0,  56.956,  0,  18.139,  30.631,  3.837,  0], 
[2006, 226.732, 101.569, 0,  57.965,  3.850, 22.464,  31.929,  3.485,  5.470], 
[2007, 226.773, 100.181, 0,  58.572,  4.079, 23.205,  32.009,  3.448,  5.279], 
[2008, 225.749, 99.278,  0,  58.699,  4.225, 23.447,  31.562,  3.532,  5.006], 
[2009, 226.483, 97.137,  1.892, 58.050,  4.177, 23.786,  31.902,  4.774,  4.765], 
[2010, 224.697, 95.159,  3.802, 57.541,  4.521, 23.007,  32.175,  3.702,  4.790], 
[2011, 225.414, 94.761,  5.445, 57.385,  4.537, 22.160,  32.673,  4.168,  4.285], 
[2012, 225.645, 98.654,  0,  59.608,  4.435, 21.541,  33.179,  4.411,  3.817] 
     ]); 

     var options = { 
     chart: { 
      title: 'Box Office Earnings in First Two Weeks of Opening', 
      subtitle: 'in millions of dollars (USD)' 
     }, 
     width: 900, 
     height: 500 
     }; 

     var chart = new google.charts.Line(document.getElementById('linechart_material')); 

     chart.draw(data, options); 
    } 
    </script> 
</head> 
<body> 
    <div id="linechart_material"></div> 
</body> 
</html> 

回答

0

你缺少左括號 「(」 在所有 「data.addColumn」 行

例:

應該是:

data.addColumn(('number'),'Year');

不是:

data.addColumn('number'),'Year');

或者,你可以刪除後「number'on每一行是這樣的:

data.addColumn右括號(」數字」,‘年’);