lib/axlsx/drawing/pie_series.rb in axlsx-1.1.3 vs lib/axlsx/drawing/pie_series.rb in axlsx-1.1.4
- old
+ new
@@ -17,44 +17,58 @@
# The explosion for this series
# @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
# @option options [String] title
# @option options [Integer] explosion
# @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?
+ self.labels = AxDataSource.new(:data => options[:labels]) unless options[:labels].nil?
+ self.data = NumDataSource.new(options) 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
# Serializes the object
# @param [String] str
# @return [String]
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
str
end
private
# assigns the data for this series
- def data=(v) DataTypeValidator.validate "Series.data", [SimpleTypedList], v; @data = v; end
+ def data=(v) DataTypeValidator.validate "Series.data", [NumDataSource], v; @data = v; end
# assigns the labels for this series
- def labels=(v) DataTypeValidator.validate "Series.labels", [SimpleTypedList], v; @labels = v; end
+ def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end
end
end