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

#axId, #axPos, #crossAx, #crosses, #delete, #format_code, #gridlines, #label_rotation, #scaling, #tickLblPos

Instance Method Summary collapse

Constructor Details

#initialize(axId, crossAx, options = {}) ⇒ CatAxis

Creates a new CatAxis object

Parameters:

  • axId (Integer)

    the id of this axis. Inherited

  • crossAx (Integer)

    the id of the perpendicular axis. Inherited

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

    a customizable set of options

Options Hash (options):

  • axPos. (Symbol)

    Inherited

  • tickLblPos. (Symbol)

    Inherited

  • crosses. (Symbol)

    Inherited

  • auto (Boolean)
  • lblAlgn (Symbol)
  • lblOffset (Integer)
  • tickLblSkip (Integer)
  • tickMarkSkip (Integer)


44
45
46
47
48
49
50
51
# File 'lib/axlsx/drawing/cat_axis.rb', line 44

def initialize(axId, crossAx, options={})
  @tickLblSkip = 1
  @tickMarkSkip = 1
  self.auto = 1
  self.lblAlgn = :ctr
  self.lblOffset = "100%"
  super(axId, crossAx, 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)


8
9
10
# File 'lib/axlsx/drawing/cat_axis.rb', line 8

def auto
  @auto
end

#lblAlgnSymbol

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

Returns:

  • (Symbol)


13
14
15
# File 'lib/axlsx/drawing/cat_axis.rb', line 13

def lblAlgn
  @lblAlgn
end

#lblOffsetInteger

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

Returns:

  • (Integer)


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

def lblOffset
  @lblOffset
end

#tickLblSkipInteger

The number of tick lables to skip between labels

Returns:

  • (Integer)


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

def tickLblSkip
  @tickLblSkip
end

#tickMarkSkipBoolean

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

Returns:

  • (Boolean)


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

def tickMarkSkip
  @tickMarkSkip
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

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

Returns:

  • (String)


75
76
77
78
79
80
81
82
83
84
# File 'lib/axlsx/drawing/cat_axis.rb', line 75

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