summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-05-03 20:17:49 +0900
committerRandy Morgan <[email protected]>2012-05-03 20:17:49 +0900
commit55f3ade0b2fc64d414cb9a1c3bbdcb90bbe1289b (patch)
treea2b7cc2ca957ed2d5294fc15c40f789859c710bd /lib/axlsx
parente77c6ea64df17814c4a9820822d585c28ee6cc43 (diff)
downloadcaxlsx-55f3ade0b2fc64d414cb9a1c3bbdcb90bbe1289b.tar.gz
caxlsx-55f3ade0b2fc64d414cb9a1c3bbdcb90bbe1289b.zip
add support for axis delete, cat axis tickLblSkip and tickMarkSkip with sensible defaults. Improve chart positioning defaults.
Diffstat (limited to 'lib/axlsx')
-rw-r--r--lib/axlsx/drawing/axis.rb13
-rw-r--r--lib/axlsx/drawing/cat_axis.rb24
-rw-r--r--lib/axlsx/drawing/chart.rb10
-rw-r--r--lib/axlsx/drawing/ser_axis.rb2
4 files changed, 42 insertions, 7 deletions
diff --git a/lib/axlsx/drawing/axis.rb b/lib/axlsx/drawing/axis.rb
index 9d6a54c6..1e16dee6 100644
--- a/lib/axlsx/drawing/axis.rb
+++ b/lib/axlsx/drawing/axis.rb
@@ -44,6 +44,10 @@ module Axlsx
# @return [Boolean]
attr_reader :gridlines
+ # specifies if gridlines should be shown in the chart
+ # @return [Boolean]
+ attr_reader :delete
+
# Creates an Axis object
# @param [Integer] axId the id of this axis
# @param [Integer] crossAx the id of the perpendicular axis
@@ -57,7 +61,7 @@ module Axlsx
@axId = axId
@crossAx = crossAx
@format_code = "General"
- @label_rotation = 0
+ @delete = @label_rotation = 0
@scaling = Scaling.new(:orientation=>:minMax)
self.axPos = :b
self.tickLblPos = :nextTo
@@ -84,6 +88,11 @@ module Axlsx
# default true
def gridlines=(v) Axlsx::validate_boolean(v); @gridlines = v; end
+
+ # Specify if axis should be removed from the chart
+ # default false
+ def delete=(v) Axlsx::validate_boolean(v); @delete = v; end
+
# specifies how the perpendicular axis is crossed
# must be one of [:autoZero, :min, :max]
def crosses=(v) RestrictionValidator.validate "#{self.class}.crosses", [:autoZero, :min, :max], v; @crosses = v; end
@@ -104,7 +113,7 @@ module Axlsx
def to_xml_string(str = '')
str << '<c:axId val="' << @axId.to_s << '"/>'
@scaling.to_xml_string str
- str << '<c:delete val="0"/>'
+ str << '<c:delete val="'<< @delete.to_s << '"/>'
str << '<c:axPos val="' << @axPos.to_s << '"/>'
str << '<c:majorGridlines>'
if self.gridlines == false
diff --git a/lib/axlsx/drawing/cat_axis.rb b/lib/axlsx/drawing/cat_axis.rb
index a961d736..6def7349 100644
--- a/lib/axlsx/drawing/cat_axis.rb
+++ b/lib/axlsx/drawing/cat_axis.rb
@@ -17,6 +17,16 @@ module Axlsx
# @return [Integer]
attr_reader :lblOffset
+
+ # The number of tick lables to skip between labels
+ # @return [Integer]
+ attr_reader :tickLblSkip
+
+ # The number of tickmarks to be skipped before the next one is rendered.
+ # @return [Boolean]
+ attr_reader :tickMarkSkip
+
+
# regex for validating label offset
LBL_OFFSET_REGEX = /0*(([0-9])|([1-9][0-9])|([1-9][0-9][0-9])|1000)%/
@@ -29,13 +39,25 @@ module Axlsx
# @option options [Boolean] auto
# @option options [Symbol] lblAlgn
# @option options [Integer] lblOffset
+ # @option options [Integer] tickLblSkip
+ # @option options [Integer] tickMarkSkip
def initialize(axId, crossAx, options={})
+ @tickLblSkip = 1
+ @tickMarkSkip = 1
self.auto = 1
self.lblAlgn = :ctr
self.lblOffset = "100%"
super(axId, crossAx, options)
end
+
+ # @see tickLblSkip
+ def tickLblSkip=(v) Axlsx::validate_unsigned_int(v); @tickLblSkip = v; end
+
+ # @see tickMarkSkip
+ def tickMarkSkip=(v) Axlsx::validate_unsigned_int(v); @tickMarkSkip = v; 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
@@ -56,6 +78,8 @@ module Axlsx
str << '<c:auto val="' << @auto.to_s << '"/>'
str << '<c:lblAlgn val="' << @lblAlgn.to_s << '"/>'
str << '<c:lblOffset val="' << @lblOffset.to_s << '"/>'
+ str << '<c:tickLblSkip val="' << @tickLblSkip.to_s << '"/>'
+ str << '<c:tickMarkSkip val="' << @tickMarkSkip.to_s << '"/>'
str << '</c:catAx>'
end
diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb
index 5f14dde8..0f26c551 100644
--- a/lib/axlsx/drawing/chart.rb
+++ b/lib/axlsx/drawing/chart.rb
@@ -41,6 +41,8 @@ module Axlsx
# @param [GraphicalFrame] frame The frame that holds this chart.
# @option options [Cell, String] title
# @option options [Boolean] show_legend
+ # @option options [Array|String|Cell] start_at The X, Y coordinates defining the top left corner of the chart.
+ # @option options [Array|String|Cell] end_at The X, Y coordinates defining the bottom right corner of the chart.
def initialize(frame, options={})
@style = 2
@view3D = nil
@@ -153,7 +155,7 @@ module Axlsx
# @param [Integer] x The column
# @param [Integer] y The row
# @return [Marker]
- def start_at(x, y=0)
+ def start_at(x=0, y=0)
x, y = *parse_coord_args(x, y)
@graphic_frame.anchor.from.col = x
@graphic_frame.anchor.from.row = y
@@ -162,10 +164,10 @@ module Axlsx
# This is a short cut method to set the end anchor position
# If you need finer granularity in positioning use
# graphic_frame.anchor.to.colOff / rowOff
- # @param [Integer] x The column
- # @param [Integer] y The row
+ # @param [Integer] x The column - default 10
+ # @param [Integer] y The row - default 10
# @return [Marker]
- def end_at(x, y=0)
+ def end_at(x=10, y=10)
x, y = *parse_coord_args(x, y)
@graphic_frame.anchor.to.col = x
@graphic_frame.anchor.to.row = y
diff --git a/lib/axlsx/drawing/ser_axis.rb b/lib/axlsx/drawing/ser_axis.rb
index 703786e5..00b04989 100644
--- a/lib/axlsx/drawing/ser_axis.rb
+++ b/lib/axlsx/drawing/ser_axis.rb
@@ -20,7 +20,7 @@ module Axlsx
# @option options [Integer] tickLblSkip
# @option options [Integer] tickMarkSkip
def initialize(axId, crossAx, options={})
- @tickLblSkip, @tickMarkSkip = nil, nil
+ @tickLblSkip, @tickMarkSkip = 1, 1
super(axId, crossAx, options)
end