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].
-
#delete ⇒ Boolean
specifies if gridlines should be shown in the chart.
-
#format_code ⇒ String
The number format format code for this axis default :General.
-
#gridlines ⇒ Boolean
specifies if gridlines should be shown in the chart.
-
#label_rotation ⇒ Integer
specifies how the degree of label rotation.
-
#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
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/axlsx/drawing/axis.rb', line 58 def initialize(axId, crossAx, ={}) Axlsx::validate_unsigned_int(axId) Axlsx::validate_unsigned_int(crossAx) @axId = axId @crossAx = crossAx @format_code = "General" @delete = @label_rotation = 0 @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 |
#delete ⇒ Boolean
specifies if gridlines should be shown in the chart
49 50 51 |
# File 'lib/axlsx/drawing/axis.rb', line 49 def delete @delete 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
45 46 47 |
# File 'lib/axlsx/drawing/axis.rb', line 45 def gridlines @gridlines end |
#label_rotation ⇒ Integer
specifies how the degree of label rotation
41 42 43 |
# File 'lib/axlsx/drawing/axis.rb', line 41 def label_rotation @label_rotation 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
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/axlsx/drawing/axis.rb', line 113 def to_xml_string(str = '') str << '<c:axId val="' << @axId.to_s << '"/>' @scaling.to_xml_string str str << '<c:delete val="'<< @delete.to_s << '"/>' 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 << '"/>' # some potential value in implementing this in full. Very detailed! str << '<c:txPr><a:bodyPr rot="' << @label_rotation.to_s << '"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr/></a:p></c:txPr>' str << '<c:crossAx val="' << @crossAx.to_s << '"/>' str << '<c:crosses val="' << @crosses.to_s << '"/>' end |