summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rwxr-xr-xexamples/example.rb3
-rw-r--r--lib/axlsx/drawing/line_chart.rb3
-rw-r--r--lib/axlsx/drawing/line_series.rb12
-rw-r--r--test/drawing/tc_line_chart.rb1
-rw-r--r--test/drawing/tc_line_series.rb12
6 files changed, 25 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index 64aac637..95ae026c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,5 @@ examples/sprk2012
.bundle/config
.~lock*
*.qcachegrind
+*.iml
+.idea \ No newline at end of file
diff --git a/examples/example.rb b/examples/example.rb
index 3e409f2d..f8ed9241 100755
--- a/examples/example.rb
+++ b/examples/example.rb
@@ -468,10 +468,9 @@ if examples.include? :line_chart
chart.valAxis.title = 'Y Axis'
end
sheet.add_chart(Axlsx::LineChart, :title => "Simple Line Chart", :rotX => 30, :rotY => 20) do |chart|
- chart.smooth = true
chart.start_at 0, 21
chart.end_at 10, 41
- chart.add_series :data => sheet["A3:A6"], :title => sheet["A2"], :color => "FF0000"
+ chart.add_series :data => sheet["A3:A6"], :title => sheet["A2"], :color => "FF0000", show_marker => true, :smooth => true
chart.add_series :data => sheet["B3:B6"], :title => sheet["B2"], :color => "00FF00"
chart.catAxis.title = 'X Axis'
chart.valAxis.title = 'Y Axis'
diff --git a/lib/axlsx/drawing/line_chart.rb b/lib/axlsx/drawing/line_chart.rb
index 8ff32412..699050dc 100644
--- a/lib/axlsx/drawing/line_chart.rb
+++ b/lib/axlsx/drawing/line_chart.rb
@@ -39,8 +39,6 @@ module Axlsx
# @return [Symbol]
attr_reader :grouping
- attr_accessor :smooth
-
# Creates a new line chart object
# @param [GraphicFrame] frame The workbook that owns this chart.
# @option options [Cell, String] title
@@ -85,7 +83,6 @@ module Axlsx
@series.each { |ser| ser.to_xml_string(str_inner) }
@d_lbls.to_xml_string(str_inner) if @d_lbls
yield str_inner if block_given?
- str_inner << '<c:smooth val="1"/>' if smooth
axes.to_xml_string(str_inner, :ids => true)
str_inner << "</c:" << node_name << ">"
axes.to_xml_string(str_inner)
diff --git a/lib/axlsx/drawing/line_series.rb b/lib/axlsx/drawing/line_series.rb
index b011e0b6..93478b8f 100644
--- a/lib/axlsx/drawing/line_series.rb
+++ b/lib/axlsx/drawing/line_series.rb
@@ -23,12 +23,17 @@ module Axlsx
# @return [Boolean]
attr_reader :show_marker
+ # line smoothing on values
+ # @return [Boolean]
+ attr_reader :smooth
+
# Creates a new series
# @option options [Array, SimpleTypedList] data
# @option options [Array, SimpleTypedList] labels
# @param [Chart] chart
def initialize(chart, options={})
@show_marker = false
+ @smooth = false
@labels, @data = nil, nil
super(chart, options)
@labels = AxDataSource.new(:data => options[:labels]) unless options[:labels].nil?
@@ -46,6 +51,12 @@ module Axlsx
@show_marker = v
end
+ # @see smooth
+ def smooth=(v)
+ Axlsx::validate_boolean(v)
+ @smooth = v
+ end
+
# Serializes the object
# @param [String] str
# @return [String]
@@ -66,6 +77,7 @@ module Axlsx
str << '<c:marker><c:symbol val="none"/></c:marker>' unless @show_marker
@labels.to_xml_string(str) unless @labels.nil?
@data.to_xml_string(str) unless @data.nil?
+ str << '<c:smooth val="' << ((smooth) ? '1' : '0') << '"/>'
end
end
diff --git a/test/drawing/tc_line_chart.rb b/test/drawing/tc_line_chart.rb
index a14f75dc..0783edae 100644
--- a/test/drawing/tc_line_chart.rb
+++ b/test/drawing/tc_line_chart.rb
@@ -7,7 +7,6 @@ class TestLineChart < Test::Unit::TestCase
ws = @p.workbook.add_worksheet
@row = ws.add_row ["one", 1, Time.now]
@chart = ws.add_chart Axlsx::LineChart, :title => "fishery"
- @chart.smooth = true
end
def teardown
diff --git a/test/drawing/tc_line_series.rb b/test/drawing/tc_line_series.rb
index 866553c3..3d023a12 100644
--- a/test/drawing/tc_line_series.rb
+++ b/test/drawing/tc_line_series.rb
@@ -6,7 +6,7 @@ class TestLineSeries < Test::Unit::TestCase
p = Axlsx::Package.new
@ws = p.workbook.add_worksheet :name=>"hmmm"
chart = @ws.add_chart Axlsx::Line3DChart, :title => "fishery"
- @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob", :color => "#FF0000", :show_marker => true
+ @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob", :color => "#FF0000", :show_marker => true, :smooth => true
end
def test_initialize
@@ -20,11 +20,19 @@ class TestLineSeries < Test::Unit::TestCase
assert_equal(true, @series.show_marker)
@series.show_marker = false
assert_equal(false, @series.show_marker)
- end
+ end
+
+ def test_smooth
+ assert_equal(true, @series.smooth)
+ @series.smooth = false
+ assert_equal(false, @series.smooth)
+ end
+
def test_to_xml_string
doc = Nokogiri::XML(@series.to_xml_string)
assert(doc.xpath("//srgbClr[@val='#{@series.color}']"))
assert(doc.xpath("//marker"))
+ assert(doc.xpath("//smooth"))
end
#TODO serialization testing
end