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
59
# 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
  @format_code = "General"
  @scaling = Scaling.new(:orientation=>:minMax)      
  self.axPos = :b
  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)


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

def to_xml(xml)
  xml.axId :val=>@axId
  @scaling.to_xml(xml)
  xml.delete :val=>0
  xml.axPos :val=>@axPos
  xml.majorGridlines
  xml.numFmt :formatCode => @format_code, :sourceLinked=>"1"
  xml.majorTickMark :val=>"none"
  xml.minorTickMark :val=>"none"
  xml.tickLblPos :val=>@tickLblPos
  xml.crossAx :val=>@crossAx
  xml.crosses :val=>@crosses
end