diff options
| author | shifakhan <[email protected]> | 2015-02-21 16:31:07 +0530 |
|---|---|---|
| committer | shifakhan <[email protected]> | 2015-02-21 16:31:07 +0530 |
| commit | 1a9e9d03a2181a928a95be4a642751f34e1a1c34 (patch) | |
| tree | c770494326fc4b3bc9e10d440c5c7f86123044aa /lib/axlsx/drawing/chart.rb | |
| parent | c24ec92ab6495b6b0c36e8e139d3d3ce350fc5c5 (diff) | |
| download | caxlsx-1a9e9d03a2181a928a95be4a642751f34e1a1c34.tar.gz caxlsx-1a9e9d03a2181a928a95be4a642751f34e1a1c34.zip | |
Background color option for charts
Diffstat (limited to 'lib/axlsx/drawing/chart.rb')
| -rw-r--r-- | lib/axlsx/drawing/chart.rb | 21 |
1 files changed, 21 insertions, 0 deletions
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 << ('<c:dispBlanksAs val="' << display_blanks_as.to_s << '"/>') str << '<c:showDLblsOverMax val="1"/>' str << '</c:chart>' + if bg_color + str << '<c:spPr>' + str << '<a:solidFill>' + str << '<a:srgbClr val="' << bg_color << '"/>' + str << '</a:solidFill>' + str << '<a:ln>' + str << '<a:noFill/>' + str << '</a:ln>' + str << '</c:spPr>' + end str << '<c:printSettings>' str << '<c:headerFooter/>' str << '<c:pageMargins b="1.0" l="0.75" r="0.75" t="1.0" header="0.5" footer="0.5"/>' |
