summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/val_axis_data.rb
blob: 6a24a1ef46c788558c5e2a6dae5d9564c7c569bd (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
module Axlsx
  # The ValAxisData class manages the values for a chart value series.
  class ValAxisData < CatAxisData

    # Serializes the value 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:val') {
        xml.send('c:numRef') {
          xml.send('c:f', Axlsx::cell_range(@list))
          xml.send('c:numCache') {
            xml.send('c:formatCode', 'General')
            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