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.

See Also:

Constant Summary

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, index, pn, series, series_type, show_legend, style, title, view3D

Instance Method Summary (collapse)

Methods inherited from Chart

#add_series, #end_at, #from, #start_at, #to

Constructor Details

- (Bar3DChart) initialize(frame, options = {})

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:



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 61

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

Instance Attribute Details

- (Symbol) barDir

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

Returns:

  • (Symbol)


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

def barDir
  @barDir
end

- (CatAxis) catAxis (readonly)

the category axis

Returns:



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

def catAxis
  @catAxis
end

- (String) gapDepth

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

Returns:

  • (String)


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

def gapDepth
  @gapDepth
end

- (String) gapWidth

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 gapWidth
  @gapWidth
end

- (Symbol) grouping

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

Returns:

  • (Symbol)


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

def grouping
  @grouping
end

- (Symbol) shape

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

Returns:

  • (Symbol)


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

def shape
  @shape
end

- (ValAxis) valAxis (readonly)

the valueaxis

Returns:



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

def valAxis
  @valAxis
end

Instance Method Details

- (String) to_xml

Serializes the bar chart

Returns:

  • (String)


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/axlsx/drawing/bar_3D_chart.rb', line 101

def to_xml
  super() do |xml|
    xml.send('c:bar3DChart') {
      xml.send('c:barDir', :val => barDir)
      xml.send('c:grouping', :val=>grouping)
      xml.send('c:varyColors', :val=>1)
      @series.each { |ser| ser.to_xml(xml) }
      xml.send('c:gapWidth', :val=>@gapWidth) unless @gapWidth.nil?
      xml.send('c:gapDepth', :val=>@gapDepth) unless @gapDepth.nil?
      xml.send('c:shape', :val=>@shape) unless @shape.nil?
      xml.send('c:axId', :val=>@catAxId)
      xml.send('c:axId', :val=>@valAxId)
      xml.send('c:axId', :val=>0)
    }
    @catAxis.to_xml(xml)
    @valAxis.to_xml(xml)        
  end
end