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)/.freeze

Constants inherited from Axis

Axis::VALID_TICK_MARK_VALUES

Instance Attribute Summary collapse

Attributes inherited from Axis

#ax_pos, #color, #cross_axis, #crosses, #delete, #format_code, #gridlines, #id, #label_rotation, #major_tick_mark, #minor_tick_mark, #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, nil)
  • tick_mark_skip (Integer, nil)


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

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


18
19
20
# File 'lib/axlsx/drawing/cat_axis.rb', line 18

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)


23
24
25
# File 'lib/axlsx/drawing/cat_axis.rb', line 23

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)


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

def lbl_offset
  @lbl_offset
end

#tick_lbl_skipInteger? Also known as: tickLblSkip

The number of tick labels to skip between labels

Returns:

  • (Integer, nil)


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

def tick_lbl_skip
  @tick_lbl_skip
end

#tick_mark_skipInteger? Also known as: tickMarkSkip

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

Returns:

  • (Integer, nil)


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

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)


84
85
86
87
88
89
90
91
92
93
# File 'lib/axlsx/drawing/cat_axis.rb', line 84

def to_xml_string(str = +'')
  str << '<c:catAx>'
  super
  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 << '"/>' unless @tick_lbl_skip.nil?
  str << '<c:tickMarkSkip val="' << @tick_mark_skip.to_s << '"/>' unless @tick_mark_skip.nil?
  str << '</c:catAx>'
end