diff options
| author | Randy Morgan <[email protected]> | 2013-03-17 15:38:55 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2013-03-17 15:38:55 +0900 |
| commit | ae75ef360e3e0da253188d408a3cbc81ed3897e6 (patch) | |
| tree | 9bf184d72c4a78b3f14731af511aad26002a51ad /lib/axlsx/drawing/axis.rb | |
| parent | 17f135ab215ba05b85ef92a15ed0038ea7556de9 (diff) | |
| download | caxlsx-ae75ef360e3e0da253188d408a3cbc81ed3897e6.tar.gz caxlsx-ae75ef360e3e0da253188d408a3cbc81ed3897e6.zip | |
Fixed LineChart and refactored chart axes management
Diffstat (limited to 'lib/axlsx/drawing/axis.rb')
| -rw-r--r-- | lib/axlsx/drawing/axis.rb | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/axlsx/drawing/axis.rb b/lib/axlsx/drawing/axis.rb index 1b55bece..16c087a2 100644 --- a/lib/axlsx/drawing/axis.rb +++ b/lib/axlsx/drawing/axis.rb @@ -7,17 +7,13 @@ module Axlsx include Axlsx::OptionsParser # Creates an Axis object - # @param [Integer] ax_id the id of this axis - # @param [Integer] cross_ax the id of the perpendicular axis + # @param [Integer] cross_axis the perpendicular axis # @option options [Symbol] ax_pos # @option options [Symbol] crosses # @option options [Symbol] tick_lbl_pos # @raise [ArgumentError] If axi_id or cross_ax are not unsigned integers - def initialize(ax_id, cross_ax, options={}) - Axlsx::validate_unsigned_int(ax_id) - Axlsx::validate_unsigned_int(cross_ax) - @ax_id = ax_id - @cross_ax = cross_ax + def initialize(options={}) + @id = rand(8 ** 8) @format_code = "General" @delete = @label_rotation = 0 @scaling = Scaling.new(:orientation=>:minMax) @@ -37,13 +33,13 @@ module Axlsx # the id of the axis. # @return [Integer] - attr_reader :ax_id - alias :axID :ax_id + attr_reader :id + alias :axID :id # The perpendicular axis # @return [Integer] - attr_reader :cross_ax - alias :crossAx :cross_ax + attr_reader :cross_axis + alias :crossAx :cross_axis # The scaling of the axis # @see Scaling @@ -95,6 +91,11 @@ module Axlsx @color = color_rgb end + def cross_axis=(axis) + DataTypeValidator.validate "#{self.class}.cross_axis", [Axis], axis + @cross_axis = axis + end + # The position of the axis # must be one of [:l, :r, :t, :b] def ax_pos=(v) RestrictionValidator.validate "#{self.class}.ax_pos", [:l, :r, :b, :t], v; @ax_pos = v; end @@ -147,7 +148,7 @@ module Axlsx # @param [String] str # @return [String] def to_xml_string(str = '') - str << '<c:axId val="' << @ax_id.to_s << '"/>' + str << '<c:axId val="' << @id.to_s << '"/>' @scaling.to_xml_string str str << '<c:delete val="'<< @delete.to_s << '"/>' str << '<c:axPos val="' << @ax_pos.to_s << '"/>' @@ -175,7 +176,7 @@ module Axlsx end # 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:crossAx val="' << @cross_axis.id.to_s << '"/>' str << '<c:crosses val="' << @crosses.to_s << '"/>' end |
