diff options
| author | Randy Morgan <[email protected]> | 2011-11-23 12:28:10 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2011-11-23 12:28:10 +0900 |
| commit | 6739c249e7bf3cf7d2132b2aa49b6faf6bebec29 (patch) | |
| tree | c68e1527212c3665464debeebd2d97c127b0887e /lib/axlsx/drawing/bar_series.rb | |
| parent | 099a1d5a7824b7a6392bfe2f124ebeaf9d8122db (diff) | |
| download | caxlsx-6739c249e7bf3cf7d2132b2aa49b6faf6bebec29.tar.gz caxlsx-6739c249e7bf3cf7d2132b2aa49b6faf6bebec29.zip | |
-refactoring chart position and axis data/category for chart.
-additional specs and documentation improvements.
Diffstat (limited to 'lib/axlsx/drawing/bar_series.rb')
| -rw-r--r-- | lib/axlsx/drawing/bar_series.rb | 41 |
1 files changed, 6 insertions, 35 deletions
diff --git a/lib/axlsx/drawing/bar_series.rb b/lib/axlsx/drawing/bar_series.rb index 0f46af15..5e10eb0e 100644 --- a/lib/axlsx/drawing/bar_series.rb +++ b/lib/axlsx/drawing/bar_series.rb @@ -28,8 +28,8 @@ module Axlsx def initialize(chart, options={}) @shape = :box super(chart, options) - self.data = options[:data] || [] - self.labels = options[:labels] || [] + self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil? + self.data = ValAxisData.new(options[:data]) unless options[:data].nil? end def shape=(v) @@ -42,37 +42,8 @@ module Axlsx # @return [String] def to_xml(xml) super(xml) do |xml| - if !labels.empty? - xml.send('c:cat') { - xml.send('c:strRef') { - xml.send('c:f', Axlsx::cell_range(labels)) - xml.send('c:strCache') { - xml.send('c:ptCount', :val=>labels.size) - labels.each_with_index do |cell, index| - v = cell.is_a?(Cell) ? cell.value : cell - xml.send('c:pt', :idx=>index) { - xml.send('c:v', v) - } - end - } - } - } - end - xml.send('c:val') { - xml.send('c:numRef') { - xml.send('c:f', Axlsx::cell_range(data)) - xml.send('c:numCache') { - xml.send('c:formatCode', 'General') - xml.send('c:ptCount', :val=>data.size) - data.each_with_index do |cell, index| - v = cell.is_a?(Cell) ? cell.value : cell - xml.send('c:pt', :idx=>index) { - xml.send('c:v', v) - } - end - } - } - } + @labels.to_xml(xml) unless @labels.nil? + @data.to_xml(xml) unless @data.nil? xml.send('c:shape', :val=>@shape) end end @@ -82,10 +53,10 @@ module Axlsx # assigns the data for this series - def data=(v) DataTypeValidator.validate "Series.data", [Array, SimpleTypedList], v; @data = v; end + def data=(v) DataTypeValidator.validate "Series.data", [SimpleTypedList], v; @data = v; end # assigns the labels for this series - def labels=(v) DataTypeValidator.validate "Series.labels", [Array, SimpleTypedList], v; @labels = v; end + def labels=(v) DataTypeValidator.validate "Series.labels", [SimpleTypedList], v; @labels = v; end end |
