summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/axis.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-06-11 08:45:37 +0900
committerRandy Morgan <[email protected]>2012-06-11 08:45:37 +0900
commit68f0b530e2260ceacf2ed916e216eaec5da60945 (patch)
tree63045ae99fc3abd33e4fde341f73e86af6655969 /lib/axlsx/drawing/axis.rb
parente693d2b1933797e18cc1cdd3cba793630e8ecb25 (diff)
downloadcaxlsx-68f0b530e2260ceacf2ed916e216eaec5da60945.tar.gz
caxlsx-68f0b530e2260ceacf2ed916e216eaec5da60945.zip
add title object to axis.
Diffstat (limited to 'lib/axlsx/drawing/axis.rb')
-rw-r--r--lib/axlsx/drawing/axis.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/axlsx/drawing/axis.rb b/lib/axlsx/drawing/axis.rb
index 84713943..1da3e430 100644
--- a/lib/axlsx/drawing/axis.rb
+++ b/lib/axlsx/drawing/axis.rb
@@ -52,6 +52,9 @@ module Axlsx
# @return [Boolean]
attr_reader :delete
+ # the title for the axis. This can be a cell or a fixed string.
+ attr_reader :title
+
# Creates an Axis object
# @param [Integer] ax_id the id of this axis
# @param [Integer] cross_ax the id of the perpendicular axis
@@ -67,6 +70,7 @@ module Axlsx
@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"
@@ -113,6 +117,19 @@ module Axlsx
@label_rotation = adjusted
end
+
+ # The title object for the chart.
+ # @param [String, Cell] v
+ # @return [Title]
+ def title=(v)
+ DataTypeValidator.validate "#{self.class}.title", [String, Cell], v
+ @title ||= Title.new
+ if v.is_a?(String)
+ @title.text = v
+ elsif v.is_a?(Cell)
+ @title.cell = v
+ end
+ end
# Serializes the object
# @param [String] str
@@ -131,6 +148,7 @@ module Axlsx
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"/>'