lib/axlsx/drawing/bar_3D_chart.rb in axlsx-1.0.18 vs lib/axlsx/drawing/bar_3D_chart.rb in axlsx-1.1.0
- old
+ new
@@ -39,11 +39,11 @@
# @return [Symbol]
attr_reader :shape
# validation regex for gap amount percent
GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/
-
+
# Creates a new bar chart object
# @param [GraphicFrame] frame The workbook that owns this chart.
# @option options [Cell, String] title
# @option options [Boolean] show_legend
# @option options [Symbol] barDir
@@ -65,18 +65,18 @@
@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)
+ super(frame, options)
@series_type = BarSeries
@view3D = View3D.new({:rAngAx=>1}.merge(options))
end
# The direction of the bars in the chart
# must be one of [:bar, :col]
- def barDir=(v)
+ def barDir=(v)
RestrictionValidator.validate "Bar3DChart.barDir", [:bar, :col], v
@barDir = v
end
#grouping for a column, line, or area chart.
@@ -98,40 +98,41 @@
@gapDepth=(v)
end
# The shabe of the bars or columns
# must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
- def shape=(v)
+ def shape=(v)
RestrictionValidator.validate "Bar3DChart.shape", [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax], v
@shape = v
end
-
- # Serializes the bar chart
+
+ # Serializes the object
+ # @param [String] str
# @return [String]
- def to_xml
- super() do |xml|
- xml.bar3DChart {
- xml.barDir :val => barDir
- xml.grouping :val=>grouping
- xml.varyColors :val=>1
- @series.each { |ser| ser.to_xml(xml) }
- xml.dLbls {
- xml.showLegendKey :val=>0
- xml.showVal :val=>0
- xml.showCatName :val=>0
- xml.showSerName :val=>0
- xml.showPercent :val=>0
- xml.showBubbleSize :val=>0
- }
- xml.gapWidth :val=>@gapWidth unless @gapWidth.nil?
- xml.gapDepth :val=>@gapDepth unless @gapDepth.nil?
- xml.shape :val=>@shape unless @shape.nil?
- xml.axId :val=>@catAxId
- xml.axId :val=>@valAxId
- xml.axId :val=>0
- }
- @catAxis.to_xml(xml)
- @valAxis.to_xml(xml)
+ 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
- end
+ end
+ end
end