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_pos, #color, #cross_axis, #crosses, #delete, #format_code, #gridlines, #id, #label_rotation, #scaling, #tick_lbl_pos, #title

Instance Method Summary collapse

Methods included from OptionsParser

#parse_options

Constructor Details

#initialize(options = {}) ⇒ CatAxis

Creates a new CatAxis object

Parameters:

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

    a customizable set of options

Options Hash (options):

  • tick_lbl_skip (Integer)
  • tick_mark_skip (Integer)


9
10
11
12
13
14
15
16
# File 'lib/axlsx/drawing/cat_axis.rb', line 9

def initialize(options={})
  @tick_lbl_skip = 1
  @tick_mark_skip = 1
  self.auto = 1
  self.lbl_algn = :ctr
  self.lbl_offset = "100"
  super(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)


20
21
22
# File 'lib/axlsx/drawing/cat_axis.rb', line 20

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)


25
26
27
# File 'lib/axlsx/drawing/cat_axis.rb', line 25

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)


31
32
33
# File 'lib/axlsx/drawing/cat_axis.rb', line 31

def lbl_offset
  @lbl_offset
end

#tick_lbl_skipInteger Also known as: tickLblSkip

The number of tick lables to skip between labels

Returns:

  • (Integer)


36
37
38
# File 'lib/axlsx/drawing/cat_axis.rb', line 36

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)


41
42
43
# File 'lib/axlsx/drawing/cat_axis.rb', line 41

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)


71
72
73
74
75
76
77
78
79
80
# File 'lib/axlsx/drawing/cat_axis.rb', line 71

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