diff options
| author | mfrank01 <[email protected]> | 2014-07-29 16:11:38 -0600 |
|---|---|---|
| committer | mfrank01 <[email protected]> | 2014-07-29 16:21:37 -0600 |
| commit | 1aed4d61f773fb24d198d643ae4ae062e2789620 (patch) | |
| tree | 8bb6c71a1fddd8e87420fe04130ec44cc6655dd9 /lib | |
| parent | 2aec0203fcca35dcecd5dca5e9081bc6090f5e8b (diff) | |
| download | caxlsx-1aed4d61f773fb24d198d643ae4ae062e2789620.tar.gz caxlsx-1aed4d61f773fb24d198d643ae4ae062e2789620.zip | |
Allow custom marker symbol shapes on chart
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/drawing/line_series.rb | 19 | ||||
| -rw-r--r-- | lib/axlsx/util/validators.rb | 4 |
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/axlsx/drawing/line_series.rb b/lib/axlsx/drawing/line_series.rb index 50df27b8..55b5245d 100644 --- a/lib/axlsx/drawing/line_series.rb +++ b/lib/axlsx/drawing/line_series.rb @@ -23,6 +23,10 @@ module Axlsx # @return [Boolean] attr_reader :show_marker + # custom marker symbol + # @return [String] + attr_reader :marker_symbol + # line smoothing on values # @return [Boolean] attr_reader :smooth @@ -33,6 +37,7 @@ module Axlsx # @param [Chart] chart def initialize(chart, options={}) @show_marker = false + @marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default @smooth = false @labels, @data = nil, nil super(chart, options) @@ -51,6 +56,12 @@ module Axlsx @show_marker = v end + # @see marker_symbol + def marker_symbol(v) + Axlsx::validate_marker_symbol(v) + @marker_symbol = v + end + # @see smooth def smooth=(v) Axlsx::validate_boolean(v) @@ -74,7 +85,13 @@ module Axlsx str << '<a:round/>' str << '</c:spPr>' end - str << '<c:marker><c:symbol val="none"/></c:marker>' unless @show_marker + + if !@show_marker + str << '<c:marker><c:symbol val="none"/></c:marker>' + elsif @marker_symbol != :default + str << '<c:marker><c:symbol val="' + @marker_symbol.to_s + '"/></c:marker>' + end + @labels.to_xml_string(str) unless @labels.nil? @data.to_xml_string(str) unless @data.nil? str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') diff --git a/lib/axlsx/util/validators.rb b/lib/axlsx/util/validators.rb index c9ee2e6e..9c6f34aa 100644 --- a/lib/axlsx/util/validators.rb +++ b/lib/axlsx/util/validators.rb @@ -304,4 +304,8 @@ module Axlsx RestrictionValidator.validate :visibility, [:visible, :hidden, :very_hidden], v end + # Requires that the value is one of :default, :circle, :dash, :diamond, :dot, :picture, :plus, :square, :star, :triangle, :x + def self.validate_marker_symbol(v) + RestrictionValidator.validate :marker_symbol, [:default, :circle, :dash, :diamond, :dot, :picture, :plus, :square, :star, :triangle, :x], v + end end |
