this.each不是谷歌geochart中的函数错误

时间:2017-05-23 14:31:52

标签: javascript magento google-visualization

<ul id="myList"><li>Coffee</li><li>Tea</li></ul> 

我有上面的代码来获取地理位置。但我得到this.each不是geochart div中的函数错误。请给我解决方案。

1 个答案:

答案 0 :(得分:0)

包加载在load语句中......

google.charts.load('current', {
  callback: drawCharts,
  packages: ['corechart', 'geochart']  // <-- packages for regular charts and geo charts
});

常规图表(如行,列和散点图)都使用'corechart'

专业图表,如地理图表,通常有自己的包需要加载......

请务必加载'geochart'包...

请参阅以下工作代码段...

&#13;
&#13;
google.charts.load('current', {
  callback: drawCharts,

  // packages for regular charts, and geo charts
  packages: ['corechart', 'geochart']
});

function drawCharts() {
  var data = google.visualization.arrayToDataTable([
    ['Country', 'Popularity'],
    ['Germany', 200],
    ['United States', 300],
    ['Brazil', 400],
    ['Canada', 500],
    ['France', 600],
    ['RU', 700]
  ]);

  var chartGeo = new google.visualization.GeoChart(document.getElementById('regions_div'));
  chartGeo.draw(data);

  var chartCol = new google.visualization.ColumnChart(document.getElementById('chart_div'));
  chartCol.draw(data);
}
&#13;
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>
<div id="regions_div"></div>
&#13;
&#13;
&#13;