class Axlsx::PieSeries

A PieSeries defines the data and labels and explosion for pie charts series. @note The recommended way to manage series is to use Chart#add_series @see Worksheet#add_chart @see Chart#add_series

Attributes

colors[R]

An array of rgb colors to apply to your bar chart.

data[R]

The data for this series. @return [SimpleTypedList]

explosion[R]

The explosion for this series @return [Integert]

labels[R]

The labels for this series. @return [SimpleTypedList]

Public Class Methods

new(chart, options={}) click to toggle source

Creates a new series @option options [Array, SimpleTypedList] data @option options [Array, SimpleTypedList] labels @option options [String] title @option options [Integer] explosion @param [Chart] chart

Calls superclass method
# File lib/axlsx/drawing/pie_series.rb, line 31
def initialize(chart, options={})
  @explosion = nil
  @colors = []
  super(chart, options)
  self.labels = AxDataSource.new(:data => options[:labels]) unless options[:labels].nil?
  self.data = NumDataSource.new(options) unless options[:data].nil?
end

Public Instance Methods

colors=(v) click to toggle source

@see colors

# File lib/axlsx/drawing/pie_series.rb, line 40
def colors=(v) DataTypeValidator.validate "BarSeries.colors", [Array], v; @colors = v end
explosion=(v) click to toggle source

@see explosion

# File lib/axlsx/drawing/pie_series.rb, line 43
def explosion=(v) Axlsx::validate_unsigned_int(v); @explosion = v; end
to_xml_string(str = '') click to toggle source

Serializes the object @param [String] str @return [String]

Calls superclass method
# File lib/axlsx/drawing/pie_series.rb, line 48
def to_xml_string(str = '')
  super(str) do
    str << '<c:explosion val="' + @explosion + '"/>' 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

Private Instance Methods

data=(v) click to toggle source

assigns the data for this series

# File lib/axlsx/drawing/pie_series.rb, line 67
def data=(v) DataTypeValidator.validate "Series.data", [NumDataSource], v; @data = v; end
labels=(v) click to toggle source

assigns the labels for this series

# File lib/axlsx/drawing/pie_series.rb, line 70
def labels=(v) DataTypeValidator.validate "Series.labels", [AxDataSource], v; @labels = v; end