Class: Writexlsx::Chart::Series

Inherits:
Object
  • Object
show all
Includes:
Gradient, Utility
Defined in:
lib/write_xlsx/chart/series.rb

Constant Summary

Constants included from Utility

Utility::COL_MAX, Utility::ROW_MAX, Utility::SHEETNAME_MAX, Utility::STR_MAX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Gradient

#gradient_properties

Methods included from Utility

#absolute_char, #check_dimensions, #check_dimensions_and_update_max_min_values, #check_parameter, #convert_date_time, #dash_types, delete_files, #fill_properties, #float_to_str, #layout_properties, #line_fill_properties, #line_properties, #palette_color, #pixels_to_points, #process_workbook_options, #ptrue?, #put_deprecate_message, #quote_sheetname, #r_id_attributes, #row_col_notation, #shape_style_base, #store_col_max_min_values, #store_row_max_min_values, #substitute_cellref, #underline_attributes, #v_shape_attributes_base, #v_shape_style_base, #value_or_raise, #write_anchor, #write_auto_fill, #write_color, #write_comment_path, #write_div, #write_fill, #write_font, #write_stroke, #write_xml_declaration, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell, #xml_str

Constructor Details

#initialize(chart, params = {}) ⇒ Series

Returns a new instance of Series.


178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/write_xlsx/chart/series.rb', line 178

def initialize(chart, params = {})
  @chart      = chart
  @values     = aref_to_formula(params[:values])
  @categories = aref_to_formula(params[:categories])
  @name, @name_formula =
    chart.process_names(params[:name], params[:name_formula])

  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]

  @label_positions = chart.label_positions
  @label_position_default = chart.label_position_default
  @labels     = labels_properties(params[:data_labels])

  [:smooth, :invert_if_negative, :x2_axis, :y2_axis].
    each { |key| instance_variable_set("@#{key}", params[key]) }
end

Instance Attribute Details

#cat_data_idObject (readonly)

Returns the value of attribute cat_data_id


173
174
175
# File 'lib/write_xlsx/chart/series.rb', line 173

def cat_data_id
  @cat_data_id
end

#categoriesObject (readonly)

Returns the value of attribute categories


172
173
174
# File 'lib/write_xlsx/chart/series.rb', line 172

def categories
  @categories
end

#error_barsObject (readonly)

Returns the value of attribute error_bars


175
176
177
# File 'lib/write_xlsx/chart/series.rb', line 175

def error_bars
  @error_bars
end

#fillObject (readonly)

Returns the value of attribute fill


173
174
175
# File 'lib/write_xlsx/chart/series.rb', line 173

def fill
  @fill
end

#gradientObject (readonly)

Returns the value of attribute gradient


173
174
175
# File 'lib/write_xlsx/chart/series.rb', line 173

def gradient
  @gradient
end

#invert_if_negativeObject (readonly)

Returns the value of attribute invert_if_negative


174
175
176
# File 'lib/write_xlsx/chart/series.rb', line 174

def invert_if_negative
  @invert_if_negative
end

#labelsObject (readonly)

Returns the value of attribute labels


174
175
176
# File 'lib/write_xlsx/chart/series.rb', line 174

def labels
  @labels
end

#lineObject

Returns the value of attribute line


176
177
178
# File 'lib/write_xlsx/chart/series.rb', line 176

def line
  @line
end

#markerObject

Returns the value of attribute marker


176
177
178
# File 'lib/write_xlsx/chart/series.rb', line 176

def marker
  @marker
end

#nameObject (readonly)

Returns the value of attribute name


172
173
174
# File 'lib/write_xlsx/chart/series.rb', line 172

def name
  @name
end

#name_formulaObject (readonly)

Returns the value of attribute name_formula


172
173
174
# File 'lib/write_xlsx/chart/series.rb', line 172

def name_formula
  @name_formula
end

#name_idObject (readonly)

Returns the value of attribute name_id


172
173
174
# File 'lib/write_xlsx/chart/series.rb', line 172

def name_id
  @name_id
end

#pointsObject (readonly)

Returns the value of attribute points


175
176
177
# File 'lib/write_xlsx/chart/series.rb', line 175

def points
  @points
end

#smoothObject (readonly)

Returns the value of attribute smooth


174
175
176
# File 'lib/write_xlsx/chart/series.rb', line 174

def smooth
  @smooth
end

#trendlineObject (readonly)

Returns the value of attribute trendline


174
175
176
# File 'lib/write_xlsx/chart/series.rb', line 174

def trendline
  @trendline
end

#val_data_idObject (readonly)

Returns the value of attribute val_data_id


173
174
175
# File 'lib/write_xlsx/chart/series.rb', line 173

def val_data_id
  @val_data_id
end

#valuesObject (readonly)

Returns the value of attribute values


172
173
174
# File 'lib/write_xlsx/chart/series.rb', line 172

def values
  @values
end

#x2_axisObject (readonly)

Returns the value of attribute x2_axis


175
176
177
# File 'lib/write_xlsx/chart/series.rb', line 175

def x2_axis
  @x2_axis
end

#y2_axisObject (readonly)

Returns the value of attribute y2_axis


175
176
177
# File 'lib/write_xlsx/chart/series.rb', line 175

def y2_axis
  @y2_axis
end

Instance Method Details

#==(other) ⇒ Object


206
207
208
209
210
211
212
213
214
215
# File 'lib/write_xlsx/chart/series.rb', line 206

def ==(other)
  methods = %w[categories values name name_formula name_id
           cat_data_id val_data_id
           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
end

#line_defined?Boolean

Returns:

  • (Boolean)

217
218
219
# File 'lib/write_xlsx/chart/series.rb', line 217

def line_defined?
  line && ptrue?(line[:_defined])
end