Class: Axlsx::PieSeries
- Defined in:
- lib/axlsx/drawing/pie_series.rb
Overview
Note:
The recommended way to manage series is to use Chart#add_series
A PieSeries defines the data and labels and explosion for pie charts series.
Instance Attribute Summary collapse
-
#colors ⇒ Object
An array of rgb colors to apply to your bar chart.
-
#data ⇒ SimpleTypedList
readonly
The data for this series.
-
#explosion ⇒ Integert
The explosion for this series.
-
#labels ⇒ SimpleTypedList
readonly
The labels for this series.
Attributes inherited from Series
Instance Method Summary collapse
-
#initialize(chart, options = {}) ⇒ PieSeries
constructor
Creates a new series.
-
#to_xml_string(str = +'')) ⇒ String
Serializes the object.
Methods inherited from Series
Methods included from OptionsParser
Constructor Details
#initialize(chart, options = {}) ⇒ PieSeries
Creates a new series
30 31 32 33 34 35 36 |
# File 'lib/axlsx/drawing/pie_series.rb', line 30 def initialize(chart, = {}) @explosion = nil @colors = [] super self.labels = AxDataSource.new(data: [:labels]) unless [:labels].nil? self.data = NumDataSource.new() unless [:data].nil? end |
Instance Attribute Details
#colors ⇒ Object
An array of rgb colors to apply to your bar chart.
22 23 24 |
# File 'lib/axlsx/drawing/pie_series.rb', line 22 def colors @colors end |
#data ⇒ SimpleTypedList
The data for this series.
11 12 13 |
# File 'lib/axlsx/drawing/pie_series.rb', line 11 def data @data end |
#explosion ⇒ Integert
The explosion for this series
19 20 21 |
# File 'lib/axlsx/drawing/pie_series.rb', line 19 def explosion @explosion end |
#labels ⇒ SimpleTypedList
The labels for this series.
15 16 17 |
# File 'lib/axlsx/drawing/pie_series.rb', line 15 def labels @labels end |
Instance Method Details
#to_xml_string(str = +'')) ⇒ String
Serializes the object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/axlsx/drawing/pie_series.rb', line 53 def to_xml_string(str = +'') super do str << '<c:explosion val="' << @explosion.to_s << '"/>' unless @explosion.nil? colors.each_with_index do |c, index| str << '<c:dPt>' str << '<c:idx val="' << index.to_s << '"/>' str << '<c:spPr><a:solidFill>' str << '<a:srgbClr val="' << c << '"/>' str << '</a:solidFill></c:spPr></c:dPt>' end @labels.to_xml_string str unless @labels.nil? @data.to_xml_string str unless @data.nil? end str end |