Class: Axlsx::Axis

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

Overview

the access class defines common properties and values for a chart axis.

Direct Known Subclasses

CatAxis, SerAxis, ValAxis

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Creates an Axis object

Parameters:

  • axId (Integer)

    the id of this axis

  • crossAx (Integer)

    the id of the perpendicular axis

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

    a customizable set of options

Options Hash (options):

  • axPos (Symbol)
  • crosses (Symbol)
  • tickLblPos (Symbol)

Raises:

  • (ArgumentError)

    If axId or crossAx are not unsigned integers



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/axlsx/drawing/axis.rb', line 45

def initialize(axId, crossAx, options={})
  Axlsx::validate_unsigned_int(axId)
  Axlsx::validate_unsigned_int(crossAx)
  @axId = axId
  @crossAx = crossAx
  @scaling = Scaling.new(:orientation=>:minMax)
  self.axPos = :l
  self.tickLblPos = :nextTo
  self.format_code = "General"
  self.crosses = :autoZero
  options.each do |o|
    self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
  end
end

Instance Attribute Details

#axIdInteger (readonly)

the id of the axis.

Returns:

  • (Integer)


7
8
9
# File 'lib/axlsx/drawing/axis.rb', line 7

def axId
  @axId
end

#axPosSymbol

The position of the axis must be one of [:l, :r, :t, :b]

Returns:

  • (Symbol)


21
22
23
# File 'lib/axlsx/drawing/axis.rb', line 21

def axPos
  @axPos
end

#crossAxInteger (readonly)

The perpendicular axis

Returns:

  • (Integer)


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

def crossAx
  @crossAx
end

#crossesSymbol

specifies how the perpendicular axis is crossed must be one of [:autoZero, :min, :max]

Returns:

  • (Symbol)


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

def crosses
  @crosses
end

#format_codeString

The number format format code for this axis default :General

Returns:

  • (String)


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

def format_code
  @format_code
end

#scalingScaling (readonly)

The scaling of the axis

Returns:

See Also:



16
17
18
# File 'lib/axlsx/drawing/axis.rb', line 16

def scaling
  @scaling
end

#tickLblPosSymbol

the position of the tick labels must be one of [:nextTo, :high, :low]

Returns:

  • (Symbol)


26
27
28
# File 'lib/axlsx/drawing/axis.rb', line 26

def tickLblPos
  @tickLblPos
end

Instance Method Details

#to_xml(xml) ⇒ String

Serializes the common axis

Parameters:

  • xml (Nokogiri::XML::Builder)

    The document builder instance this objects xml will be added to.

Returns:

  • (String)


68
69
70
71
72
73
74
75
76
77
# File 'lib/axlsx/drawing/axis.rb', line 68

def to_xml(xml)
  xml.send('c:axId', :val=>@axId)
  @scaling.to_xml(xml)
  xml.send('c:axPos', :val=>@axPos)
  xml.send('c:majorGridlines')
  xml.send('c:numFmt', :formatCode => @format_code, :sourceLinked=>"1")
  xml.send('c:tickLblPos', :val=>@tickLblPos)
  xml.send('c:crossAx', :val=>@crossAx)
  xml.send('c:crosses', :val=>@crosses)
end