Skip to content

Commit

Permalink
adding in quick patch for catAxis, valAxis on charts to specify gridl…
Browse files Browse the repository at this point in the history
…ines = false. Needs specs once I work out what the hell happened to nokogiri in 1.5.1
  • Loading branch information
Randy Morgan committed Mar 9, 2012
1 parent 5befcc4 commit 94663f5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions axlsx.gemspec
Expand Up @@ -24,8 +24,8 @@ Gem::Specification.new do |s|

s.add_runtime_dependency 'rubyzip', '~> 0.9'

s.add_runtime_dependency 'rake', "0.8.7" if RUBY_VERSION == "1.9.2"
s.add_runtime_dependency 'rake', ">= 0.8.7" if ["1.9.3", "1.8.7"].include?(RUBY_VERSION)
s.add_runtime_dependency 'rake', '0.8.7' if RUBY_VERSION == "1.9.2"
s.add_runtime_dependency 'rake', '>= 0.8.7' if ["1.9.3", "1.8.7"].include?(RUBY_VERSION)
s.add_development_dependency 'yard'
s.add_development_dependency 'yard'
s.add_development_dependency 'rdiscount'
Expand Down
29 changes: 23 additions & 6 deletions lib/axlsx/drawing/axis.rb
Expand Up @@ -3,7 +3,7 @@ module Axlsx
# the access class defines common properties and values for a chart axis.
class Axis

# the id of the axis.
# the id of the axis.
# @return [Integer]
attr_reader :axId

Expand All @@ -15,7 +15,7 @@ class Axis
# @see Scaling
# @return [Scaling]
attr_reader :scaling

# The position of the axis
# must be one of [:l, :r, :t, :b]
# @return [Symbol]
Expand All @@ -34,7 +34,11 @@ class Axis
# specifies how the perpendicular axis is crossed
# must be one of [:autoZero, :min, :max]
# @return [Symbol]
attr_reader :crosses
attr_reader :crosses

# specifies if gridlines should be shown in the chart
# @return [Boolean]
attr_reader :gridlines

# Creates an Axis object
# @param [Integer] axId the id of this axis
Expand All @@ -49,11 +53,12 @@ def initialize(axId, crossAx, options={})
@axId = axId
@crossAx = crossAx
@format_code = "General"
@scaling = Scaling.new(:orientation=>:minMax)
@scaling = Scaling.new(:orientation=>:minMax)
self.axPos = :b
self.tickLblPos = :nextTo
self.format_code = "General"
self.crosses = :autoZero
self.gridlines = true
options.each do |o|
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
end
Expand All @@ -70,6 +75,10 @@ def tickLblPos=(v) RestrictionValidator.validate "#{self.class}.tickLblPos", [:n
# default :General
def format_code=(v) Axlsx::validate_string(v); @format_code = v; end

# Specify if gridlines should be shown for this axis
# default true
def gridlines=(v) Axlsx::validate_boolean(v); @gridlines = 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
Expand All @@ -82,13 +91,21 @@ def to_xml(xml)
@scaling.to_xml(xml)
xml.delete :val=>0
xml.axPos :val=>@axPos
xml.majorGridlines
xml.majorGridlines {
if self.gridlines == false
xml.spPr {
xml[:a].ln {
xml[:a].noFill
}
}
end
}
xml.numFmt :formatCode => @format_code, :sourceLinked=>"1"
xml.majorTickMark :val=>"none"
xml.minorTickMark :val=>"none"
xml.tickLblPos :val=>@tickLblPos
xml.crossAx :val=>@crossAx
xml.crosses :val=>@crosses
end
end
end
end
1 change: 0 additions & 1 deletion test/tc_package.rb
Expand Up @@ -109,6 +109,5 @@ def test_content_type_added_with_shared_strings
def test_name_to_indices
assert(Axlsx::name_to_indices('A1') == [0,0])
assert(Axlsx::name_to_indices('A100') == [0,99], 'needs to axcept rows that contain 0')

end
end

0 comments on commit 94663f5

Please sign in to comment.