summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/bar_chart.rb
diff options
context:
space:
mode:
authorZsolt Kozaroczy <[email protected]>2021-07-24 00:31:54 +0200
committerGitHub <[email protected]>2021-07-24 00:31:54 +0200
commit158942c16b249a269e77633dd261b87787d191af (patch)
treebca8bcd68530a6f67115080e4295303960963a12 /lib/axlsx/drawing/bar_chart.rb
parent187461e2a653e53c34171cc894e10c3dcfced04d (diff)
downloadcaxlsx-158942c16b249a269e77633dd261b87787d191af.tar.gz
caxlsx-158942c16b249a269e77633dd261b87787d191af.zip
Add overlap to bar charts (#107)
Diffstat (limited to 'lib/axlsx/drawing/bar_chart.rb')
-rw-r--r--lib/axlsx/drawing/bar_chart.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/axlsx/drawing/bar_chart.rb b/lib/axlsx/drawing/bar_chart.rb
index e9af9400..cb596fce 100644
--- a/lib/axlsx/drawing/bar_chart.rb
+++ b/lib/axlsx/drawing/bar_chart.rb
@@ -49,6 +49,12 @@ module Axlsx
@grouping ||= :clustered
end
+ # Overlap between series
+ # @return [Integer]
+ def overlap
+ @overlap ||= 0
+ end
+
# The shape of the bars or columns
# must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
# @return [Symbol]
@@ -71,7 +77,7 @@ module Axlsx
# @see Chart
def initialize(frame, options={})
@vary_colors = true
- @gap_width, @gap_depth, @shape = nil, nil, nil
+ @gap_width, @gap_depth, @overlap, @shape = nil, nil, nil, nil
super(frame, options)
@series_type = BarSeries
@d_lbls = nil
@@ -106,6 +112,11 @@ module Axlsx
end
alias :gapDepth= :gap_depth=
+ def overlap=(v)
+ RangeValidator.validate "BarChart.overlap", -100, 100, v
+ @overlap=(v)
+ end
+
# The shape of the bars or columns
# must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
def shape=(v)
@@ -124,6 +135,7 @@ module Axlsx
str << ('<c:varyColors val="' << vary_colors.to_s << '"/>')
@series.each { |ser| ser.to_xml_string(str) }
@d_lbls.to_xml_string(str) if @d_lbls
+ str << ('<c:overlap val="' << @overlap.to_s << '"/>') unless @overlap.nil?
str << ('<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil?
str << ('<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil?
str << ('<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil?