From 1a9e9d03a2181a928a95be4a642751f34e1a1c34 Mon Sep 17 00:00:00 2001 From: shifakhan Date: Sat, 21 Feb 2015 16:31:07 +0530 Subject: Background color option for charts --- lib/axlsx/drawing/chart.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb index 1d6b9293..066d49cd 100644 --- a/lib/axlsx/drawing/chart.rb +++ b/lib/axlsx/drawing/chart.rb @@ -23,6 +23,7 @@ module Axlsx @display_blanks_as = :gap @series_type = Series @title = Title.new + @bg_color = nil parse_options options start_at(*options[:start_at]) if options[:start_at] end_at(*options[:end_at]) if options[:end_at] @@ -80,6 +81,10 @@ module Axlsx # Default :gap (although this really should vary by chart type and grouping) attr_reader :display_blanks_as + # Background color for the chart + # @return [String] + attr_reader :bg_color + # The relationship object for this chart. # @return [Relationship] def relationship @@ -146,6 +151,12 @@ module Axlsx @series.last end + # Assigns a background color to chart area + def bg_color=(v) + DataTypeValidator.validate(:color, Color, Color.new(:rgb => v)) + @bg_color = v + end + # Serializes the object # @param [String] str # @return [String] @@ -176,6 +187,16 @@ module Axlsx str << ('') str << '' str << '' + if bg_color + str << '' + str << '' + str << '' + str << '' + str << '' + str << '' + str << '' + str << '' + end str << '' str << '' str << '' -- cgit v1.2.3