Class: Axlsx::CatAxis

Inherits:
Axis
  • Object
show all
Defined in:
lib/axlsx/drawing/cat_axis.rb

Overview

A CatAxis object defines a chart category axis

Constant Summary collapse

LBL_OFFSET_REGEX =

regex for validating label offset

/0*(([0-9])|([1-9][0-9])|([1-9][0-9][0-9])|1000)/

Instance Attribute Summary collapse

Attributes inherited from Axis

#ax_id, #ax_pos, #color, #cross_ax, #crosses, #delete, #format_code, #gridlines, #label_rotation, #scaling, #tick_lbl_pos, #title

Instance Method Summary collapse

Constructor Details

#initialize(ax_id, cross_ax, options = {}) ⇒ CatAxis

Creates a new CatAxis object

Parameters:

  • ax_id (Integer)

    the id of this axis. Inherited

  • cross_ax (Integer)

    the id of the perpendicular axis. Inherited

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • ax_pos. (Symbol)

    Inherited

  • tick_lbl_pos. (Symbol)

    Inherited

  • crosses. (Symbol)

    Inherited

  • auto (Boolean)
  • lbl_algn (Symbol)
  • lbl_offset (Integer)
  • tick_lbl_skip (Integer)
  • tick_mark_skip (Integer)


17
18
19
20
21
22
23
24
# File 'lib/axlsx/drawing/cat_axis.rb', line 17

def initialize(ax_id, cross_ax, options={})
  @tick_lbl_skip = 1
  @tick_mark_skip = 1
  self.auto = 1
  self.lbl_algn = :ctr
  self.lbl_offset = "100"
  super(ax_id, cross_ax, options)
end

Instance Attribute Details

#autoBoolean

From the docs: This element specifies that this axis is a date or text axis based on the data that is used for the axis labels, not a specific choice.

Returns:

  • (Boolean)


28
29
30
# File 'lib/axlsx/drawing/cat_axis.rb', line 28

def auto
  @auto
end

#lbl_algnSymbol Also known as: lblAlgn

specifies how the perpendicular axis is crossed must be one of [:ctr, :l, :r]

Returns:

  • (Symbol)


33
34
35
# File 'lib/axlsx/drawing/cat_axis.rb', line 33

def lbl_algn
  @lbl_algn
end

#lbl_offsetInteger Also known as: lblOffset

The offset of the labels must be between a string between 0 and 1000

Returns:

  • (Integer)


39
40
41
# File 'lib/axlsx/drawing/cat_axis.rb', line 39

def lbl_offset
  @lbl_offset
end

#tick_lbl_skipInteger Also known as: tickLblSkip

The number of tick lables to skip between labels

Returns:

  • (Integer)


44
45
46
# File 'lib/axlsx/drawing/cat_axis.rb', line 44

def tick_lbl_skip
  @tick_lbl_skip
end

#tick_mark_skipBoolean Also known as: tickMarkSkip

The number of tickmarks to be skipped before the next one is rendered.

Returns:

  • (Boolean)


49
50
51
# File 'lib/axlsx/drawing/cat_axis.rb', line 49

def tick_mark_skip
  @tick_mark_skip
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

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

Returns:

  • (String)


79
80
81
82
83
84
85
86
87
88
# File 'lib/axlsx/drawing/cat_axis.rb', line 79

def to_xml_string(str = '')
  str << '<c:catAx>'
  super(str)
  str << '<c:auto val="' << @auto.to_s << '"/>'
  str << '<c:lblAlgn val="' << @lbl_algn.to_s << '"/>'
  str << '<c:lblOffset val="' << @lbl_offset.to_i.to_s << '"/>'
  str << '<c:tickLblSkip val="' << @tick_lbl_skip.to_s << '"/>'
  str << '<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>'
  str << '</c:catAx>'
end