Class: Axlsx::LineSeries
- 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
-
#data ⇒ Array, SimpleTypedList
readonly
The data for this series.
-
#labels ⇒ Array, SimpleTypedList
readonly
The labels for this series.
Attributes inherited from Series
#chart, #index, #order, #title
Instance Method Summary collapse
-
#initialize(chart, options = {}) ⇒ LineSeries
constructor
Creates a new series.
-
#to_xml(xml) ⇒ String
Serializes the series.
Constructor Details
#initialize(chart, options = {}) ⇒ LineSeries
Creates a new series
20 21 22 23 24 |
# File 'lib/axlsx/drawing/line_series.rb', line 20 def initialize(chart, ={}) super(chart, ) self.data = [:data] || [] self.labels = [:labels] || [] end |
Instance Attribute Details
#data ⇒ Array, SimpleTypedList
The data for this series.
10 11 12 |
# File 'lib/axlsx/drawing/line_series.rb', line 10 def data @data end |
#labels ⇒ Array, SimpleTypedList
The labels for this series.
14 15 16 |
# File 'lib/axlsx/drawing/line_series.rb', line 14 def labels @labels end |
Instance Method Details
#to_xml(xml) ⇒ String
Serializes the series
29 30 31 32 33 34 35 36 37 38 39 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/line_series.rb', line 29 def to_xml(xml) super(xml) do |xml| if !labels.empty? xml.send('c:cat') { xml.send('c:strRef') { xml.send('c:f', Axlsx::cell_range(labels)) xml.send('c:strCache') { xml.send('c:ptCount', :val=>labels.size) labels.each_with_index do |cell, index| v = cell.is_a?(Cell) ? cell.value : cell xml.send('c:pt', :idx=>index) { xml.send('c:v', v) } end } } } end xml.send('c:val') { xml.send('c:numRef') { xml.send('c:f', Axlsx::cell_range(data)) xml.send('c:numCache') { xml.send('c:formatCode', 'General') xml.send('c:ptCount', :val=>data.size) data.each_with_index do |cell, index| v = cell.is_a?(Cell) ? cell.value : cell xml.send('c:pt', :idx=>index) { xml.send('c:v', v) } end } } } end end |