Class: Axlsx::CatAxisData
- Inherits:
-
SimpleTypedList
- Object
- SimpleTypedList
- Axlsx::CatAxisData
- Defined in:
- lib/axlsx/drawing/cat_axis_data.rb
Overview
The CatAxisData class serializes the category axis data for a chart
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(data = []) ⇒ CatAxisData
constructor
Create a new CatAxisData object.
-
#to_xml_string(str = '') ⇒ String
Serializes the object.
Constructor Details
#initialize(data = []) ⇒ CatAxisData
Create a new CatAxisData object
8 9 10 11 12 |
# File 'lib/axlsx/drawing/cat_axis_data.rb', line 8 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_string(str = '') ⇒ String
Serializes the object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/axlsx/drawing/cat_axis_data.rb', line 17 def to_xml_string(str = '') str << '<c:cat>' str << '<c:strRef>' str << '<c:f>' << Axlsx::cell_range(@list) << '</c:f>' str << '<c:strCache>' str << '<c:ptCount val="' << size.to_s << '"/>' each_with_index do |item, index| v = item.is_a?(Cell) ? item.value.to_s : item str << '<c:pt idx="' << index.to_s << '"><c:v>' << v << '</c:v></c:pt>' end str << '</c:strCache>' str << '</c:strRef>' str << '</c:cat>' end |