setData and setCategory highcharts from rails -


i'm using highcharts 3.0.1 ruby on rails.

basically have javascript ( in ajax/remote request) :

var chart = $('#my_bar_div').highcharts(); chart.xaxis[0].setcategories(["cat1", "cat2", "cat4"]); chart.series[0].setdata([6.0,7.0,8.0]); 

ruby version _updatechart.js.erb:

var chart = $('#my_bar_div').highcharts(); chart.xaxis[0].setcategories(<%= @qids.to_s.html_safe %>); chart.series[0].setdata(<%= @average_values.to_json %>); 

i'm going 6 3 categories/rows, use vertical column chart:

@bar = lazyhighcharts::highchart.new('column') |f|   f.series(:name=>'punkte',:data=> @average_values )      f.title({ :text=>"auswertung fragen " + @theobjects.name })    ###  options bar   f.options[:chart][:defaultseriestype] = "bar"   f.plot_options({:series=>{:stacking=>"normal"}, :bar => { :datalabels => { :enabled => true }}})   f.options[:xaxis] = {:plot_bands => "none", :title=>{:text=>""}, :categories => @qids}   f.options[:yaxis] = {:title => { :text =>'punkte', :align =>'high'}, :labels => { :overflow => 'justify' } } end 

it resizes categories, not redraw columns, tried without success.

maybe got ideas?

thanks, patrick

fixed example: http://jsfiddle.net/bcryp/4/

1) "plotbands": "none" -> remove or use {}

2) use same variable's name:

var chart; $(document).ready(function () {     var chart = new highcharts.chart(options);     jquery("#button").on("click", function () {         chart.xaxis[0].setcategories(["wie geht es?", "how mam?"], true);         chart.series[0].setdata([5.5, 6.0], true);     }); }); 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -