lib/write_xlsx/chart/series.rb in write_xlsx-0.83.0 vs lib/write_xlsx/chart/series.rb in write_xlsx-0.85.1

- old
+ new

@@ -1,11 +1,14 @@ # -*- coding: utf-8 -*- module Writexlsx class Chart + require 'write_xlsx/gradient' + class Chartline include Writexlsx::Utility + include Writexlsx::Gradient attr_reader :line, :fill, :type def initialize(params) @line = params[:line] @@ -13,12 +16,16 @@ # Set the line properties for the marker.. @line = line_properties(@line) # Allow 'border' as a synonym for 'line'. @line = line_properties(params[:border]) if params[:border] + # Set the gradient fill properties for the series. + @gradient = gradient_properties(params[:gradient]) + # Set the fill properties for the marker. @fill = fill_properties(@fill) + @fill = nil if ptrue?(@gradient) end def line_defined? line && ptrue?(line[:_defined]) end @@ -158,13 +165,14 @@ end end class Series include Writexlsx::Utility + include Writexlsx::Gradient attr_reader :values, :categories, :name, :name_formula, :name_id - attr_reader :cat_data_id, :val_data_id, :fill + attr_reader :cat_data_id, :val_data_id, :fill, :gradient attr_reader :trendline, :smooth, :labels, :invert_if_negative attr_reader :x2_axis, :y2_axis, :error_bars, :points attr_accessor :line, :marker def initialize(chart, params = {}) @@ -177,10 +185,13 @@ set_data_ids(params) @line = line_properties(params[:border] || params[:line]) @fill = fill_properties(params[:fill]) + @gradient = gradient_properties(params[:gradient]) + @fill = nil if ptrue?(@gradient) + @marker = Marker.new(params[:marker]) if params[:marker] @trendline = Trendline.new(params[:trendline]) if params[:trendline] @error_bars = errorbars(params[:x_error_bars], params[:y_error_bars]) @points = params[:points].collect { |p| p ? Point.new(p) : p } if params[:points] @@ -193,10 +204,10 @@ end def ==(other) methods = %w[categories values name name_formula name_id cat_data_id val_data_id - line fill marker trendline + line fill gradient marker trendline smooth labels invert_if_neg x2_axis y2_axis error_bars points ] methods.each do |method| return false unless self.instance_variable_get("@#{method}") == other.instance_variable_get("@#{method}") end true