diff options
| -rw-r--r-- | lib/axlsx/drawing/chart.rb | 12 | ||||
| -rw-r--r-- | test/drawing/tc_chart.rb | 13 |
2 files changed, 25 insertions, 0 deletions
diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb index 723c79d8..500353cf 100644 --- a/lib/axlsx/drawing/chart.rb +++ b/lib/axlsx/drawing/chart.rb @@ -15,6 +15,7 @@ module Axlsx # @option options [Array|String|Cell] start_at The X, Y coordinates defining the top left corner of the chart. # @option options [Array|String|Cell] end_at The X, Y coordinates defining the bottom right corner of the chart. # @option options [Boolean] plot_visible_only (true) Whether only data from visible cells should be plotted. + # @option options [Boolean] rounded_corners (true) Whether the chart area shall have rounded corners. def initialize(frame, options={}) @style = 18 @view_3D = nil @@ -28,6 +29,7 @@ module Axlsx @title = Title.new @bg_color = nil @plot_visible_only = true + @rounded_corners = true parse_options options start_at(*options[:start_at]) if options[:start_at] end_at(*options[:end_at]) if options[:end_at] @@ -104,6 +106,10 @@ module Axlsx # @return [Boolean] attr_reader :plot_visible_only + # Whether the chart area shall have rounded corners. + # @return [Boolean] + attr_reader :rounded_corners + # The relationship object for this chart. # @return [Relationship] def relationship @@ -191,6 +197,11 @@ module Axlsx # @return [Boolean] def plot_visible_only=(v) Axlsx::validate_boolean(v); @plot_visible_only = v; end + # Whether the chart area shall have rounded corners. + # @param [Boolean] v + # @return [Boolean] + def rounded_corners=(v) Axlsx::validate_boolean(v); @rounded_corners = v; end + # Serializes the object # @param [String] str # @return [String] @@ -198,6 +209,7 @@ module Axlsx str << '<?xml version="1.0" encoding="UTF-8"?>' str << ('<c:chartSpace xmlns:c="' << XML_NS_C << '" xmlns:a="' << XML_NS_A << '" xmlns:r="' << XML_NS_R << '">') str << ('<c:date1904 val="' << Axlsx::Workbook.date1904.to_s << '"/>') + str << ('<c:roundedCorners val="' << rounded_corners.to_s << '"/>') str << ('<c:style val="' << style.to_s << '"/>') str << '<c:chart>' @title.to_xml_string(str) unless @title.empty? diff --git a/test/drawing/tc_chart.rb b/test/drawing/tc_chart.rb index c3392f26..65d7877c 100644 --- a/test/drawing/tc_chart.rb +++ b/test/drawing/tc_chart.rb @@ -120,6 +120,13 @@ class TestChart < Test::Unit::TestCase assert_raise(ArgumentError) { @chart.plot_visible_only = "" } end + def test_rounded_corners + assert(@chart.rounded_corners, "default should be true") + @chart.rounded_corners = false + assert_false(@chart.rounded_corners) + assert_raise(ArgumentError) { @chart.rounded_corners = "" } + end + def test_to_xml_string schema = Nokogiri::XML::Schema(File.open(Axlsx::DRAWING_XSD)) doc = Nokogiri::XML(@chart.to_xml_string) @@ -148,4 +155,10 @@ class TestChart < Test::Unit::TestCase @chart.plot_visible_only = false assert_equal("false", Nokogiri::XML(@chart.to_xml_string).xpath("//c:plotVisOnly").attr("val").value) end + + def test_to_xml_string_for_rounded_corners + assert_equal("true", Nokogiri::XML(@chart.to_xml_string).xpath("//c:roundedCorners").attr("val").value) + @chart.rounded_corners = false + assert_equal("false", Nokogiri::XML(@chart.to_xml_string).xpath("//c:roundedCorners").attr("val").value) + end end |
