diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/axlsx/drawing/bar_series.rb | 16 | ||||
| -rw-r--r-- | lib/axlsx/drawing/line_series.rb | 18 | ||||
| -rw-r--r-- | lib/axlsx/drawing/pie_series.rb | 2 | ||||
| -rw-r--r-- | lib/axlsx/drawing/scatter_series.rb | 28 |
4 files changed, 54 insertions, 10 deletions
diff --git a/lib/axlsx/drawing/bar_series.rb b/lib/axlsx/drawing/bar_series.rb index 63c20a31..25523410 100644 --- a/lib/axlsx/drawing/bar_series.rb +++ b/lib/axlsx/drawing/bar_series.rb @@ -35,7 +35,7 @@ module Axlsx @colors = [] super(chart, options) self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil? - self.data = ValAxisData.new(options[:data]) unless options[:data].nil? + self.data = NamedAxisData.new(:val, options[:data]) unless options[:data].nil? end # @see colors @@ -53,16 +53,18 @@ module Axlsx # @return [String] def to_xml_string(str = '') super(str) do |str_inner| + colors.each_with_index do |c, index| - str << '<c:dPt>' - str << '<c:idx val="' << index.to_s << '"/>' - str << '<c:spPr><a:solidFill>' - str << '<a:srgbClr val="' << c << '"/>' - str << '</a:solidFill></c:spPr></c:dPt>' + str_inner << '<c:dPt>' + str_inner << '<c:idx val="' << index.to_s << '"/>' + str_inner << '<c:spPr><a:solidFill>' + str_inner << '<a:srgbClr val="' << c << '"/>' + str_inner << '</a:solidFill></c:spPr></c:dPt>' end + @labels.to_xml_string(str_inner) unless @labels.nil? @data.to_xml_string(str_inner) unless @data.nil? - str_inner << '<c:shape val="' << @shape.to_s << '"/>' + str_inner << '<c:shape val="' << shape.to_s << '"></c:shape>' end end diff --git a/lib/axlsx/drawing/line_series.rb b/lib/axlsx/drawing/line_series.rb index ac3840f1..1d785a23 100644 --- a/lib/axlsx/drawing/line_series.rb +++ b/lib/axlsx/drawing/line_series.rb @@ -14,6 +14,11 @@ module Axlsx # @return [CatAxisData] attr_reader :labels + # 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 series # @option options [Array, SimpleTypedList] data # @option options [Array, SimpleTypedList] labels @@ -22,7 +27,12 @@ module Axlsx @labels, @data = nil, nil super(chart, options) @labels = CatAxisData.new(options[:labels]) unless options[:labels].nil? - @data = ValAxisData.new(options[:data]) unless options[:data].nil? + @data = NamedAxisData.new('val', options[:data]) unless options[:data].nil? + end + + # @see color + def color=(v) + @color = v end # Serializes the object @@ -30,6 +40,12 @@ module Axlsx # @return [String] def to_xml_string(str = '') super(str) do + if color + str << '<c:spPr><a:solidFill>' + str << '<a:srgbClr val="' << color << '"/>' + str << '</a:solidFill></c:spPr>' + end + @labels.to_xml_string(str) unless @labels.nil? @data.to_xml_string(str) unless @data.nil? end diff --git a/lib/axlsx/drawing/pie_series.rb b/lib/axlsx/drawing/pie_series.rb index 7e518886..13f3cd5d 100644 --- a/lib/axlsx/drawing/pie_series.rb +++ b/lib/axlsx/drawing/pie_series.rb @@ -33,7 +33,7 @@ module Axlsx @colors = [] super(chart, options) self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil? - self.data = ValAxisData.new(options[:data]) unless options[:data].nil? + self.data = NamedAxisData.new(:val, options[:data]) unless options[:data].nil? end # @see colors diff --git a/lib/axlsx/drawing/scatter_series.rb b/lib/axlsx/drawing/scatter_series.rb index 2469e0bf..3f4bf289 100644 --- a/lib/axlsx/drawing/scatter_series.rb +++ b/lib/axlsx/drawing/scatter_series.rb @@ -16,20 +16,46 @@ module Axlsx # @return [NamedAxisData] attr_reader :yData + # 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 ScatterSeries def initialize(chart, options={}) @xData, @yData = nil super(chart, options) - @xData = NamedAxisData.new("xVal", options[:xData]) unless options[:xData].nil? @yData = NamedAxisData.new("yVal", options[:yData]) unless options[:yData].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? end |
