我有以下代碼:新Highcharts.Chart創造麻煩。爲什麼?
資產/ JavaScript的/ activities.js.coffee
jQuery ->
graph = new Highcharts.Chart
chart:
renderTo: "activity_graph"
type: 'column'
exporting:
buttons:
printButton:
enabled: true
....
資產/ JavaScript的/ activity_groups.js.coffee
jQuery ->
$('ul').children('ul').hide()
的activity_group文件不起作用,如果我的活動文件中有新的Highcharts.Chart。如果我評論新的Highcharts.Chart,它可以正常工作。兩個文件都可以正常加載爲什麼會發生?
[EDIT1]
我玩弄我也注意到,如果我把$('ul').children('ul').hide()
之前graph = new Highcharts.Chart
也按預期工作。我不想把它放在同一個文件中,雖然,我不希望有將其放置在圖形變量前面必然。
[EDIT2]
發現一個錯誤,爲什麼我認爲它沒有工作。我不是很熟悉javascript。 未捕獲Highcharts錯誤#13:
Highcharts錯誤#13
渲染DIV沒有找到
如果chart.renderTo選項misconfugured使Highcharts是無法找到的HTML元素來渲染,就會出現此錯誤在圖表中。
我的標記只包含activity_graph格在我需要它(在我的活動顯示視圖)。它不包括在其他地方。這就是爲什麼我認爲我得到這個錯誤。我不想在任何其他地方使用它...任何想法?
[EDIT3]
這是我與軌道產生的標記:
= content_tag :div, "", id: "activity_graph", data: {name: graph.name, minutes: graph.minutes, year: graph.year, month: graph.month, day: graph.day, data_hash: graph.data_hash}
我得到我的div id爲activity_graph,沒有問題顯示圖。該錯誤不會彈出,當我在此頁......不過如果我瀏覽不同的網頁上,則錯誤,因爲我沒有這個div和ID不再彈出...
請出示的標記,可以是可以提供幫助。只需補充一點,'highcharts'不會對'hidden'元素起作用。 – Jashwant
@Jashwant我發現了一個錯誤。我會更新我的帖子。 –
'renderTo:「activity_graph」'意味着你需要一個帶有'id = activity_graph'的元素,並且在調用'highcharts'的時候它不應該是'display:none'或'hide()'。你能顯示與它相關的標記(html)嗎? – Jashwant