Sha256: 74a4bd08e2d102d8bc4263416db1eb62d66685616e4ee8a0d33669bad9006cc8

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

# encoding: UTF-8
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.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

  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
axlsx-1.0.18 lib/axlsx/drawing/cat_axis_data.rb
axlsx-1.0.17 lib/axlsx/drawing/cat_axis_data.rb