我有几个文件正在尝试加载高图。我怀疑时间有问题,但我无法确定问题所在。图表有时会加载,但有时不会加载,我收到错误消息:Uncaught TypeError: Object [object Object] has no method 'highcharts'
有什么想法吗?
这是我的主干观点:
namespace "happiness_kpi", (exports) ->
exports.chartView = Backbone.View.extend
template: HandlebarsTemplates['templates/chart']
el: '#lineChart'
initialize: ->
$.getScript "http://code.highcharts.com/stock/highstock.js", success: @buildChart()
render: ->
@$el.html HandlebarsTemplates.chart()
buildChart: ->
$.getScript "build_chart.coffee", success: @render()
这是我构建图表的 js 文件:
$ ->
$.getJSON "http://www.highcharts.com/samples/data/jsonp.php?filename=aapl- c.json&callback=?", (data) ->
# Create the chart
$('#lineChart').highcharts "StockChart",
rangeSelector:
selected: 1
title:
text: "Just Checking"
series: [
name: "Oakland University"
data: data
tooltip:
valueDecimals: 2
]
我最初将脚本加载到 hamlbars 模板中,但我尝试以不同的方式进行。无论我尝试过哪种方式,我都没有运气。