From 68f0b530e2260ceacf2ed916e216eaec5da60945 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Mon, 11 Jun 2012 08:45:37 +0900 Subject: add title object to axis. --- lib/axlsx/drawing/axis.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib') 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 << '' end str << '' + @title.to_xml_string(str) unless @title == nil str << '' str << '' str << '' -- cgit v1.2.3