Ruby on rails 3.1 Lazy_high_图表:为什么options.xaxis未定义?

Ruby on rails 3.1 Lazy_high_图表:为什么options.xaxis未定义?,ruby-on-rails-3.1,highcharts,Ruby On Rails 3.1,Highcharts,我与ror合作并使用lazy_high_图表宝石。 我的查看代码是: %= high_stock("my_id", @h) do |c| %> <%="options.rangeSelector= {inputEditDateFormat: '%b %e, %Y',buttons: [{type: 'month',count: 1,text: '1m'}, {type: 'month',count: 3,text: '3m'}, {type: 'month',coun

我与ror合作并使用lazy_high_图表宝石。 我的查看代码是:

%= high_stock("my_id", @h) do |c| %>     
   <%="options.rangeSelector= {inputEditDateFormat: '%b %e, %Y',buttons: [{type: 'month',count: 1,text: '1m'}, {type: 'month',count: 3,text: '3m'}, {type: 'month',count: 6,text: '6m'}, {type: 'year',count: 1,text: '1y'}, {type: 'all',text: 'All'}]}"%>
    <%="options.xAxis.events.setExtremes = function() { alert 'ho';}" %>

<%end %>
%=high_stock(“my_id”,@h)do | c |%>
rangeSelector设置正常,但当我添加xaxis事件(或xaxis.other参数)时 我犯了个错误

“options.xAxis未定义”

在gem自述文件中,我看到了非常相似的示例:

你能帮我吗


提前感谢

您最好按照它的步骤,在控制器中使用它,而不是在视图中使用它

e、 g。 在控制器中

@h = LazyHighCharts::HighChart.new('graph') do |f|
f.options[:chart][:defaultSeriesType] = "area"
f.series(:name=>'John', :data=>[3, 20, 3, 5, 4, 10, 12 ,3, 5,6,7,7,80,9,9])
f.series(:name=>'Jane', :data=> [1, 3, 4, 3, 3, 5, 4,-46,7,8,8,9,9,0,0,9] )
end
鉴于,

<%= high_chart("my_id", @h) %>

您需要添加:

   <%="options.xAxis.events = {}" %>  

之前:

   <%="options.xAxis.events.setExtremes = function() { alert 'ho';}" %>

您的控制器代码是什么样子的?我成功了。(我为这个问题添加了一个答案)非常感谢。