summaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
authorNoel Peden <[email protected]>2022-02-07 08:15:47 -0800
committerGitHub <[email protected]>2022-02-07 08:15:47 -0800
commitbe9b3e6ee9dca0e0377ae8f3b14d007ad494b7e6 (patch)
tree00cca6551838ca48dc297dd71338c14d8f8467b0 /lib
parent196862524f94c58b1521ef84a6cf0397b411a685 (diff)
parentf957baf68aae6ec06e94b5b7b4b1d281ab295ab3 (diff)
downloadcaxlsx-be9b3e6ee9dca0e0377ae8f3b14d007ad494b7e6.tar.gz
caxlsx-be9b3e6ee9dca0e0377ae8f3b14d007ad494b7e6.zip
Merge pull request #85 from olegykz/feature/manageable-scatter-markers
feature: manageable markers for scatter series
Diffstat (limited to 'lib')
-rw-r--r--lib/axlsx/drawing/scatter_series.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/axlsx/drawing/scatter_series.rb b/lib/axlsx/drawing/scatter_series.rb
index b9ca2c1d..8158c373 100644
--- a/lib/axlsx/drawing/scatter_series.rb
+++ b/lib/axlsx/drawing/scatter_series.rb
@@ -28,6 +28,14 @@ module Axlsx
# @return [Boolean]
attr_reader :smooth
+ # Line markers presence
+ # @return [Boolean]
+ attr_reader :show_marker
+
+ # custom marker symbol
+ # @return [String]
+ attr_reader :marker_symbol
+
# Creates a new ScatterSeries
def initialize(chart, options={})
@xData, @yData = nil
@@ -40,6 +48,9 @@ module Axlsx
@smooth = options[:smooth]
end
@ln_width = options[:ln_width] unless options[:ln_width].nil?
+ @show_marker = [:lineMarker, :marker, :smoothMarker].include?(chart.scatter_style)
+ @marker_symbol = :default
+
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?
@@ -61,6 +72,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]
@@ -81,8 +98,12 @@ module Axlsx
str << '<a:ln><a:solidFill>'
str << ('<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>')
str << '</c:spPr>'
+ str << marker_symbol_xml
str << '</c:marker>'
+ else
+ str << "<c:marker>#{marker_symbol_xml}</c:marker>"
end
+
if ln_width
str << '<c:spPr>'
str << '<a:ln w="' << ln_width.to_s << '"/>'
@@ -94,5 +115,15 @@ module Axlsx
end
str
end
+
+ private
+
+ def marker_symbol_xml
+ if !@show_marker
+ '<c:symbol val="none"/>'
+ elsif @marker_symbol != :default
+ '<c:symbol val="' + @marker_symbol.to_s + '"/>'
+ end.to_s
+ end
end
end