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)
-
- (Integer) axId
readonly
the id of the axis.
-
- (Symbol) axPos
The position of the axis must be one of [:l, :r, :t, :b].
-
- (Integer) crossAx
readonly
The perpendicular axis.
-
- (Symbol) crosses
specifies how the perpendicular axis is crossed must be one of [:autoZero, :min, :max].
-
- (Boolean) delete
specifies if gridlines should be shown in the chart.
-
- (String) format_code
The number format format code for this axis default :General.
-
- (Boolean) gridlines
specifies if gridlines should be shown in the chart.
-
- (Integer) label_rotation
specifies how the degree of label rotation.
-
- (Scaling) scaling
readonly
The scaling of the axis.
-
- (Symbol) tickLblPos
the position of the tick labels must be one of [:nextTo, :high, :low].
Instance Method Summary (collapse)
-
- (Axis) initialize(axId, crossAx, options = {})
constructor
Creates an Axis object.
-
- (String) to_xml_string(str = '')
Serializes the object.
Constructor Details
- (Axis) initialize(axId, crossAx, options = {})
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
- (Integer) axId (readonly)
the id of the axis.
8 9 10 |
# File 'lib/axlsx/drawing/axis.rb', line 8 def axId @axId end |
- (Symbol) axPos
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 |
- (Integer) crossAx (readonly)
The perpendicular axis
12 13 14 |
# File 'lib/axlsx/drawing/axis.rb', line 12 def crossAx @crossAx end |
- (Symbol) crosses
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 |
- (Boolean) delete
specifies if gridlines should be shown in the chart
49 50 51 |
# File 'lib/axlsx/drawing/axis.rb', line 49 def delete @delete end |
- (String) format_code
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 |
- (Boolean) gridlines
specifies if gridlines should be shown in the chart
45 46 47 |
# File 'lib/axlsx/drawing/axis.rb', line 45 def gridlines @gridlines end |
- (Integer) label_rotation
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 |
- (Symbol) tickLblPos
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
- (String) to_xml_string(str = '')
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 |