From 8dd92ebff726f60fbd31f5f0dcb05849745dea39 Mon Sep 17 00:00:00 2001 From: Oleg Yakovenko Date: Mon, 1 Mar 2021 18:37:28 +0200 Subject: feature: marker symbol management for scatter series --- lib/axlsx/drawing/scatter_series.rb | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'lib/axlsx/drawing/scatter_series.rb') diff --git a/lib/axlsx/drawing/scatter_series.rb b/lib/axlsx/drawing/scatter_series.rb index 1e116860..b62fc006 100644 --- a/lib/axlsx/drawing/scatter_series.rb +++ b/lib/axlsx/drawing/scatter_series.rb @@ -30,11 +30,15 @@ module Axlsx # Line markers presence # @return [Boolean] - attr_reader :marker + attr_reader :show_marker + + # custom marker symbol + # @return [String] + attr_reader :marker_symbol # Creates a new ScatterSeries def initialize(chart, options={}) - @xData, @yData = nil + @xData, @yData, @marker_symbol = 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) @@ -44,7 +48,7 @@ module Axlsx @smooth = options[:smooth] end @ln_width = options[:ln_width] unless options[:ln_width].nil? - @marker = [:lineMarker, :marker, :smoothMarker].include?(chart.scatter_style) + @show_marker = [:lineMarker, :marker, :smoothMarker].include?(chart.scatter_style) super(chart, options) @xData = AxDataSource.new(:tag_name => :xVal, :data => options[:xData]) unless options[:xData].nil? @@ -67,6 +71,12 @@ module Axlsx @ln_width = v end + # @see marker_symbol + def marker_symbol=(v) + Axlsx::validate_marker_symbol(v) + @marker_symbol = v + end + # Serializes the object # @param [String] str # @return [String] @@ -87,7 +97,13 @@ module Axlsx str << '' str << ('') str << '' - str << '' unless marker + + if !@show_marker + str << '' + elsif @marker_symbol != :default + str << '' + end + str << '' end if ln_width -- cgit v1.2.3