lib/axlsx/drawing/bar_3D_chart.rb in axlsx-1.3.4 vs lib/axlsx/drawing/bar_3D_chart.rb in axlsx-1.3.5
- old
+ new
@@ -19,32 +19,40 @@
alias :valAxis :val_axis
# The direction of the bars in the chart
# must be one of [:bar, :col]
# @return [Symbol]
- attr_reader :bar_dir
+ def bar_dir
+ @bar_dir ||= :bar
+ end
alias :barDir :bar_dir
# space between bar or column clusters, as a percentage of the bar or column width.
# @return [String]
attr_reader :gap_depth
alias :gapDepth :gap_depth
# space between bar or column clusters, as a percentage of the bar or column width.
# @return [String]
- attr_reader :gap_width
+ def gap_width
+ @gap_width ||= 150
+ end
alias :gapWidth :gap_width
-
+
#grouping for a column, line, or area chart.
# must be one of [:percentStacked, :clustered, :standard, :stacked]
# @return [Symbol]
- attr_reader :grouping
+ def grouping
+ @grouping ||= :clustered
+ end
# The shabe of the bars or columns
# must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
# @return [Symbol]
- attr_reader :shape
+ def shape
+ @shape ||= :box
+ end
# validation regex for gap amount percent
GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/
# Creates a new bar chart object
@@ -63,14 +71,11 @@
# @option options [Boolean] r_ang_ax
# @option options [Integer] perspective
# @see Chart
# @see View3D
def initialize(frame, options={})
- @bar_dir = :bar
- @grouping = :clustered
- @shape = :box
- @gap_width = 150
+ @vary_colors = true
@gap_width, @gap_depth, @shape = nil, nil, nil
@cat_ax_id = rand(8 ** 8)
@val_ax_id = rand(8 ** 8)
@cat_axis = CatAxis.new(@cat_ax_id, @val_ax_id)
@val_axis = ValAxis.new(@val_ax_id, @cat_ax_id, :tick_lbl_pos => :low, :ax_pos => :l)
@@ -122,10 +127,10 @@
def to_xml_string(str = '')
super(str) do |str_inner|
str_inner << '<c:bar3DChart>'
str_inner << '<c:barDir val="' << bar_dir.to_s << '"/>'
str_inner << '<c:grouping val="' << grouping.to_s << '"/>'
- str_inner << '<c:varyColors val="1"/>'
+ str_inner << '<c:varyColors val="' << vary_colors.to_s << '"/>'
@series.each { |ser| ser.to_xml_string(str_inner) }
@d_lbls.to_xml_string(str) if @d_lbls
str_inner << '<c:gapWidth val="' << @gap_width.to_s << '"/>' unless @gap_width.nil?
str_inner << '<c:gapDepth val="' << @gap_depth.to_s << '"/>' unless @gap_depth.nil?
str_inner << '<c:shape val="' << @shape.to_s << '"/>' unless @shape.nil?