diff options
| author | Jean-Philippe Moal <[email protected]> | 2013-10-09 16:38:35 +0200 |
|---|---|---|
| committer | Jean-Philippe Moal <[email protected]> | 2013-10-09 16:38:35 +0200 |
| commit | 3171fa568618e9d75ead1994ed6e3be90b693a47 (patch) | |
| tree | 2d7d5655f60386a70571eaa287f93045ae9c4317 /lib/axlsx/drawing/bubble_series.rb | |
| parent | 3bf46a00d717d5e991166360bf4a2ece41cc3fbc (diff) | |
| download | caxlsx-3171fa568618e9d75ead1994ed6e3be90b693a47.tar.gz caxlsx-3171fa568618e9d75ead1994ed6e3be90b693a47.zip | |
Add support for bubble charts
Diffstat (limited to 'lib/axlsx/drawing/bubble_series.rb')
| -rw-r--r-- | lib/axlsx/drawing/bubble_series.rb | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/lib/axlsx/drawing/bubble_series.rb b/lib/axlsx/drawing/bubble_series.rb new file mode 100644 index 00000000..161a9a9e --- /dev/null +++ b/lib/axlsx/drawing/bubble_series.rb @@ -0,0 +1,71 @@ +# encoding: UTF-8 +module Axlsx + + # A BubbleSeries defines the x/y position and bubble size of data in the chart + # @note The recommended way to manage series is to use Chart#add_series + # @see Worksheet#add_chart + # @see Chart#add_series + # @see examples/example.rb + class BubbleSeries < Series + + # The x data for this series. + # @return [AxDataSource] + attr_reader :xData + + # The y data for this series. + # @return [NumDataSource] + attr_reader :yData + + # The bubble size for this series. + # @return [NumDataSource] + attr_reader :bubbleSize + + # The fill color for this series. + # Red, green, and blue is expressed as sequence of hex digits, RRGGBB. A perceptual gamma of 2.2 is used. + # @return [String] + attr_reader :color + + # Creates a new BubbleSeries + def initialize(chart, options={}) + @xData, @yData, @bubbleSize = nil + super(chart, options) + @xData = AxDataSource.new(:tag_name => :xVal, :data => options[:xData]) unless options[:xData].nil? + @yData = NumDataSource.new({:tag_name => :yVal, :data => options[:yData]}) unless options[:yData].nil? + @bubbleSize = NumDataSource.new({:tag_name => :bubbleSize, :data => options[:bubbleSize]}) unless options[:bubbleSize].nil? + end + + # @see color + def color=(v) + @color = v + end + + # Serializes the object + # @param [String] str + # @return [String] + def to_xml_string(str = '') + super(str) do |inner_str| + # needs to override the super color here to push in ln/and something else! + if color + str << '<c:spPr><a:solidFill>' + str << '<a:srgbClr val="' << color << '"/>' + str << '</a:solidFill>' + str << '<a:ln><a:solidFill>' + str << '<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>' + str << '</c:spPr>' + str << '<c:marker>' + str << '<c:spPr><a:solidFill>' + str << '<a:srgbClr val="' << color << '"/>' + str << '</a:solidFill>' + str << '<a:ln><a:solidFill>' + str << '<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>' + str << '</c:spPr>' + str << '</c:marker>' + end + @xData.to_xml_string(inner_str) unless @xData.nil? + @yData.to_xml_string(inner_str) unless @yData.nil? + @bubbleSize.to_xml_string(inner_str) unless @bubbleSize.nil? + end + str + end + end +end |
