2014-09-26 51 views
2

這可能是一個簡單的解決方法,但我看不出發生了什麼問題。我正嘗試使用Candlesticks is always on top of lines in combo chart google charthttps://google-developers.appspot.com/chart/interactive/docs/gallery/candlestickchart中的一段代碼。我已經嘗試將它放在我的html代碼中(這適用於其他示例),但在這種情況下它不起作用。只是想知道你是否可以幫我調試它。谷歌圖表 - 組合圖示例問題

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



function drawVisualization() { 
    // Create and populate the data table. 
    var data = new google.visualization.DataTable(); 
    data.addColumn('string', 'Day'); 
    data.addColumn('number', 'Dummy'); 
    data.addColumn('number', 'Range'); 
    data.addColumn({type: 'number', role: 'interval'}); 
    data.addColumn({type: 'number', role: 'interval'}); 
    data.addColumn('number', 'Trend'); 
    data.addRows([ 
    ['Mon', 28, 10, -8, 17, 42.8], 
    ['Tue', 38, 17, -7, 28, 47.5], 
    ['Wed', 55, 22, -5, 25, 52.2], 
    ['Thu', 66, 11, -16, 11, 56.9], 
    ['Fri', 22, 44, -7, 44, 61.6], 
    ]); 

    // Create and draw the visualization. 
    var ac = new google.visualization.ComboChart(document.getElementById('visualization')); 
    ac.draw(data, { 
    title : 'Monthly Coffee Production by Country', 
    width: 600, 
    height: 400, 
    vAxis: {title: "Cups"}, 
    hAxis: {title: "Month"}, 
    isStacked: true, 
    seriesType: "bars", 
    series: {0: {color: 'transparent'}, 2: {type: "line"}} 
    }); 
} 



    </script> 
    </head> 
    <body> 
    </body> 
</html> 

回答

4

你的HTML體不含有稱爲可視化的元素 - 這是圖表插入下面一行:

var ac = new google.visualization.ComboChart(document.getElementById('visualization')); 

這裏有一個小提琴:http://jsfiddle.net/s2nya2Lv/

這是否解決你的問題,還是有另一個問題?你的問題沒有清楚地解釋問題到底是什麼。