Class: Axlsx::PieSeries

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

Attributes inherited from Series

#chart, #index, #order, #title

Instance Method Summary collapse

Constructor Details

#initialize(chart, options = {}) ⇒ PieSeries

Creates a new series

Parameters:

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

    a customizable set of options

Options Hash (options):



26
27
28
29
30
# File 'lib/axlsx/drawing/pie_series.rb', line 26

def initialize(chart, options={})
  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

#dataSimpleTypedList

The data for this series.

Returns:



10
11
12
# File 'lib/axlsx/drawing/pie_series.rb', line 10

def data
  @data
end

#explosionIntegert

The explosion for this series

Returns:

  • (Integert)


18
19
20
# File 'lib/axlsx/drawing/pie_series.rb', line 18

def explosion
  @explosion
end

#labelsSimpleTypedList

The labels for this series.

Returns:



14
15
16
# File 'lib/axlsx/drawing/pie_series.rb', line 14

def labels
  @labels
end

Instance Method Details

#to_xml(xml) ⇒ String

Serializes the series

Parameters:

  • xml (Nokogiri::XML::Builder)

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

Returns:

  • (String)


37
38
39
40
41
42
43
# File 'lib/axlsx/drawing/pie_series.rb', line 37

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