lib/write_xlsx/chart.rb in write_xlsx-0.87.0 vs lib/write_xlsx/chart.rb in write_xlsx-0.88.0

- old
+ new

@@ -1283,10 +1283,13 @@ write_cat_number_format(x_axis) # Write the c:majorTickMark element. write_major_tick_mark(x_axis.major_tick_mark) + # Write the c:minorTickMark element. + write_minor_tick_mark(x_axis.minor_tick_mark) + # Write the c:tickLblPos element. write_tick_label_pos(x_axis.label_position) # Write the c:spPr element for the axis line. write_sp_pr(x_axis) @@ -1357,10 +1360,13 @@ write_number_format(y_axis) # Write the c:majorTickMark element. write_major_tick_mark(y_axis.major_tick_mark) + # Write the c:minorTickMark element. + write_minor_tick_mark(y_axis.minor_tick_mark) + # Write the c:tickLblPos element. write_tick_label_pos(y_axis.label_position) # Write the c:spPr element for the axis line. write_sp_pr(y_axis) @@ -1580,10 +1586,19 @@ @writer.empty_tag('c:majorTickMark', [ ['val', val] ]) end # + # Write the <c:minorTickMark> element. + # + def write_minor_tick_mark(val) + return unless ptrue?(val) + + @writer.empty_tag('c:minorTickMark', [ ['val', val] ]) + end + + # # Write the <c:tickLblPos> element. # def write_tick_label_pos(val) # :nodoc: val ||= 'nextTo' val = 'nextTo' if val == 'next_to' @@ -2185,21 +2200,41 @@ end # # Write the <a:solidFill> element. # - def write_a_solid_fill(line) # :nodoc: + def write_a_solid_fill(fill) # :nodoc: @writer.tag_elements('a:solidFill') do - # Write the a:srgbClr element. - write_a_srgb_clr(color(line[:color])) if line[:color] + if fill[:color] + # Write the a:srgbClr element. + write_a_srgb_clr(color(fill[:color]), fill[:transparency]) + end end end # # Write the <a:srgbClr> element. # - def write_a_srgb_clr(val) # :nodoc: - @writer.empty_tag('a:srgbClr', [ ['val', val] ]) + def write_a_srgb_clr(color, transparency = nil) # :nodoc: + tag = 'a:srgbClr' + attributes = [ ['val', color] ] + + if ptrue?(transparency) + @writer.tag_elements(tag, attributes) do + write_a_alpha(transparency) + end + else + @writer.empty_tag(tag, attributes) + end + end + + # + # Write the <a:alpha> element. + # + def write_a_alpha(val) + val = (100 - val.to_i) * 1000 + + @writer.empty_tag('a:alpha', [ ['val', val] ]) end # # Write the <a:prstDash> element. #