Class: Axlsx::LineSeries

Inherits:
Series
  • Object
show all
Defined in:
lib/axlsx/drawing/line_series.rb

Overview

Note:

The recommended way to manage series is to use Chart#add_series

A LineSeries defines the title, data and labels for line charts

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 = {}) ⇒ LineSeries

Creates a new series

Parameters:

  • chart (Chart)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • data (Array, SimpleTypedList)
  • labels (Array, SimpleTypedList)


38
39
40
41
42
43
44
45
46
# File 'lib/axlsx/drawing/line_series.rb', line 38

def initialize(chart, options={})
  @show_marker = false
  @marker_symbol = options[:marker_symbol] ? options[:marker_symbol] : :default
  @smooth = false
  @labels, @data = nil, nil
  super(chart, options)
  @labels = AxDataSource.new(:data => options[:labels]) unless options[:labels].nil?
  @data = NumDataSource.new(options) unless options[:data].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:



20
21
22
# File 'lib/axlsx/drawing/line_series.rb', line 20

def color
  @color
end

#dataValAxisData

The data for this series.

Returns:

  • (ValAxisData)


11
12
13
# File 'lib/axlsx/drawing/line_series.rb', line 11

def data
  @data
end

#labelsCatAxisData

The labels for this series.

Returns:

  • (CatAxisData)


15
16
17
# File 'lib/axlsx/drawing/line_series.rb', line 15

def labels
  @labels
end

#marker_symbolString

custom marker symbol

Returns:



28
29
30
# File 'lib/axlsx/drawing/line_series.rb', line 28

def marker_symbol
  @marker_symbol
end

#show_markerBoolean

show markers on values

Returns:

  • (Boolean)


24
25
26
# File 'lib/axlsx/drawing/line_series.rb', line 24

def show_marker
  @show_marker
end

#smoothBoolean

line smoothing on values

Returns:

  • (Boolean)


32
33
34
# File 'lib/axlsx/drawing/line_series.rb', line 32

def smooth
  @smooth
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

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

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/axlsx/drawing/line_series.rb', line 74

def to_xml_string(str = '')
  super(str) do
    if color
      str << '<c:spPr><a:solidFill>'
      str << ('<a:srgbClr val="' << color << '"/>')
      str << '</a:solidFill>'
      str << '<a:ln w="28800">'
      str << '<a:solidFill>'
      str << ('<a:srgbClr val="' << color << '"/>')
      str << '</a:solidFill>'
      str << '</a:ln>'
      str << '<a:round/>'
      str << '</c:spPr>'
    end

    if !@show_marker
      str << '<c:marker><c:symbol val="none"/></c:marker>'
    elsif @marker_symbol != :default
      str << '<c:marker><c:symbol val="' + @marker_symbol.to_s + '"/></c:marker>'
    end

    @labels.to_xml_string(str) unless @labels.nil?
    @data.to_xml_string(str) unless @data.nil?
    str << ('<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>')
  end
end