lib/write_xlsx/chart.rb in write_xlsx-0.58.0 vs lib/write_xlsx/chart.rb in write_xlsx-0.59.0
- old
+ new
@@ -2109,11 +2109,12 @@
write_c_minor_unit(y_axis[:_minor_unit])
end
end
#
- # Write the <c:valAx> element. This is for the second valAx in scatter plots.
+ # Write the <c:valAx> element.
+ # This is for the second valAx in scatter plots.
#
# Usually the X axis.
#
def write_cat_val_axis(params) # :nodoc:
x_axis = params[:x_axis]
@@ -2526,37 +2527,31 @@
#
# Write the <c:majorGridlines> element.
#
def write_major_gridlines(gridlines) # :nodoc:
- return unless gridlines
- return unless ptrue?(gridlines[:_visible])
-
- if gridlines[:_line] && ptrue?(gridlines[:_line][:_defined])
- @writer.tag_elements('c:majorGridlines') do
- # Write the c:spPr element.
- write_sp_pr(gridlines)
- end
- else
- @writer.empty_tag('c:majorGridlines')
- end
+ write_gridlines_common(gridlines, 'c:majorGridlines')
end
#
# Write the <c:minorGridlines> element.
#
def write_minor_gridlines(gridlines) # :nodoc:
+ write_gridlines_common(gridlines, 'c:minorGridlines')
+ end
+
+ def write_gridlines_common(gridlines, tag) # :nodoc:
return unless gridlines
return unless ptrue?(gridlines[:_visible])
if gridlines[:_line] && ptrue?(gridlines[:_line][:_defined])
- @writer.tag_elements('c:minorGridlines') do
+ @writer.tag_elements(tag) do
# Write the c:spPr element.
write_sp_pr(gridlines)
end
else
- @writer.empty_tag('c:minorGridlines')
+ @writer.empty_tag(tag)
end
end
#
# Write the <c:crossBetween> element.
@@ -2878,26 +2873,14 @@
#
# Write the <a:defRPr> element.
#
def write_a_def_rpr(font = nil) # :nodoc:
- style_attributes = get_font_style_attributes(font)
- latin_attributes = get_font_latin_attributes(font)
- has_color = ptrue?(font) && ptrue?(font[:_color])
-
- if !latin_attributes.empty? || has_color
- @writer.tag_elements('a:defRPr', style_attributes) do
- if has_color
- write_a_solid_fill(:color => font[:_color])
- end
- if !latin_attributes.empty?
- write_a_latin(latin_attributes)
- end
- end
- else
- @writer.empty_tag('a:defRPr', style_attributes)
- end
+ write_def_rpr_r_pr_common(
+ font,
+ get_font_style_attributes(font),
+ 'a:defRPr')
end
#
# Write the <a:endParaRPr> element.
#
@@ -2923,29 +2906,31 @@
#
# Write the <a:rPr> element.
#
def write_a_r_pr(font) # :nodoc:
- lang = 'en-US'
+ write_def_rpr_r_pr_common(
+ font,
+ get_font_style_attributes(font).unshift('en-US').unshift('lang'),
+ 'a:rPr'
+ )
+ end
- style_attributes = get_font_style_attributes(font)
+ def write_def_rpr_r_pr_common(font, style_attributes, tag) # :nodoc:
latin_attributes = get_font_latin_attributes(font)
has_color = ptrue?(font) && ptrue?(font[:_color])
- # Add the lang type to the attributes.
- style_attributes.unshift(lang).unshift('lang')
-
if !latin_attributes.empty? || has_color
- @writer.tag_elements('a:rPr', style_attributes) do
+ @writer.tag_elements(tag, style_attributes) do
if has_color
write_a_solid_fill(:color => font[:_color])
end
if !latin_attributes.empty?
write_a_latin(latin_attributes)
end
end
else
- @writer.empty_tag('a:rPr', style_attributes)
+ @writer.empty_tag(tag, style_attributes)
end
end
#
# Write the <a:t> element.