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, #view3D

Instance Method Summary collapse

Methods inherited from Chart

#add_series, #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)
  • barDir (Symbol)
  • grouping (Symbol)
  • gapWidth (String)
  • gapDepth (String)
  • shape (Symbol)
  • 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
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 62

def initialize(frame, options={})
  @barDir = :bar
  @grouping = :clustered
  @gapWidth, @gapDepth, @shape = nil, nil, nil
  @catAxId = rand(8 ** 8)
  @valAxId = rand(8 ** 8)
  @catAxis = CatAxis.new(@catAxId, @valAxId)
  @valAxis = ValAxis.new(@valAxId, @catAxId, :tickLblPos => :low)
  super(frame, options)
  @series_type = BarSeries
  @view3D = View3D.new({:rAngAx=>1}.merge(options))
end

Instance Attribute Details

#barDirSymbol

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

Returns:

  • (Symbol)


22
23
24
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 22

def barDir
  @barDir
end

#catAxisCatAxis (readonly)

the category axis

Returns:



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

def catAxis
  @catAxis
end

#gapDepthString

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

Returns:

  • (String)


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

def gapDepth
  @gapDepth
end

#gapWidthString

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

Returns:

  • (String)


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

def gapWidth
  @gapWidth
end

#groupingSymbol

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

Returns:

  • (Symbol)


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

def grouping
  @grouping
end

#shapeSymbol

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

Returns:

  • (Symbol)


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

def shape
  @shape
end

#valAxisValAxis (readonly)

the valueaxis

Returns:



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

def valAxis
  @valAxis
end

Instance Method Details

#to_xml_string(str = '') ⇒ String

Serializes the object

Parameters:

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

Returns:

  • (String)


111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 111

def to_xml_string(str = '')
  super(str) do |str_inner|
    str_inner << '<c:bar3DChart>'
    str_inner << '<c:barDir val="' << barDir.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) }
    str_inner << '<c:dLbls>'
    str_inner << '<c:showLegendKey val="0"/>'
    str_inner << '<c:showVal val="0"/>'
    str_inner << '<c:showCatName val="0"/>'
    str_inner << '<c:showSerName val="0"/>'
    str_inner << '<c:showPercent val="0"/>'
    str_inner << '<c:showBubbleSize val="0"/>'
    str_inner << '</c:dLbls>'
    str_inner << '<c:gapWidth val="' << @gapWidth.to_s << '"/>' unless @gapWidth.nil?
    str_inner << '<c:gapDepth val="' << @gapDepth.to_s << '"/>' unless @gapDepth.nil?
    str_inner << '<c:shape val="' << @shape.to_s << '"/>' unless @shape.nil?
    str_inner << '<c:axId val="' << @catAxId.to_s << '"/>'
    str_inner << '<c:axId val="' << @valAxId.to_s << '"/>'
    str_inner << '<c:axId val="0"/>'
    str_inner << '</c:bar3DChart>'
    @catAxis.to_xml_string str_inner
    @valAxis.to_xml_string str_inner
  end
end