我已经建立了一些图表使用高级图表,填充它的系列列使用辉煌的'gon‘宝石。现在,我正在尝试使用ajax更新它的结果。
下面是我的设置:
user_controller:
gon.segmentedData = ActiveRecord query here..application.js
var weekly_options = { //Some standard highcharts options here
series: gon.segmentedData
};这就完美地呈现了图表。我想用下面的操作来解释这个图表
视图:
<div class = deposit>
<%= form_tag transact_path, :remote => true, :validate => true, :method => :post do %>
.
.
.
<%= submit_tag "Deposit", :id => 'deposit_button', :class => 'round', :disable_with => 'Please wait..' %> 为了将更新的数据放到图表中,我重新填充了transaction_controller的create操作中的系列数据
transaction_controller
def create
gon.segmentedData = ..
endcreate.js :
var options = //here i pass all the options again
new Highcharts.Chart(options);我的问题是,我无法通过create.js通过transaction_controller获得一组更新的选项。同样的图表会再次呈现。
如果有人能为我批评这种方法,我会非常感激的。
发布于 2012-04-06 04:25:30
在从控制器获取更新的数据以填充高图表数据时遇到了问题。我没有使用源源不断地返回陈旧数据的gon,而是改用了json。现在很有魅力了。
发布于 2012-02-29 16:03:57
使用懒惰的高图表来节省你的时间!
https://github.com/michelson/lazy_high_charts
例如在控制器中,
@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) %>https://stackoverflow.com/questions/9445310
复制相似问题