diff options
| author | Randy Morgan <[email protected]> | 2012-04-01 00:35:26 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-04-01 00:35:26 +0900 |
| commit | 22a341841f191a5aa00e87b1f166b4f25cc67f0a (patch) | |
| tree | 505f46708d5cac7d33d0dd6679c125e2eb819075 /lib/axlsx/drawing/bar_series.rb | |
| parent | bb2117ba17297e02a0fc6d5ad5a22462e72a9a79 (diff) | |
| download | caxlsx-22a341841f191a5aa00e87b1f166b4f25cc67f0a.tar.gz caxlsx-22a341841f191a5aa00e87b1f166b4f25cc67f0a.zip | |
part way through changing all serialization to use string concatenation prior to dropping Nokogiri dep in production.
Diffstat (limited to 'lib/axlsx/drawing/bar_series.rb')
| -rw-r--r-- | lib/axlsx/drawing/bar_series.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/axlsx/drawing/bar_series.rb b/lib/axlsx/drawing/bar_series.rb index 5be8fabc..3a3ea6fa 100644 --- a/lib/axlsx/drawing/bar_series.rb +++ b/lib/axlsx/drawing/bar_series.rb @@ -6,8 +6,8 @@ module Axlsx # @see Chart#add_series class BarSeries < Series - - # The data for this series. + + # The data for this series. # @return [Array, SimpleTypedList] attr_reader :data @@ -31,15 +31,23 @@ module Axlsx super(chart, options) self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil? self.data = ValAxisData.new(options[:data]) unless options[:data].nil? - end + end # The shabe of the bars or columns # must be one of [:percentStacked, :clustered, :standard, :stacked] - def shape=(v) + def shape=(v) RestrictionValidator.validate "BarSeries.shape", [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax], v @shape = v end + def to_xml_string(str = '') + super(str) do + @labels.to_xml_string(str) unless @labels.nil? + @data.to_xml_string(str) unless @data.nil? + str << '<shape val="' << @shape.to_s << '"/>' + end + end + # Serializes the series # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. # @return [String] @@ -48,11 +56,11 @@ module Axlsx @labels.to_xml(xml_inner) unless @labels.nil? @data.to_xml(xml_inner) unless @data.nil? xml_inner.shape :val=>@shape - end + end end - - private + + private # assigns the data for this series def data=(v) DataTypeValidator.validate "Series.data", [SimpleTypedList], v; @data = v; end |
