summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/cat_axis.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-04-01 00:35:26 +0900
committerRandy Morgan <[email protected]>2012-04-01 00:35:26 +0900
commit22a341841f191a5aa00e87b1f166b4f25cc67f0a (patch)
tree505f46708d5cac7d33d0dd6679c125e2eb819075 /lib/axlsx/drawing/cat_axis.rb
parentbb2117ba17297e02a0fc6d5ad5a22462e72a9a79 (diff)
downloadcaxlsx-22a341841f191a5aa00e87b1f166b4f25cc67f0a.tar.gz
caxlsx-22a341841f191a5aa00e87b1f166b4f25cc67f0a.zip
part way through changing all serialization to use string concatenation prior to dropping Nokogiri dep in production.
Diffstat (limited to 'lib/axlsx/drawing/cat_axis.rb')
-rw-r--r--lib/axlsx/drawing/cat_axis.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/axlsx/drawing/cat_axis.rb b/lib/axlsx/drawing/cat_axis.rb
index ee408c56..242ae698 100644
--- a/lib/axlsx/drawing/cat_axis.rb
+++ b/lib/axlsx/drawing/cat_axis.rb
@@ -10,7 +10,7 @@ module Axlsx
# specifies how the perpendicular axis is crossed
# must be one of [:ctr, :l, :r]
# @return [Symbol]
- attr_reader :lblAlgn
+ attr_reader :lblAlgn
# The offset of the labels
# must be between a string between 0 and 1000
@@ -20,7 +20,7 @@ module Axlsx
# regex for validating label offset
LBL_OFFSET_REGEX = /0*(([0-9])|([1-9][0-9])|([1-9][0-9][0-9])|1000)%/
- # Creates a new CatAxis object
+ # Creates a new CatAxis object
# @param [Integer] axId the id of this axis. Inherited
# @param [Integer] crossAx the id of the perpendicular axis. Inherited
# @option options [Symbol] axPos. Inherited
@@ -28,13 +28,13 @@ module Axlsx
# @option options [Symbol] crosses. Inherited
# @option options [Boolean] auto
# @option options [Symbol] lblAlgn
- # @option options [Integer] lblOffset
+ # @option options [Integer] lblOffset
def initialize(axId, crossAx, options={})
self.auto = 1
self.lblAlgn = :ctr
self.lblOffset = "100%"
super(axId, crossAx, options)
- end
+ end
# From the docs: This element specifies that this axis is a date or text axis based on the data that is used for the axis labels, not a specific choice.
def auto=(v) Axlsx::validate_boolean(v); @auto = v; end
@@ -47,6 +47,14 @@ module Axlsx
# must be between a string between 0 and 1000
def lblOffset=(v) RegexValidator.validate "#{self.class}.lblOffset", LBL_OFFSET_REGEX, v; @lblOffset = v; end
+
+ def to_xml_string(str = '')
+ str << '<catAx>'
+ super(str)
+ str << '<auto val="' << @auto.to_s << '</auto>'
+ str << '</catAx>'
+ end
+
# Serializes the category axis
# @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
# @return [String]
@@ -59,6 +67,6 @@ module Axlsx
}
end
end
-
+
end