lib/write_xlsx/chart.rb in write_xlsx-0.69.0 vs lib/write_xlsx/chart.rb in write_xlsx-0.70.0
- old
+ new
@@ -573,10 +573,11 @@
@x_scale = 1
@y_scale = 1
@x_offset = 0
@y_offset = 0
@table = nil
+ @smooth_allowed = 0
set_default_properties
end
def set_xml_writer(filename) # :nodoc:
@@ -1116,10 +1117,13 @@
marker = marker_properties(params[:marker])
# Set the trendline properties for the series.
trendline = trendline_properties(params[:trendline])
+ # Set the line smooth property for the series.
+ smooth = params[:smooth]
+
# Set the error bars properties for the series.
y_error_bars = error_bars_properties(params[:y_error_bars])
x_error_bars = error_bars_properties(params[:x_error_bars])
# Set the point properties for the series.
@@ -1156,10 +1160,11 @@
:_cat_data_id => cat_id,
:_line => line,
:_fill => fill,
:_marker => marker,
:_trendline => trendline,
+ :_smooth => smooth,
:_labels => labels,
:_invert_if_neg => invert_if_neg,
:_x2_axis => x2_axis,
:_y2_axis => y2_axis,
:_points => points,
@@ -1279,10 +1284,11 @@
# name
# size
# bold
# italic
# underline
+ # rotation
# color
#
# The following explains the available font properties:
#
# ===name
@@ -1308,10 +1314,17 @@
# ===underline
# Set the font underline property, should be 0 or 1:
#
# chart.set_x_axis( :num_font => { :underline => 1 } )
#
+ # ===rotation
+ # See the font rotation in the range -90 to 90:
+ #
+ # chart.set_x_axis(:num_font => { :rotation => 45 })
+ #
+ # This is useful for displaying large axis data such as dates in a more compact format.
+ #
# ===color
# Set the font color property. Can be a color index, a color name or HTML
# style RGB colour:
#
# chart.set_x_axis( :num_font => { :color => 'red' } )
@@ -2572,10 +2585,12 @@
write_error_bars(series[:_error_bars])
# Write the c:cat element.
write_cat(series)
# Write the c:val element.
write_val(series)
+ # Write the c:smooth element.
+ write_c_smooth(series[:_smooth]) if ptrue?(@smooth_allowed)
end
end
#
# Write the <c:idx> element.
@@ -4147,9 +4162,20 @@
#
# Write the <c:upBars> element.
#
def write_down_bars(format)
write_bars_base('c:downBars', format)
+ end
+
+ #
+ # Write the <c:smooth> element.
+ #
+ def write_c_smooth(smooth)
+ return unless ptrue?(smooth)
+
+ attributes = ['val', 1]
+
+ @writer.empty_tag('c:smooth', attributes)
end
def write_bars_base(tag, format)
if ptrue?(format[:_line][:_defined]) || ptrue?(format[:_fill][:_defined])
@writer.tag_elements(tag) { write_sp_pr(format) }