diff options
| author | Randy Morgan <[email protected]> | 2012-04-25 20:30:24 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-04-25 20:30:24 +0900 |
| commit | 672aae6fd76c761006868c42062e153e56da2a09 (patch) | |
| tree | ad570fda83c7d4a818518e59e7c01a4780e047d6 /lib/axlsx/drawing/axis.rb | |
| parent | bb9d3279c500164e9a958c168ca3bea5e4e6d76c (diff) | |
| download | caxlsx-672aae6fd76c761006868c42062e153e56da2a09.tar.gz caxlsx-672aae6fd76c761006868c42062e153e56da2a09.zip | |
label rotation and conditional formatting examples
Diffstat (limited to 'lib/axlsx/drawing/axis.rb')
| -rw-r--r-- | lib/axlsx/drawing/axis.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/axlsx/drawing/axis.rb b/lib/axlsx/drawing/axis.rb index 9206e848..ea093391 100644 --- a/lib/axlsx/drawing/axis.rb +++ b/lib/axlsx/drawing/axis.rb @@ -36,6 +36,10 @@ module Axlsx # @return [Symbol] attr_reader :crosses + # specifies how the degree of label rotation + # @return [Integer] + attr_reader :label_rotation + # specifies if gridlines should be shown in the chart # @return [Boolean] attr_reader :gridlines @@ -53,6 +57,7 @@ module Axlsx @axId = axId @crossAx = crossAx @format_code = "General" + @label_rotation = 0 @scaling = Scaling.new(:orientation=>:minMax) self.axPos = :b self.tickLblPos = :nextTo @@ -83,6 +88,15 @@ module Axlsx # must be one of [:autoZero, :min, :max] def crosses=(v) RestrictionValidator.validate "#{self.class}.crosses", [:autoZero, :min, :max], v; @crosses = v; end + # Specify the degree of label rotation to apply to labels + # default true + def label_rotation=(v) + Axlsx::validate_int(v) + adjusted = v.to_i * 60000 + Axlsx::validate_angle(adjusted) + @label_rotation = adjusted + end + # Serializes the object # @param [String] str @@ -105,6 +119,8 @@ module Axlsx 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}'/><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 |
