class Axlsx::BarSeries
A BarSeries
defines the title, data and labels for bar charts @note The recommended way to manage series is to use Chart#add_series
@see Worksheet#add_chart
@see Chart#add_series
Attributes
An array of rgb colors to apply to your bar chart.
The data for this series. @return [NumDataSource]
The labels for this series. @return [Array, SimpleTypedList]
The shabe of the bars or columns must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax] @return [Symbol]
Public Class Methods
Creates a new series @option options [Array, SimpleTypedList] data @option options [Array, SimpleTypedList] labels @option options [String] title @option options [String] shape @option options [String] colors an array of colors to use when rendering each data point @param [Chart] chart
# File lib/axlsx/drawing/bar_series.rb, line 33 def initialize(chart, options={}) @shape = :box @colors = [] super(chart, options) self.labels = AxDataSource.new({:data => options[:labels]}) unless options[:labels].nil? self.data = NumDataSource.new(options) unless options[:data].nil? end
Public Instance Methods
@see colors
# File lib/axlsx/drawing/bar_series.rb, line 42 def colors=(v) DataTypeValidator.validate "BarSeries.colors", [Array], v; @colors = v end
The shabe of the bars or columns must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
# File lib/axlsx/drawing/bar_series.rb, line 46 def shape=(v) RestrictionValidator.validate "BarSeries.shape", [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax], v @shape = v end
Serializes the object @param [String] str @return [String]
# File lib/axlsx/drawing/bar_series.rb, line 54 def to_xml_string(str = '') super(str) do 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) unless @labels.nil? @data.to_xml_string(str) unless @data.nil? # this is actually only required for shapes other than box str << ('<c:shape val="' << shape.to_s << '"></c:shape>') end end
Private Instance Methods
assigns the data for this series
# File lib/axlsx/drawing/bar_series.rb, line 75 def data=(v) DataTypeValidator.validate "Series.data", [NumDataSource], v; @data = v; end
assigns the labels for this series
# File lib/axlsx/drawing/bar_series.rb, line 78 def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end