summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/bar_3D_chart.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-04-01 00:35:26 +0900
committerRandy Morgan <[email protected]>2012-04-01 00:35:26 +0900
commit22a341841f191a5aa00e87b1f166b4f25cc67f0a (patch)
tree505f46708d5cac7d33d0dd6679c125e2eb819075 /lib/axlsx/drawing/bar_3D_chart.rb
parentbb2117ba17297e02a0fc6d5ad5a22462e72a9a79 (diff)
downloadcaxlsx-22a341841f191a5aa00e87b1f166b4f25cc67f0a.tar.gz
caxlsx-22a341841f191a5aa00e87b1f166b4f25cc67f0a.zip
part way through changing all serialization to use string concatenation prior to dropping Nokogiri dep in production.
Diffstat (limited to 'lib/axlsx/drawing/bar_3D_chart.rb')
-rw-r--r--lib/axlsx/drawing/bar_3D_chart.rb44
1 files changed, 35 insertions, 9 deletions
diff --git a/lib/axlsx/drawing/bar_3D_chart.rb b/lib/axlsx/drawing/bar_3D_chart.rb
index de179cb6..dbed026a 100644
--- a/lib/axlsx/drawing/bar_3D_chart.rb
+++ b/lib/axlsx/drawing/bar_3D_chart.rb
@@ -41,7 +41,7 @@ module Axlsx
# 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
@@ -67,14 +67,14 @@ module Axlsx
@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
@@ -100,11 +100,37 @@ module Axlsx
# 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
-
+
+ def to_xml_string(str = '')
+ super do |str|
+ str << '<bar3DChart>'
+ str << '<barDir val="' << barDir.to_s << '"/>'
+ str << '<grouping val="' << grouping.to_s << '"/>'
+ str << '<varyColors val="1"/>'
+ @series.each { |ser| ser.to_xml_str(str) }
+ str << '<dLbls>'
+ str << '<showLegendKey val="0"/>'
+ str << '<showVal val="0"/>'
+ str << '<showCatName val="0"/>'
+ str << '<showSerName val="0"/>'
+ str << '<showPercent val="0"/>'
+ str << '<showBubbleSize val="0"/>'
+ str << '</dLbls>'
+ str << '<gapWidth val="' << @gapWidth.to_s << '"/>' unless @gapWidth.nil?
+ str << '<gapDepth val="' << @gapDepth.to_s << '"/>' unless @gapDepth.nil?
+ str << '<shape val="' << @shape.to_s << '"/>'
+ str << '<axId val="' << @catAxId.to_s << '"/>'
+ str << '<axId val="' << @valAxId.to_s << '"/>'
+ str << '<axId val="0"/>'
+ str << '</bar3DChart>'
+ @catAxis.to_xml_str str
+ @valAxis.to_xml_str str
+ end
+ end
# Serializes the bar chart
# @return [String]
def to_xml
@@ -120,7 +146,7 @@ module Axlsx
xml.showCatName :val=>0
xml.showSerName :val=>0
xml.showPercent :val=>0
- xml.showBubbleSize :val=>0
+ xml.showBubbleSize :val=>0
}
xml.gapWidth :val=>@gapWidth unless @gapWidth.nil?
xml.gapDepth :val=>@gapDepth unless @gapDepth.nil?
@@ -130,8 +156,8 @@ module Axlsx
xml.axId :val=>0
}
@catAxis.to_xml(xml)
- @valAxis.to_xml(xml)
+ @valAxis.to_xml(xml)
end
- end
- end
+ end
+ end
end