lib/write_xlsx/chart/scatter.rb in write_xlsx-1.09.4 vs lib/write_xlsx/chart/scatter.rb in write_xlsx-1.09.5
- old
+ new
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
+
###############################################################################
#
# Scatter - A class for writing Excel Scatter charts.
#
# Used in conjunction with Chart.
@@ -30,25 +31,25 @@
@smooth_allowed = 1
# Set the available data label positions for this chart type.
@label_position_default = 'right'
@label_positions = {
- 'center' => 'ctr',
- 'right' => 'r',
- 'left' => 'l',
- 'above' => 't',
- 'below' => 'b',
+ 'center' => 'ctr',
+ 'right' => 'r',
+ 'left' => 'l',
+ 'above' => 't',
+ 'below' => 'b',
# For backward compatibility.
- 'top' => 't',
- 'bottom' => 'b'
+ 'top' => 't',
+ 'bottom' => 'b'
}
end
#
# Override parent method to add a warning.
#
- def combine(chart)
+ def combine(_chart)
raise 'Combined chart not currently supported with scatter chart as the primary chart'
end
#
# Override the virtual superclass method with a chart specific method.
@@ -60,29 +61,29 @@
#
# Write the <c:scatterChart> element.
#
def write_scatter_chart(params)
- if params[:primary_axes] == 1
- series = get_primary_axes_series
- else
- series = get_secondary_axes_series
- end
+ series = if params[:primary_axes] == 1
+ get_primary_axes_series
+ else
+ get_secondary_axes_series
+ end
return if series.empty?
- style = 'lineMarker'
+ style = 'lineMarker'
# Set the user defined chart subtype
- style = 'smoothMarker' if ['smooth_with_markers', 'smooth'].include?(@subtype)
+ style = 'smoothMarker' if %w[smooth_with_markers smooth].include?(@subtype)
# Add default formatting to the series data.
modify_series_formatting
@writer.tag_elements('c:scatterChart') do
# Write the c:scatterStyle element.
write_scatter_style(style)
# Write the series elements.
- series.each {|s| write_series(s)}
+ series.each { |s| write_series(s) }
# Write the c:marker element.
write_marker_value
# Write the c:axId elements
write_axis_ids(params)
end
@@ -185,11 +186,11 @@
#
# Write the <c:scatterStyle> element.
#
def write_scatter_style(val)
- @writer.empty_tag('c:scatterStyle', [ ['val', val] ])
+ @writer.empty_tag('c:scatterStyle', [['val', val]])
end
#
# Add default formatting to the series data unless it has already been
# specified by the user.
@@ -198,23 +199,19 @@
# The default scatter style "markers only" requires a line type
if @subtype == 'marker_only'
# Go through each series and define default values.
@series.each do |series|
# Set a line type unless there is already a user defined type.
- unless series.line_defined?
- series.line = line_properties(:width => 2.25, :none => 1, :_defined => 1)
- end
+ series.line = line_properties(:width => 2.25, :none => 1, :_defined => 1) unless series.line_defined?
end
end
# Turn markers off for subtypes that don't have them
unless @subtype =~ /marker/
# Go through each series and define default values.
@series.each do |series|
# Set a marker type unless there is already a user defined type.
- unless ptrue?(series.marker)
- series.marker = Marker.new(:type => 'none', :_defined => 1)
- end
+ series.marker = Marker.new(:type => 'none', :_defined => 1) unless ptrue?(series.marker)
end
end
end
#