blob: 60e6ee9d50b307ad6ead712c6d66d658784578e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
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)
data.each { |i| @list << i } if data.is_a?(SimpleTypedList)
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
|