Class: Axlsx::BarChart
Overview
The BarChart is a two dimentional barchart that you can add to your worksheet.
Instance Attribute Summary
Attributes inherited from Chart
#bg_color, #display_blanks_as, #graphic_frame, #legend_position, #plot_visible_only, #rounded_corners, #series, #series_type, #show_legend, #style, #title, #vary_colors, #view_3D
Instance Method Summary collapse
-
#axes ⇒ Axes
A hash of axes used by this chart.
-
#bar_dir ⇒ Symbol
(also: #barDir)
The direction of the bars in the chart must be one of [:bar, :col].
-
#bar_dir=(v) ⇒ Object
(also: #barDir=)
The direction of the bars in the chart must be one of [:bar, :col].
-
#cat_axis ⇒ CatAxis
(also: #catAxis)
the category axis.
-
#gap_width ⇒ Integer
(also: #gapWidth)
space between bar or column clusters, as a percentage of the bar or column width.
-
#gap_width=(v) ⇒ Object
(also: #gapWidth=)
space between bar or column clusters, as a percentage of the bar or column width.
-
#grouping ⇒ Symbol
grouping for a column, line, or area chart.
-
#grouping=(v) ⇒ Object
grouping for a column, line, or area chart.
-
#initialize(frame, options = {}) ⇒ BarChart
constructor
Creates a new bar chart object.
-
#overlap ⇒ Integer
Overlap between series.
- #overlap=(v) ⇒ Object
-
#shape ⇒ Symbol
The shape of the bars or columns must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax].
-
#shape=(v) ⇒ Object
The shape of the bars or columns must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax].
-
#to_xml_string(str = '') ⇒ String
Serializes the object.
-
#val_axis ⇒ ValAxis
(also: #valAxis)
the value axis.
Methods inherited from Chart
#add_series, #d_lbls, #end_at, #from, #index, #pn, #relationship, #start_at, #title_size=, #to
Methods included from OptionsParser
Constructor Details
Instance Method Details
#axes ⇒ Axes
A hash of axes used by this chart. Bar charts have a value and category axes specified via axes[:val_axes] and axes[:cat_axis]
131 132 133 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 131 def axes @axes ||= Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis) end |
#bar_dir ⇒ Symbol Also known as: barDir
The direction of the bars in the chart must be one of [:bar, :col]
25 26 27 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 25 def @bar_dir ||= :bar end |
#bar_dir=(v) ⇒ Object Also known as: barDir=
The direction of the bars in the chart must be one of [:bar, :col]
76 77 78 79 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 76 def (v) RestrictionValidator.validate "BarChart.bar_dir", [:bar, :col], v @bar_dir = v end |
#cat_axis ⇒ CatAxis Also known as: catAxis
the category axis
10 11 12 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 10 def cat_axis axes[:cat_axis] end |
#gap_width ⇒ Integer Also known as: gapWidth
space between bar or column clusters, as a percentage of the bar or column width.
32 33 34 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 32 def gap_width @gap_width ||= 150 end |
#gap_width=(v) ⇒ Object Also known as: gapWidth=
space between bar or column clusters, as a percentage of the bar or column width.
90 91 92 93 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 90 def gap_width=(v) RangeValidator.validate "BarChart.gap_width", 0, 500, v @gap_width = (v) end |
#grouping ⇒ Symbol
grouping for a column, line, or area chart. must be one of [:percentStacked, :clustered, :standard, :stacked]
40 41 42 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 40 def grouping @grouping ||= :clustered end |
#grouping=(v) ⇒ Object
grouping for a column, line, or area chart. must be one of [:percentStacked, :clustered, :standard, :stacked]
84 85 86 87 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 84 def grouping=(v) RestrictionValidator.validate "BarChart.grouping", [:percentStacked, :clustered, :standard, :stacked], v @grouping = v end |
#overlap ⇒ Integer
Overlap between series
46 47 48 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 46 def overlap @overlap ||= 0 end |
#overlap=(v) ⇒ Object
96 97 98 99 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 96 def overlap=(v) RangeValidator.validate "BarChart.overlap", -100, 100, v @overlap = (v) end |
#shape ⇒ Symbol
The shape of the bars or columns must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
53 54 55 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 53 def shape @shape ||= :box end |
#shape=(v) ⇒ Object
The shape of the bars or columns must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
103 104 105 106 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 103 def shape=(v) RestrictionValidator.validate "BarChart.shape", [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax], v @shape = v end |
#to_xml_string(str = '') ⇒ String
Serializes the object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 111 def to_xml_string(str = '') super(str) do str << '<c:barChart>' str << ('<c:barDir val="' << .to_s << '"/>') str << ('<c:grouping val="' << grouping.to_s << '"/>') str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } @d_lbls.to_xml_string(str) if @d_lbls str << ('<c:overlap val="' << @overlap.to_s << '"/>') unless @overlap.nil? str << ('<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil? str << ('<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil? axes.to_xml_string(str, :ids => true) str << '</c:barChart>' axes.to_xml_string(str) end end |
#val_axis ⇒ ValAxis Also known as: valAxis
the value axis
17 18 19 |
# File 'lib/axlsx/drawing/bar_chart.rb', line 17 def val_axis axes[:val_axis] end |