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.
-
#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
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 29 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 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.
22 23 24 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 22 def color @color end |
#smooth ⇒ Boolean
Line smoothing between data points
26 27 28 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 26 def smooth @smooth end |
#xData ⇒ NamedAxisData (readonly)
The x data for this series.
13 14 15 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 13 def xData @xData end |
#yData ⇒ NamedAxisData (readonly)
The y data for this series.
17 18 19 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 17 def yData @yData end |
Instance Method Details
#to_xml_string(str = '') ⇒ String
Serializes the object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/axlsx/drawing/scatter_series.rb', line 58 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 << '</c:marker>' 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 |