Class: Axlsx::NamedAxisData

Inherits:
CatAxisData
  • Object
show all
Defined in:
lib/axlsx/drawing/named_axis_data.rb

Overview

The ValAxisData class manages the values for a chart value series.

Instance Method Summary collapse

Constructor Details

#initialize(name, data = []) ⇒ NamedAxisData

creates a new NamedAxisData Object

Parameters:

  • name (String)

    The serialized node name for the axis data object

  • The (Array)

    data to associate with the axis data object



10
11
12
13
# File 'lib/axlsx/drawing/named_axis_data.rb', line 10

def initialize(name, data=[])
  super(data)
  @name = name
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

  • str (String) (defaults to: '')

Returns:

  • (String)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/axlsx/drawing/named_axis_data.rb', line 18

def to_xml_string(str = '')
  str << '<c:' << @name.to_s << '>'
  str << '<c:numRef>'
  str << '<c:f>' << Axlsx::cell_range(@list) << '</c:f>'
  str << '<c:numCache>'
  str << '<c:formatCode>General</c:formatCode>'
  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:numCache>'
  str << '</c:numRef>'
  str << '</c:' << @name.to_s << '>'
end