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
-
#ax_id ⇒ Integer
(also: #axID)
readonly
the id of the axis.
-
#ax_pos ⇒ Symbol
(also: #axPos)
The position of the axis must be one of [:l, :r, :t, :b].
-
#cross_ax ⇒ Integer
(also: #crossAx)
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.
-
#tick_lbl_pos ⇒ Symbol
(also: #tickLblPos)
the position of the tick labels must be one of [:nextTo, :high, :low].
-
#title ⇒ Object
the title for the axis.
Instance Method Summary collapse
-
#initialize(ax_id, cross_ax, options = {}) ⇒ Axis
constructor
Creates an Axis object.
-
#to_xml_string(str = '') ⇒ String
Serializes the object.
Constructor Details
#initialize(ax_id, cross_ax, options = {}) ⇒ Axis
Creates an Axis object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/axlsx/drawing/axis.rb', line 65 def initialize(ax_id, cross_ax, ={}) Axlsx::validate_unsigned_int(ax_id) Axlsx::validate_unsigned_int(cross_ax) @ax_id = ax_id @cross_ax = cross_ax @format_code = "General" @delete = @label_rotation = 0 @scaling = Scaling.new(:orientation=>:minMax) @title = nil self.ax_pos = :b self.tick_lbl_pos = :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
#ax_id ⇒ Integer (readonly) Also known as: axID
the id of the axis.
8 9 10 |
# File 'lib/axlsx/drawing/axis.rb', line 8 def ax_id @ax_id end |
#ax_pos ⇒ Symbol Also known as: axPos
The position of the axis must be one of [:l, :r, :t, :b]
24 25 26 |
# File 'lib/axlsx/drawing/axis.rb', line 24 def ax_pos @ax_pos end |
#cross_ax ⇒ Integer (readonly) Also known as: crossAx
The perpendicular axis
13 14 15 |
# File 'lib/axlsx/drawing/axis.rb', line 13 def cross_ax @cross_ax end |
#crosses ⇒ Symbol
specifies how the perpendicular axis is crossed must be one of [:autoZero, :min, :max]
41 42 43 |
# File 'lib/axlsx/drawing/axis.rb', line 41 def crosses @crosses end |
#delete ⇒ Boolean
specifies if gridlines should be shown in the chart
53 54 55 |
# File 'lib/axlsx/drawing/axis.rb', line 53 def delete @delete end |
#format_code ⇒ String
The number format format code for this axis default :General
36 37 38 |
# File 'lib/axlsx/drawing/axis.rb', line 36 def format_code @format_code end |
#gridlines ⇒ Boolean
specifies if gridlines should be shown in the chart
49 50 51 |
# File 'lib/axlsx/drawing/axis.rb', line 49 def gridlines @gridlines end |
#label_rotation ⇒ Integer
specifies how the degree of label rotation
45 46 47 |
# File 'lib/axlsx/drawing/axis.rb', line 45 def label_rotation @label_rotation end |
#scaling ⇒ Scaling (readonly)
The scaling of the axis
19 20 21 |
# File 'lib/axlsx/drawing/axis.rb', line 19 def scaling @scaling end |
#tick_lbl_pos ⇒ Symbol Also known as: tickLblPos
the position of the tick labels must be one of [:nextTo, :high, :low]
30 31 32 |
# File 'lib/axlsx/drawing/axis.rb', line 30 def tick_lbl_pos @tick_lbl_pos end |
#title ⇒ Object
the title for the axis. This can be a cell or a fixed string.
56 57 58 |
# File 'lib/axlsx/drawing/axis.rb', line 56 def title @title end |
Instance Method Details
#to_xml_string(str = '') ⇒ String
Serializes the object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/axlsx/drawing/axis.rb', line 137 def to_xml_string(str = '') str << '<c:axId val="' << @ax_id.to_s << '"/>' @scaling.to_xml_string str str << '<c:delete val="'<< @delete.to_s << '"/>' str << '<c:axPos val="' << @ax_pos.to_s << '"/>' str << '<c:majorGridlines>' if gridlines == false str << '<c:spPr>' str << '<a:ln>' str << '<a:noFill/>' str << '</a:ln>' str << '</c:spPr>' end str << '</c:majorGridlines>' @title.to_xml_string(str) unless @title == nil str << '<c:numFmt formatCode="' << @format_code << '" sourceLinked="1"/>' str << '<c:majorTickMark val="none"/>' str << '<c:minorTickMark val="none"/>' str << '<c:tickLblPos val="' << @tick_lbl_pos.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="' << @cross_ax.to_s << '"/>' str << '<c:crosses val="' << @crosses.to_s << '"/>' end |