lib/write_xlsx/chart/bar.rb in write_xlsx-0.0.4 vs lib/write_xlsx/chart/bar.rb in write_xlsx-0.51.0

- old
+ new

@@ -17,28 +17,37 @@ module Writexlsx class Chart class Bar < self include Writexlsx::Utility - def initialize - super(self.class) - @subtype = 'clustered' + def initialize(subtype) + super(subtype) + @subtype = subtype || 'clustered' @cat_axis_position = 'l' @val_axis_position = 'b' @horiz_val_axis = 0 @horiz_cat_axis = 1 + @show_crosses = false end # # Override the virtual superclass method with a chart specific method. # - def write_chart_type - # Reverse X and Y axes for Bar charts. - @x_axis, @y_axis = @y_axis, @x_axis + def write_chart_type(params) + if params[:primary_axes] != 0 + ## Reverse X and Y axes for Bar charts. + @y_axis, @x_axis = @x_axis, @y_axis + if !@y_axis[:_major_gridlines] + @y_axis[:_major_gridlines] = {:show => 1} + end + if @y2_axis[:_position] == 'r' + @y2_axis[:_position] = 't' + end + end # Write the c:barChart element. - write_bar_chart + write_bar_chart(params) end # # Write the <c:barDir> element. # @@ -47,19 +56,9 @@ attributes = ['val', val] @writer.empty_tag('c:barDir', attributes) end - - # - # Over-ridden to add c:overlap. - # - # Write the series elements. - # - def write_series - write_series_base {write_overlap if @subtype =~ /stacked/} - end - # # Over-ridden to add % format. TODO. This will be refactored back up to the # SUPER class later. #