Class: Axlsx::ScatterSeries
- Defined in:
- lib/axlsx/drawing/scatter_series.rb
Overview
Note:
The recommended way to manage series is to use Chart#add_series
A ScatterSeries defines the x and y position of data in the chart
Instance Attribute Summary collapse
-
#color ⇒ String
The fill color for this series.
- #ln_width ⇒ String
-
#marker_symbol ⇒ String
custom marker symbol.
-
#show_marker ⇒ Boolean
readonly
Line markers presence.
-
#smooth ⇒ Boolean
Line smoothing between data points.
-
#xData ⇒ NamedAxisData
readonly
The x data for this series.
-
#yData ⇒ NamedAxisData
readonly
The y data for this series.
Attributes inherited from Series
Instance Method Summary collapse
-
#initialize(chart, options = {}) ⇒ ScatterSeries
constructor
Creates a new ScatterSeries.
-
#to_xml_string(str = +'')) ⇒ String
Serializes the object.
Methods inherited from Series
Methods included from OptionsParser
Constructor Details
#initialize(chart, options = {}) ⇒ ScatterSeries
Creates a new ScatterSeries
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 39 def initialize(chart, = {}) @xData, @yData = nil if [: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([:smooth]) @smooth = [:smooth] end @ln_width = [:ln_width] unless [:ln_width].nil? @show_marker = [:lineMarker, :marker, :smoothMarker].include?(chart.scatter_style) @marker_symbol = :default super(chart, ) @xData = AxDataSource.new(tag_name: :xVal, data: [:xData]) unless [:xData].nil? @yData = NumDataSource.new({ tag_name: :yVal, data: [:yData] }) unless [:yData].nil? end |
Instance Attribute Details
#color ⇒ String
The fill color for this series. Red, green, and blue is expressed as sequence of hex digits, RRGGBB. A perceptual gamma of 2.2 is used.
21 22 23 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 21 def color @color end |
#ln_width ⇒ String
24 25 26 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 24 def ln_width @ln_width end |
#marker_symbol ⇒ String
custom marker symbol
36 37 38 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 36 def marker_symbol @marker_symbol end |
#show_marker ⇒ Boolean (readonly)
Line markers presence
32 33 34 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 32 def show_marker @show_marker end |
#smooth ⇒ Boolean
Line smoothing between data points
28 29 30 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 28 def smooth @smooth end |
#xData ⇒ NamedAxisData (readonly)
The x data for this series.
12 13 14 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 12 def xData @xData end |
#yData ⇒ NamedAxisData (readonly)
The y data for this series.
16 17 18 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 16 def yData @yData end |
Instance Method Details
#to_xml_string(str = +'')) ⇒ String
Serializes the object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 83 def to_xml_string(str = +'') super(str) do # needs to override the super color here to push in ln/and something else! if color str << '<c:spPr><a:solidFill>' str << '<a:srgbClr val="' << color << '"/>' str << '</a:solidFill>' str << '<a:ln><a:solidFill>' str << '<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>' str << '</c:spPr>' str << '<c:marker>' str << '<c:spPr><a:solidFill>' str << '<a:srgbClr val="' << color << '"/>' str << '</a:solidFill>' 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 << '"/>' str << '</c:spPr>' 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 |