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/cat_axis_data.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/cat_axis_data.rb')
| -rw-r--r-- | lib/axlsx/drawing/cat_axis_data.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/axlsx/drawing/cat_axis_data.rb b/lib/axlsx/drawing/cat_axis_data.rb new file mode 100644 index 00000000..83dfa56e --- /dev/null +++ b/lib/axlsx/drawing/cat_axis_data.rb @@ -0,0 +1,34 @@ +module Axlsx + # The CatAxisData class serializes the category axis data for a chart + class CatAxisData < SimpleTypedList + + # Create a new CatAxisData object + # @param [Array, SimpleTypedList] data the data for this category axis. This can be a simple array or a simple typed list of cells. + def initialize(data=[]) + super Object + @list.concat data if data.is_a?(Array) + end + + # Serializes the category axis data + # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. + # @return [String] + def to_xml(xml) + xml.send('c:cat') { + xml.send('c:strRef') { + xml.send('c:f', Axlsx::cell_range(@list)) + xml.send('c:strCache') { + xml.send('c:ptCount', :val=>size) + each_with_index do |item, index| + v = item.is_a?(Cell) ? item.value : item + xml.send('c:pt', :idx=>index) { + xml.send('c:v', v) + } + end + } + } + } + end + + end + +end |
