Class: Axlsx::BarSeries

Inherits:
Series
  • Object
show all
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

See Also:

Instance Attribute Summary (collapse)

Attributes inherited from Series

chart, index, order, title

Instance Method Summary (collapse)

Constructor Details

- (BarSeries) initialize(chart, options = {})

Creates a new series

Parameters:

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

    a customizable set of options

Options Hash (options):



28
29
30
31
32
33
# File 'lib/axlsx/drawing/bar_series.rb', line 28

def initialize(chart, options={})
  @shape = :box
  super(chart, options)
  self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil?
  self.data = ValAxisData.new(options[:data]) unless options[:data].nil?
end

Instance Attribute Details

- (Array, SimpleTypedList) data

The data for this series.

Returns:



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

def data
  @data
end

- (Array, SimpleTypedList) labels

The labels for this series.

Returns:



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

def labels
  @labels
end

- (Symbol) shape

The shabe of the bars or columns must be one of [:percentStacked, :clustered, :standard, :stacked]

Returns:

  • (Symbol)


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

def shape
  @shape
end

Instance Method Details

- (String) to_xml(xml)

Serializes the series

Parameters:

  • xml (Nokogiri::XML::Builder)

    The document builder instance this objects xml will be added to.

Returns:

  • (String)


43
44
45
46
47
48
49
# File 'lib/axlsx/drawing/bar_series.rb', line 43

def to_xml(xml)
  super(xml) do |xml|
    @labels.to_xml(xml) unless @labels.nil?
    @data.to_xml(xml) unless @data.nil?
    xml.send('c:shape', :val=>@shape)
  end      
end