0

我正在使用https://github.com/winston/google_visualr在我的页面上加载一个谷歌图表,它返回带有图表内容的 javascript;

<script type='text/javascript'>
     google.load('visualization','1', {packages: ['geochart']});
     google.setOnLoadCallback(draw_geochart);
     function draw_geochart() {
        var data_table = new         google.visualization.DataTable();data_table.addColumn({"type":"string","label":"Country"});data_table.addColumn({"type":"number","label":"Visits"});data_table.addRow([{v: "United Kingdom"}, {v: 13}]);
                    var chart = new google.visualization.GeoChart(document.getElementById('geochart'));
                    chart.draw(data_table, {dataMode: "regions", width: 700, height: 500, title: "Company Performance"});
                  };
</script>

这在与页面一起呈现时工作正常,但我无法通过 ajax 让它工作,发送了正确的响应,但它不会出现在页面上。我正在加载它;

图表.js.erb

$('#geochart').html("<%=  render_chart @countries_chart, 'geochart' %>");

仪表板控制器上的图表操作在页面加载时调用;

仪表板.js.coffee

ready = ->
      $.get 'charts'
4

0 回答 0