Class: Axlsx::CatAxisData

Inherits:
SimpleTypedList
  • Object
show all
Defined in:
lib/axlsx/drawing/cat_axis_data.rb

Overview

The CatAxisData class serializes the category axis data for a chart

Direct Known Subclasses

ValAxisData

Instance Method Summary collapse

Constructor Details

#initialize(data = []) ⇒ CatAxisData

Create a new CatAxisData object



7
8
9
10
11
# File 'lib/axlsx/drawing/cat_axis_data.rb', line 7

def initialize(data=[])
  super Object
  @list.concat data if data.is_a?(Array)
  data.each { |i| @list << i } if data.is_a?(SimpleTypedList)
end

Instance Method Details

#to_xml(xml) ⇒ String

Serializes the category axis data



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/axlsx/drawing/cat_axis_data.rb', line 16

def to_xml(xml)
  xml.cat {
    xml.strRef {
      xml.f Axlsx::cell_range(@list)
      xml.strCache {
        xml.ptCount :val=>size
        each_with_index do |item, index|
          v = item.is_a?(Cell) ? item.value : item
          xml.pt(:idx=>index) {
            xml.v v
          }                          
        end
      }
    }
  }
end