Class: Axlsx::ScatterChart

Inherits:
Chart
  • Object
show all
Defined in:
lib/axlsx/drawing/scatter_chart.rb

Overview

The ScatterChart allows you to insert a scatter chart into your worksheet

See Also:

Instance Attribute Summary collapse

Attributes inherited from Chart

#graphic_frame, #series, #series_type, #show_legend, #style, #title, #view_3D

Instance Method Summary collapse

Methods inherited from Chart

#add_series, #d_lbls, #end_at, #from, #index, #pn, #start_at, #to

Constructor Details

#initialize(frame, options = {}) ⇒ ScatterChart

Creates a new scatter chart



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/axlsx/drawing/scatter_chart.rb', line 24

def initialize(frame, options={})
  @scatterStyle = :lineMarker
  @xValAxId = rand(8 ** 8)
  @yValAxId = rand(8 ** 8)
  @xValAxis = ValAxis.new(@xValAxId, @yValAxId)
  @yValAxis = ValAxis.new(@yValAxId, @xValAxId)
  super(frame, options)
  @series_type = ScatterSeries
  @d_lbls = nil
  options.each do |o|
    self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
  end
end

Instance Attribute Details

#scatterStyleObject

The Style for the scatter chart must be one of :none | :line | :lineMarker | :marker | :smooth | :smoothMarker return [Symbol]



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

def scatterStyle
  @scatterStyle
end

#xValAxisValAxis (readonly)

the x value axis

Returns:



17
18
19
# File 'lib/axlsx/drawing/scatter_chart.rb', line 17

def xValAxis
  @xValAxis
end

#yValAxisValAxis (readonly)

the y value axis

Returns:



21
22
23
# File 'lib/axlsx/drawing/scatter_chart.rb', line 21

def yValAxis
  @yValAxis
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

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

Returns:

  • (String)


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/axlsx/drawing/scatter_chart.rb', line 47

def to_xml_string(str = '')
  super(str) do |str_inner|
    str_inner << '<c:scatterChart>'
    str_inner << '<c:scatterStyle val="' << scatterStyle.to_s << '"/>'
    str_inner << '<c:varyColors val="1"/>'
    @series.each { |ser| ser.to_xml_string(str_inner) }
    d_lbls.to_xml_string(str) if @d_lbls
    str_inner << '<c:axId val="' << @xValAxId.to_s << '"/>'
    str_inner << '<c:axId val="' << @yValAxId.to_s << '"/>'
    str_inner << '</c:scatterChart>'
    @xValAxis.to_xml_string str_inner
    @yValAxis.to_xml_string str_inner
  end
  str
end