Class: Axlsx::Line3DChart

Inherits:
Chart
  • Object
show all
Defined in:
lib/axlsx/drawing/line_3D_chart.rb

Overview

The Line3DChart is a three dimentional line chart (who would have guessed?) that you can add to your worksheet.

Examples:

Creating a chart

# This example creates a line in a single sheet.
require "rubygems" # if that is your preferred way to manage gems!
require "axlsx"

p = Axlsx::Package.new
ws = p.workbook.add_worksheet
ws.add_row :values => ["This is a chart with no data in the sheet"]

chart = ws.add_chart(Axlsx::Line3DChart, :start_at=> [0,1], :end_at=>[0,6], :title=>"Most Popular Pets")
chart.add_series :data => [1, 9, 10], :labels => ["Slimy Reptiles", "Fuzzy Bunnies", "Rottweiler"]

See Also:

Constant Summary collapse

GAP_AMOUNT_PERCENT =

validation regex for gap amount percent

/0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/

Instance Attribute Summary collapse

Attributes inherited from Chart

#graphic_frame, #series, #series_type, #show_legend, #style, #title, #view_3D

Instance Method Summary collapse

Methods inherited from Chart

#add_series, #d_lbls, #end_at, #from, #index, #pn, #start_at, #to

Constructor Details

#initialize(frame, options = {}) ⇒ Line3DChart

Creates a new line chart object

Parameters:

  • frame (GraphicFrame)

    The workbook that owns this chart.

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

    a customizable set of options

Options Hash (options):

  • title (Cell, String)
  • show_legend (Boolean)
  • grouping (Symbol)
  • gapDepth (String)
  • rotX (Integer)
  • hPercent (String)
  • rotY (Integer)
  • depthPercent (String)
  • rAngAx (Boolean)
  • perspective (Integer)

See Also:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/axlsx/drawing/line_3D_chart.rb', line 62

def initialize(frame, options={})
  @gapDepth = nil
  @grouping = :standard
  @catAxId = rand(8 ** 8)
  @valAxId = rand(8 ** 8)
  @serAxId = rand(8 ** 8)
  @catAxis = CatAxis.new(@catAxId, @valAxId)
  @valAxis = ValAxis.new(@valAxId, @catAxId)
  @serAxis = SerAxis.new(@serAxId, @valAxId)
  super(frame, options)
  @series_type = LineSeries
  @view_3D = View3D.new({:perspective=>30}.merge(options))
  @d_lbls = nil
end

Instance Attribute Details

#catAxisCatAxis (readonly)

the category axis

Returns:



26
27
28
# File 'lib/axlsx/drawing/line_3D_chart.rb', line 26

def catAxis
  @catAxis
end

#gapDepthString

space between bar or column clusters, as a percentage of the bar or column width.

Returns:

  • (String)


38
39
40
# File 'lib/axlsx/drawing/line_3D_chart.rb', line 38

def gapDepth
  @gapDepth
end

#groupingSymbol

grouping for a column, line, or area chart. must be one of [:percentStacked, :clustered, :standard, :stacked]

Returns:

  • (Symbol)


43
44
45
# File 'lib/axlsx/drawing/line_3D_chart.rb', line 43

def grouping
  @grouping
end

#serAxisAxis (readonly)

the category axis

Returns:



34
35
36
# File 'lib/axlsx/drawing/line_3D_chart.rb', line 34

def serAxis
  @serAxis
end

#valAxisValAxis (readonly)

the category axis

Returns:



30
31
32
# File 'lib/axlsx/drawing/line_3D_chart.rb', line 30

def valAxis
  @valAxis
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

  • str (String) (defaults to: '')

Returns:

  • (String)


92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/axlsx/drawing/line_3D_chart.rb', line 92

def to_xml_string(str = '')
  super(str) do |str_inner|
    str_inner << '<c:line3DChart>'
    str_inner << '<c:grouping val="' << grouping.to_s << '"/>'
    str_inner << '<c:varyColors val="1"/>'
    @series.each { |ser| ser.to_xml_string(str_inner) }
    @d_lbls.to_xml_string(str) if @d_lbls
    str_inner << '<c:gapDepth val="' << @gapDepth.to_s << '"/>' unless @gapDepth.nil?
    str_inner << '<c:axId val="' << @catAxId.to_s << '"/>'
    str_inner << '<c:axId val="' << @valAxId.to_s << '"/>'
    str_inner << '<c:axId val="' << @serAxId.to_s << '"/>'
    str_inner << '</c:line3DChart>'
    @catAxis.to_xml_string str_inner
    @valAxis.to_xml_string str_inner
    @serAxis.to_xml_string str_inner
  end
end