Class: Axlsx::ScatterSeries

Inherits:
Series
  • Object
show all
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

See Also:

Instance Attribute Summary collapse

Attributes inherited from Series

#chart, #title

Instance Method Summary collapse

Methods inherited from Series

#index, #order, #order=

Methods included from OptionsParser

#parse_options

Constructor Details

#initialize(chart, options = {}) ⇒ ScatterSeries

Creates a new ScatterSeries



25
26
27
28
29
30
# File 'lib/axlsx/drawing/scatter_series.rb', line 25

def initialize(chart, options={})
  @xData, @yData = nil
  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?
end

Instance Attribute Details

#colorString

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.

Returns:

  • (String)


22
23
24
# File 'lib/axlsx/drawing/scatter_series.rb', line 22

def color
  @color
end

#xDataNamedAxisData (readonly)

The x data for this series.

Returns:

  • (NamedAxisData)


13
14
15
# File 'lib/axlsx/drawing/scatter_series.rb', line 13

def xData
  @xData
end

#yDataNamedAxisData (readonly)

The y data for this series.

Returns:

  • (NamedAxisData)


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

Parameters:

  • str (String) (defaults to: '')

Returns:

  • (String)


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/axlsx/drawing/scatter_series.rb', line 40

def to_xml_string(str = '')
  super(str) do |inner_str|
    # 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(inner_str) unless @xData.nil?
    @yData.to_xml_string(inner_str) unless @yData.nil?
  end
  str
end