简体   繁体   English

Google图表-组合图示例问题

[英]Google Charts - Combo Chart Example Issue

This is probably a simple fix, but I can't see what is going wrong. 这可能是一个简单的修复程序,但是我看不到出了什么问题。 I am trying to use a bit of code from Candlesticks is always on top of lines in combo chart google chart and https://google-developers.appspot.com/chart/interactive/docs/gallery/candlestickchart . 我正在尝试使用Candlesticks的一些代码始终位于组合图google图表https://google-developers.appspot.com/chart/interactive/docs/gallery/candlestickchart 的行顶部 I have tried placing it in my html code (this works for other examples) but its not working in this case. 我尝试将其放置在我的html代码中(这适用于其他示例),但在这种情况下不起作用。 Just wondering if you can help me debug it. 只是想知道您是否可以帮助我进行调试。

<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>

Your HTML body doesn't contain an element called visualization - this is where the chart is inserted in the below line: 您的HTML主体不包含称为可视化的元素-这是将图表插入以下行的位置:

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

Here's a fiddle: http://jsfiddle.net/s2nya2Lv/ 这是一个小提琴: http : //jsfiddle.net/s2nya2Lv/

Does this solve your problem, or is there another problem? 这是否解决了您的问题,还是还有其他问题? Your question doesn't clearly explain what exactly the problem is. 您的问题并未清楚说明问题的确切原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM