Class: Axlsx::Bar3DChart

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

Overview

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

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 = {}) ⇒ Bar3DChart

Creates a new bar 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)
  • bar_dir (Symbol)
  • grouping (Symbol)
  • gap_width (String)
  • gap_depth (String)
  • shape (Symbol)
  • rot_x (Integer)
  • h_percent (String)
  • rot_y (Integer)
  • depth_percent (String)
  • r_ang_ax (Boolean)
  • perspective (Integer)

See Also:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 67

def initialize(frame, options={})
  @bar_dir = :bar
  @grouping = :clustered
  @shape = :box
  @gap_width = 150
  @gap_width, @gap_depth, @shape = nil, nil, nil
  @cat_ax_id = rand(8 ** 8)
  @val_ax_id = rand(8 ** 8)
  @cat_axis = CatAxis.new(@cat_ax_id, @val_ax_id)
  @val_axis = ValAxis.new(@val_ax_id, @cat_ax_id, :tick_lbl_pos => :low, :ax_pos => :l)
  super(frame, options)
  @series_type = BarSeries
  @view_3D = View3D.new({:r_ang_ax=>1}.merge(options))
  @d_lbls = nil
end

Instance Attribute Details

#bar_dirSymbol Also known as: barDir

The direction of the bars in the chart must be one of [:bar, :col]

Returns:

  • (Symbol)


24
25
26
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 24

def bar_dir
  @bar_dir
end

#cat_axisCatAxis (readonly) Also known as: catAxis

the category axis

Returns:



13
14
15
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 13

def cat_axis
  @cat_axis
end

#gap_depthString Also known as: gapDepth

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

Returns:

  • (String)


29
30
31
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 29

def gap_depth
  @gap_depth
end

#gap_widthString Also known as: gapWidth

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

Returns:

  • (String)


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

def gap_width
  @gap_width
end

#groupingSymbol

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

Returns:

  • (Symbol)


40
41
42
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 40

def grouping
  @grouping
end

#shapeSymbol

The shabe of the bars or columns must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]

Returns:

  • (Symbol)


45
46
47
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 45

def shape
  @shape
end

#val_axisValAxis (readonly) Also known as: valAxis

the value axis

Returns:



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

def val_axis
  @val_axis
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

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

Returns:

  • (String)


122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 122

def to_xml_string(str = '')
  super(str) do |str_inner|
    str_inner << '<c:bar3DChart>'
    str_inner << '<c:barDir val="' << bar_dir.to_s << '"/>'
    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:gapWidth val="' << @gap_width.to_s << '"/>' unless @gap_width.nil?
    str_inner << '<c:gapDepth val="' << @gap_depth.to_s << '"/>' unless @gap_depth.nil?
    str_inner << '<c:shape val="' << @shape.to_s << '"/>' unless @shape.nil?
    str_inner << '<c:axId val="' << @cat_ax_id.to_s << '"/>'
    str_inner << '<c:axId val="' << @val_ax_id.to_s << '"/>'
    str_inner << '<c:axId val="0"/>'
    str_inner << '</c:bar3DChart>'
    @cat_axis.to_xml_string str_inner
    @val_axis.to_xml_string str_inner
  end
end