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, #view3D

Instance Method Summary collapse

Methods inherited from Chart

#add_series, #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
# 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
  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)


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/axlsx/drawing/scatter_chart.rb', line 46

def to_xml_string(str = '')
  super do |str|
    str << '<c:scatterChart>'
    str << '<c:scatterStyle val="' << scatterStyle.to_s << '"/>'
    str << '<c:varyColors val="1"/>'
    @series.each { |ser| ser.to_xml_string(str) }
    str << '<c:dLbls>'
    str << '<c:showLegendKey val="0"/>'
    str << '<c:showVal val="0"/>'
    str << '<c:showCatName val="0"/>'
    str << '<c:showSerName val="0"/>'
    str << '<c:showPercent val="0"/>'
    str << '<c:showBubbleSize val="0"/>'
    str << '</c:dLbls>'
    str << '<c:axId val="' << @xValAxId.to_s << '"/>'
    str << '<c:axId val="' << @yValAxId.to_s << '"/>'
    str << '</c:scatterChart>'
    @xValAxis.to_xml_string str
    @yValAxis.to_xml_string str
  end
  str
end