Home » excel » ruby on rails – Inverted Axis in AXLSX Bar Chart

ruby on rails – Inverted Axis in AXLSX Bar Chart

Posted by: admin April 23, 2020 Leave a comment

Questions:

I’m using this very straightforward code (practically the same as the bar chart examples here, however I am noticing that the Axes are inverted. The data that should be on the Val axis is shown on the Cat axis.

This is also true for the example linked above, and I can’t seem to find a way to put them in the correct order.

Below is an image of the problem. The code used to generate it is:

sheet.add_chart(Axlsx::Bar3DChart,:title => "Chart", :show_legend => false, :start_at => "A1", :end_at => "P30", :bar_dir => :col) do |chart|
   chart.add_series :data => sheet["B1:B25"], :labels => sheet["A1:A25"]
   chart.valAxis.gridlines = false
   chart.catAxis.gridlines = false
end

How to&Answers:

I fixed it. You can find my fork of axlsx here: https://github.com/HansCz/axlsx.

A pull request will be sent to https://github.com/randym/axlsx