1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
require 'tc_helper.rb'
class TestScatterSeries < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
@ws = p.workbook.add_worksheet :name=>"hmmm"
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Scatter Chart"
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"exponents", :color => 'FF0000', :smooth => true
end
def test_initialize
assert_equal(@series.title.text, "exponents", "series title has been applied")
end
def test_smoothed_chart_default_smoothing
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Smooth Chart", :scatter_style => :smoothMarker
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"smoothed exponents"
assert(@series.smooth, "series is smooth by default on smooth charts")
end
def test_unsmoothed_chart_default_smoothing
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Unsmooth Chart", :scatter_style => :line
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"unsmoothed exponents"
assert([email protected], "series is not smooth by default on non-smooth charts")
end
def test_explicit_smoothing
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Unsmooth Chart, Smooth Series", :scatter_style => :line
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"smoothed exponents", :smooth => true
assert(@series.smooth, "series is smooth when overriding chart default")
end
def test_explicit_unsmoothing
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "Smooth Chart, Unsmooth Series", :scatter_style => :smoothMarker
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"unsmoothed exponents", :smooth => false
assert([email protected], "series is not smooth when overriding chart default")
end
def test_ln_width
@chart = @ws.add_chart Axlsx::ScatterChart, :title => "ln width", :scatter_style => :line
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :title=>"ln_width"
@series.ln_width = 12700
assert_equal(@series.ln_width, 12700, 'line width assigment is allowed')
end
def test_to_xml_string
@chart.scatter_style = :line
@series.ln_width = 12700
doc = Nokogiri::XML(@chart.to_xml_string)
assert_equal(12700, @series.ln_width)
assert_equal(doc.xpath("//a:srgbClr[@val='#{@series.color}']").size,4)
assert_equal(doc.xpath("//a:ln[@w='#{@series.ln_width}']").length, 1)
end
def test_false_show_marker
@chart = @ws.add_chart Axlsx::ScatterChart, :title => 'Smooth Chart', :scatter_style => :smoothMarker
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9]
assert(@series.show_marker, 'markers are enabled for marker-related styles')
end
def test_true_show_marker
@chart = @ws.add_chart Axlsx::ScatterChart, :title => 'Line chart', :scatter_style => :line
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9]
assert([email protected]_marker, 'markers are disabled for markerless scatter styles')
end
def test_marker_symbol
@chart = @ws.add_chart Axlsx::ScatterChart, :title => 'Line chart', :scatter_style => :line
@series = @chart.add_series :xData=>[1,2,4], :yData=>[1,3,9], :marker_symbol => :diamond
assert_equal(@series.marker_symbol, :diamond, 'series could have own custom marker symbol')
end
end
|