Class: Axlsx::View3D

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

Overview

3D attributes for a chart.

Constant Summary collapse

H_PERCENT_REGEX =

Validation for hPercent

/0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)/
DEPTH_PERCENT_REGEX =

validation for depthPercent

/0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ View3D

Creates a new View3D for charts

Parameters:

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

    a customizable set of options

Options Hash (options):

  • rot_x (Integer)
  • h_percent (String)
  • rot_y (Integer)
  • depth_percent (String)
  • r_ang_ax (Boolean)
  • perspective (Integer)


52
53
54
55
56
57
# File 'lib/axlsx/drawing/view_3D.rb', line 52

def initialize(options={})
  @rot_x, @h_percent, @rot_y, @depth_percent, @r_ang_ax, @perspective  = nil, nil, nil, nil, nil, nil
  options.each do |o|
    self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
  end
end

Instance Attribute Details

#depth_percentString Also known as: depthPercent

depth or chart as % of chart width must be between 20% and 2000%

Returns:

  • (String)


33
34
35
# File 'lib/axlsx/drawing/view_3D.rb', line 33

def depth_percent
  @depth_percent
end

#h_percentString Also known as: hPercent

height of chart as % of chart width must be between 5% and 500%

Returns:

  • (String)


21
22
23
# File 'lib/axlsx/drawing/view_3D.rb', line 21

def h_percent
  @h_percent
end

#perspectiveInteger

field of view angle

Returns:

  • (Integer)


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

def perspective
  @perspective
end

#r_ang_axBoolean Also known as: rAngAx

Chart axis are at right angles

Returns:

  • (Boolean)


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

def r_ang_ax
  @r_ang_ax
end

#rot_xInteger Also known as: rotX

x rotation for the chart must be between -90 and 90

Returns:

  • (Integer)


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

def rot_x
  @rot_x
end

#rot_yInteger Also known as: rotY

y rotation for the chart must be between 0 and 360

Returns:

  • (Integer)


27
28
29
# File 'lib/axlsx/drawing/view_3D.rb', line 27

def rot_y
  @rot_y
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

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

Returns:

  • (String)


89
90
91
92
93
94
95
96
97
98
# File 'lib/axlsx/drawing/view_3D.rb', line 89

def to_xml_string(str = '')
  str << '<c:view3D>'
  str << '<c:rotX val="' << @rot_x.to_s << '"/>' unless @rot_x.nil?
  str << '<c:hPercent val="' << @h_percent.to_s << '"/>' unless @h_percent.nil?
  str << '<c:rotY val="' << @rot_y.to_s << '"/>' unless @rot_y.nil?
  str << '<c:depthPercent val="' << @depth_percent.to_s << '"/>' unless @depth_percent.nil?
  str << '<c:rAngAx val="' << @r_ang_ax.to_s << '"/>' unless @r_ang_ax.nil?
  str << '<c:perspective val="' << @perspective.to_s << '"/>' unless @perspective.nil?
  str << '</c:view3D>'
end