Class: Axlsx::BarSeries
- Defined in:
- lib/axlsx/drawing/bar_series.rb
Overview
Note:
The recommended way to manage series is to use Chart#add_series
A BarSeries defines the title, data and labels for bar charts
Instance Attribute Summary collapse
-
#colors ⇒ Object
An array of rgb colors to apply to your bar chart.
-
#data ⇒ NumDataSource
readonly
The data for this series.
-
#labels ⇒ Array, SimpleTypedList
readonly
The labels for this series.
-
#series_color ⇒ String
The fill color for this series.
-
#shape ⇒ Symbol
The shape of the bars or columns.
Attributes inherited from Series
Instance Method Summary collapse
-
#initialize(chart, options = {}) ⇒ BarSeries
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 = {}) ⇒ BarSeries
Creates a new series
35 36 37 38 39 40 41 |
# File 'lib/axlsx/drawing/bar_series.rb', line 35 def initialize(chart, = {}) @shape = :box @colors = [] super(chart, ) 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.
20 21 22 |
# File 'lib/axlsx/drawing/bar_series.rb', line 20 def colors @colors end |
#data ⇒ NumDataSource
The data for this series.
9 10 11 |
# File 'lib/axlsx/drawing/bar_series.rb', line 9 def data @data end |
#labels ⇒ Array, SimpleTypedList
The labels for this series.
13 14 15 |
# File 'lib/axlsx/drawing/bar_series.rb', line 13 def labels @labels end |
#series_color ⇒ String
The fill color for this series. Red, green, and blue is expressed as sequence of hex digits, RRGGBB.
25 26 27 |
# File 'lib/axlsx/drawing/bar_series.rb', line 25 def series_color @series_color end |
#shape ⇒ Symbol
The shape of the bars or columns
17 18 19 |
# File 'lib/axlsx/drawing/bar_series.rb', line 17 def shape @shape end |
Instance Method Details
#to_xml_string(str = '') ⇒ String
Serializes the object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/axlsx/drawing/bar_series.rb', line 59 def to_xml_string(str = '') super(str) do 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 if series_color str << '<c:spPr><a:solidFill>' str << ('<a:srgbClr val="' << series_color << '"/>') str << '</a:solidFill>' str << '</c:spPr>' end @labels.to_xml_string(str) unless @labels.nil? @data.to_xml_string(str) unless @data.nil? # this is actually only required for shapes other than box str << ('<c:shape val="' << shape.to_s << '"></c:shape>') end end |