diff options
| author | Randy Morgan <[email protected]> | 2012-04-27 19:18:05 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-04-27 19:18:05 +0900 |
| commit | 956117947416cba4ce21737ae0c2a431e4865b8e (patch) | |
| tree | 045b5993105166eedb9be3760e94716461e1d2f4 /lib/axlsx/drawing/pie_series.rb | |
| parent | 3748326fe3c09515077ab97f4d2a2b0638e823fd (diff) | |
| download | caxlsx-956117947416cba4ce21737ae0c2a431e4865b8e.tar.gz caxlsx-956117947416cba4ce21737ae0c2a431e4865b8e.zip | |
colored chart series and examples. Still need to workout scatter as it uses line and shape
Diffstat (limited to 'lib/axlsx/drawing/pie_series.rb')
| -rw-r--r-- | lib/axlsx/drawing/pie_series.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/axlsx/drawing/pie_series.rb b/lib/axlsx/drawing/pie_series.rb index 0deac1be..7e518886 100644 --- a/lib/axlsx/drawing/pie_series.rb +++ b/lib/axlsx/drawing/pie_series.rb @@ -19,6 +19,9 @@ module Axlsx # @return [Integert] attr_reader :explosion + # An array of rgb colors to apply to your bar chart. + attr_reader :colors + # Creates a new series # @option options [Array, SimpleTypedList] data # @option options [Array, SimpleTypedList] labels @@ -27,11 +30,15 @@ module Axlsx # @param [Chart] chart def initialize(chart, options={}) @explosion = nil + @colors = [] super(chart, options) self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil? self.data = ValAxisData.new(options[:data]) unless options[:data].nil? end + # @see colors + def colors=(v) DataTypeValidator.validate "BarSeries.colors", [Array], v; @colors = v end + # @see explosion def explosion=(v) Axlsx::validate_unsigned_int(v); @explosion = v; end @@ -41,6 +48,13 @@ module Axlsx def to_xml_string(str = '') super(str) do |str_inner| str_inner << '<c:explosion val="' << @explosion << '"/>' unless @explosion.nil? + colors.each_with_index do |c, index| + str << '<c:dPt>' + str << '<c:idx val="' << index.to_s << '"/>' + str << '<c:spPr><a:solidFill>' + str << '<a:srgbClr val="' << c << '"/>' + str << '</a:solidFill></c:spPr></c:dPt>' + end @labels.to_xml_string str_inner unless @labels.nil? @data.to_xml_string str_inner unless @data.nil? end |
