Class: Axlsx::Axis
- Inherits:
-
Object
- Object
- Axlsx::Axis
- Defined in:
- lib/axlsx/drawing/axis.rb
Overview
the access class defines common properties and values for a chart axis.
Instance Attribute Summary collapse
-
#axId ⇒ Integer
readonly
the id of the axis.
-
#axPos ⇒ Symbol
The position of the axis must be one of [:l, :r, :t, :b].
-
#crossAx ⇒ Integer
readonly
The perpendicular axis.
-
#crosses ⇒ Symbol
specifies how the perpendicular axis is crossed must be one of [:autoZero, :min, :max].
-
#format_code ⇒ String
The number format format code for this axis default :General.
-
#gridlines ⇒ Boolean
specifies if gridlines should be shown in the chart.
-
#scaling ⇒ Scaling
readonly
The scaling of the axis.
-
#tickLblPos ⇒ Symbol
the position of the tick labels must be one of [:nextTo, :high, :low].
Instance Method Summary collapse
-
#initialize(axId, crossAx, options = {}) ⇒ Axis
constructor
Creates an Axis object.
-
#to_xml_string(str = '') ⇒ String
Serializes the object.
Constructor Details
#initialize(axId, crossAx, options = {}) ⇒ Axis
Creates an Axis object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/axlsx/drawing/axis.rb', line 50 def initialize(axId, crossAx, ={}) 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 self.gridlines = true .each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end end |
Instance Attribute Details
#axId ⇒ Integer (readonly)
the id of the axis.
8 9 10 |
# File 'lib/axlsx/drawing/axis.rb', line 8 def axId @axId end |
#axPos ⇒ Symbol
The position of the axis must be one of [:l, :r, :t, :b]
22 23 24 |
# File 'lib/axlsx/drawing/axis.rb', line 22 def axPos @axPos end |
#crossAx ⇒ Integer (readonly)
The perpendicular axis
12 13 14 |
# File 'lib/axlsx/drawing/axis.rb', line 12 def crossAx @crossAx end |
#crosses ⇒ Symbol
specifies how the perpendicular axis is crossed must be one of [:autoZero, :min, :max]
37 38 39 |
# File 'lib/axlsx/drawing/axis.rb', line 37 def crosses @crosses end |
#format_code ⇒ String
The number format format code for this axis default :General
32 33 34 |
# File 'lib/axlsx/drawing/axis.rb', line 32 def format_code @format_code end |
#gridlines ⇒ Boolean
specifies if gridlines should be shown in the chart
41 42 43 |
# File 'lib/axlsx/drawing/axis.rb', line 41 def gridlines @gridlines end |
#scaling ⇒ Scaling (readonly)
The scaling of the axis
17 18 19 |
# File 'lib/axlsx/drawing/axis.rb', line 17 def scaling @scaling end |
#tickLblPos ⇒ Symbol
the position of the tick labels must be one of [:nextTo, :high, :low]
27 28 29 |
# File 'lib/axlsx/drawing/axis.rb', line 27 def tickLblPos @tickLblPos end |
Instance Method Details
#to_xml_string(str = '') ⇒ String
Serializes the object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/axlsx/drawing/axis.rb', line 90 def to_xml_string(str = '') str << '<c:axId val="' << @axId.to_s << '"/>' @scaling.to_xml_string str str << '<c:delete val="0"/>' str << '<c:axPos val="' << @axPos.to_s << '"/>' str << '<c:majorGridlines>' if self.gridlines == false str << '<c:spPr>' str << '<a:ln>' str << '<a:noFill/>' str << '</a:ln>' str << '</c:spPr>' end str << '</c:majorGridlines>' str << '<c:numFmt formatCode="' << @format_code << '" sourceLinked="1"/>' str << '<c:majorTickMark val="none"/>' str << '<c:minorTickMark val="none"/>' str << '<c:tickLblPos val="' << @tickLblPos.to_s << '"/>' str << '<c:crossAx val="' << @crossAx.to_s << '"/>' str << '<c:crosses val="' << @crosses.to_s << '"/>' end |