diff options
| author | Jurriaan Pruis <[email protected]> | 2015-03-14 16:11:38 +0100 |
|---|---|---|
| committer | Jurriaan Pruis <[email protected]> | 2015-03-14 16:11:38 +0100 |
| commit | 05c9faa89da35ba01ece50c2951739b579478993 (patch) | |
| tree | 6e46c7be1704e0fad06099584d9e48cea5b25cbb /lib | |
| parent | e6b0228fb441fe31eaa09b747f3c3e76ff629dee (diff) | |
| parent | 9a5c96c8c21424a8737245f8a51a4693b4deb38c (diff) | |
| download | caxlsx-05c9faa89da35ba01ece50c2951739b579478993.tar.gz caxlsx-05c9faa89da35ba01ece50c2951739b579478993.zip | |
Merge pull request #347 from ionthegeek/smoothing
Add support for enabling or disabling smoothed lines in a scatter series
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/drawing/scatter_series.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/axlsx/drawing/scatter_series.rb b/lib/axlsx/drawing/scatter_series.rb index 28962230..c0d6e8f1 100644 --- a/lib/axlsx/drawing/scatter_series.rb +++ b/lib/axlsx/drawing/scatter_series.rb @@ -21,9 +21,21 @@ module Axlsx # @return [String] attr_reader :color + # Line smoothing between data points + # @return [Boolean] + attr_reader :smooth + # Creates a new ScatterSeries def initialize(chart, options={}) @xData, @yData = nil + if options[:smooth].nil? + # If caller hasn't specified smoothing or not, turn smoothing on or off based on scatter style + @smooth = [:smooth, :smoothMarker].include?(chart.scatter_style) + else + # Set smoothing according to the option provided + Axlsx::validate_boolean(options[:smooth]) + @smooth = options[:smooth] + end super(chart, options) @xData = AxDataSource.new(:tag_name => :xVal, :data => options[:xData]) unless options[:xData].nil? @yData = NumDataSource.new({:tag_name => :yVal, :data => options[:yData]}) unless options[:yData].nil? @@ -34,6 +46,12 @@ module Axlsx @color = v end + # @see smooth + def smooth=(v) + Axlsx::validate_boolean(v) + @smooth = v + end + # Serializes the object # @param [String] str # @return [String] @@ -58,6 +76,7 @@ module Axlsx end @xData.to_xml_string(str) unless @xData.nil? @yData.to_xml_string(str) unless @yData.nil? + str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>') end str end |
