summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/drawing/scatter_chart.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2013-03-17 15:38:55 +0900
committerRandy Morgan <[email protected]>2013-03-17 15:38:55 +0900
commitae75ef360e3e0da253188d408a3cbc81ed3897e6 (patch)
tree9bf184d72c4a78b3f14731af511aad26002a51ad /lib/axlsx/drawing/scatter_chart.rb
parent17f135ab215ba05b85ef92a15ed0038ea7556de9 (diff)
downloadcaxlsx-ae75ef360e3e0da253188d408a3cbc81ed3897e6.tar.gz
caxlsx-ae75ef360e3e0da253188d408a3cbc81ed3897e6.zip
Fixed LineChart and refactored chart axes management
Diffstat (limited to 'lib/axlsx/drawing/scatter_chart.rb')
-rw-r--r--lib/axlsx/drawing/scatter_chart.rb41
1 files changed, 24 insertions, 17 deletions
diff --git a/lib/axlsx/drawing/scatter_chart.rb b/lib/axlsx/drawing/scatter_chart.rb
index 2b801642..f069e346 100644
--- a/lib/axlsx/drawing/scatter_chart.rb
+++ b/lib/axlsx/drawing/scatter_chart.rb
@@ -12,35 +12,40 @@ module Axlsx
# The Style for the scatter chart
# must be one of :none | :line | :lineMarker | :marker | :smooth | :smoothMarker
# return [Symbol]
- attr_reader :scatterStyle
+ attr_reader :scatter_style
+ alias :scatterStyle :scatter_style
# the x value axis
# @return [ValAxis]
- attr_reader :xValAxis
+ def x_val_axis
+ axes[:x_val_axis]
+ end
+ alias :xValAxis :x_val_axis
# the y value axis
# @return [ValAxis]
- attr_reader :yValAxis
+ def y_val_axis
+ axes[:x_val_axis]
+ end
+ alias :yValAxis :y_val_axis
# Creates a new scatter chart
def initialize(frame, options={})
@vary_colors = 0
- @scatterStyle = :lineMarker
- @xValAxId = rand(8 ** 8)
- @yValAxId = rand(8 ** 8)
- @xValAxis = ValAxis.new(@xValAxId, @yValAxId)
- @yValAxis = ValAxis.new(@yValAxId, @xValAxId)
- super(frame, options)
+ @scatter_style = :lineMarker
+
+ super(frame, options)
@series_type = ScatterSeries
@d_lbls = nil
parse_options options
end
# see #scatterStyle
- def scatterStyle=(v)
+ def scatter_style=(v)
Axlsx.validate_scatter_style(v)
- @scatterStyle = v
+ @scatter_style = v
end
+ alias :scatterStyle= :scatter_style=
# Serializes the object
# @param [String] str
@@ -48,17 +53,19 @@ module Axlsx
def to_xml_string(str = '')
super(str) do |str_inner|
str_inner << '<c:scatterChart>'
- str_inner << '<c:scatterStyle val="' << scatterStyle.to_s << '"/>'
+ str_inner << '<c:scatterStyle val="' << scatter_style.to_s << '"/>'
str_inner << '<c:varyColors val="' << vary_colors.to_s << '"/>'
@series.each { |ser| ser.to_xml_string(str_inner) }
- d_lbls.to_xml_string(str) if @d_lbls
- str_inner << '<c:axId val="' << @xValAxId.to_s << '"/>'
- str_inner << '<c:axId val="' << @yValAxId.to_s << '"/>'
+ d_lbls.to_xml_string(str_inner) if @d_lbls
+ axes.to_xml_string(str_inner, :ids => true)
str_inner << '</c:scatterChart>'
- @xValAxis.to_xml_string str_inner
- @yValAxis.to_xml_string str_inner
+ axes.to_xml_string(str_inner)
end
str
end
+
+ def axes
+ @axes ||= Axes.new(:x_val_axis => ValAxis, :y_val_axis => ValAxis)
+ end
end
end