Sha256: 0cd0d27400c77c005a10767910f730d0a3c78e12238b9310ee7d7b1e8afd0f1d

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 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 object
    # @param [String] str
    # @return [String]
    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

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
axlsx-1.1.3 lib/axlsx/drawing/cat_axis_data.rb
axlsx-1.1.2 lib/axlsx/drawing/cat_axis_data.rb
axlsx-1.1.1 lib/axlsx/drawing/cat_axis_data.rb
axlsx-1.1.0 lib/axlsx/drawing/cat_axis_data.rb