axlsx 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. data/CHANGELOG.md +32 -0
  2. data/README.md +34 -35
  3. data/Rakefile +19 -8
  4. data/doc/Axlsx.html +4 -4
  5. data/doc/Axlsx/App.html +1 -1
  6. data/doc/Axlsx/Axis.html +45 -19
  7. data/doc/Axlsx/Bar3DChart.html +134 -107
  8. data/doc/Axlsx/BarSeries.html +6 -64
  9. data/doc/Axlsx/Border.html +1 -1
  10. data/doc/Axlsx/BorderPr.html +1 -1
  11. data/doc/Axlsx/CatAxis.html +34 -31
  12. data/doc/Axlsx/CatAxisData.html +400 -0
  13. data/doc/Axlsx/Cell.html +1 -1
  14. data/doc/Axlsx/CellAlignment.html +1 -1
  15. data/doc/Axlsx/CellProtection.html +1 -1
  16. data/doc/Axlsx/CellStyle.html +1 -1
  17. data/doc/Axlsx/Chart.html +449 -212
  18. data/doc/Axlsx/Color.html +1 -1
  19. data/doc/Axlsx/ContentType.html +2 -2
  20. data/doc/Axlsx/Core.html +1 -1
  21. data/doc/Axlsx/DataTypeValidator.html +1 -1
  22. data/doc/Axlsx/Default.html +1 -1
  23. data/doc/Axlsx/Drawing.html +65 -91
  24. data/doc/Axlsx/Fill.html +1 -1
  25. data/doc/Axlsx/Font.html +1 -1
  26. data/doc/Axlsx/GradientFill.html +1 -1
  27. data/doc/Axlsx/GradientStop.html +1 -1
  28. data/doc/Axlsx/GraphicFrame.html +7 -5
  29. data/doc/Axlsx/Line3DChart.html +109 -28
  30. data/doc/Axlsx/LineSeries.html +17 -73
  31. data/doc/Axlsx/Marker.html +1 -1
  32. data/doc/Axlsx/NumFmt.html +1 -1
  33. data/doc/Axlsx/Override.html +1 -1
  34. data/doc/Axlsx/Package.html +1 -1
  35. data/doc/Axlsx/PatternFill.html +1 -1
  36. data/doc/Axlsx/Pie3DChart.html +118 -66
  37. data/doc/Axlsx/PieSeries.html +30 -89
  38. data/doc/Axlsx/RegexValidator.html +1 -1
  39. data/doc/Axlsx/Relationship.html +1 -1
  40. data/doc/Axlsx/Relationships.html +2 -2
  41. data/doc/Axlsx/RestrictionValidator.html +1 -1
  42. data/doc/Axlsx/Row.html +1 -1
  43. data/doc/Axlsx/Scaling.html +1 -1
  44. data/doc/Axlsx/SerAxis.html +52 -37
  45. data/doc/Axlsx/Series.html +25 -10
  46. data/doc/Axlsx/SeriesTitle.html +3 -2
  47. data/doc/Axlsx/SimpleTypedList.html +86 -17
  48. data/doc/Axlsx/Styles.html +1 -1
  49. data/doc/Axlsx/TableStyle.html +2 -2
  50. data/doc/Axlsx/TableStyleElement.html +1 -1
  51. data/doc/Axlsx/TableStyles.html +2 -2
  52. data/doc/Axlsx/Title.html +1 -1
  53. data/doc/Axlsx/TwoCellAnchor.html +40 -280
  54. data/doc/Axlsx/ValAxis.html +7 -8
  55. data/doc/Axlsx/ValAxisData.html +326 -0
  56. data/doc/Axlsx/View3D.html +39 -39
  57. data/doc/Axlsx/Workbook.html +1 -1
  58. data/doc/Axlsx/Worksheet.html +84 -39
  59. data/doc/Axlsx/Xf.html +1 -1
  60. data/doc/_index.html +15 -1
  61. data/doc/class_list.html +1 -1
  62. data/doc/file.README.html +30 -49
  63. data/doc/index.html +30 -49
  64. data/doc/method_list.html +448 -416
  65. data/doc/top-level-namespace.html +1 -1
  66. data/examples/#example.rb# +87 -0
  67. data/examples/example.rb +4 -1
  68. data/examples/multi_chart.xlsx +0 -0
  69. data/lib/axlsx/drawing/#bar_series.rb# +62 -0
  70. data/lib/axlsx/drawing/axis.rb +7 -6
  71. data/lib/axlsx/drawing/bar_3D_chart.rb +12 -30
  72. data/lib/axlsx/drawing/bar_series.rb +6 -35
  73. data/lib/axlsx/drawing/cat_axis.rb +8 -10
  74. data/lib/axlsx/drawing/cat_axis_data.rb +34 -0
  75. data/lib/axlsx/drawing/cat_axis_data.rb~ +28 -0
  76. data/lib/axlsx/drawing/chart.rb +48 -21
  77. data/lib/axlsx/drawing/drawing.rb +14 -12
  78. data/lib/axlsx/drawing/graphic_frame.rb +1 -0
  79. data/lib/axlsx/drawing/line_3D_chart.rb +11 -1
  80. data/lib/axlsx/drawing/line_series.rb +10 -40
  81. data/lib/axlsx/drawing/pie_3D_chart.rb +17 -34
  82. data/lib/axlsx/drawing/pie_series.rb +11 -45
  83. data/lib/axlsx/drawing/ser_axis.rb +13 -14
  84. data/lib/axlsx/drawing/series.rb +2 -3
  85. data/lib/axlsx/drawing/series_title.rb +1 -1
  86. data/lib/axlsx/drawing/two_cell_anchor.rb +10 -34
  87. data/lib/axlsx/drawing/val_axis.rb +4 -4
  88. data/lib/axlsx/drawing/val_axis_data.rb +28 -0
  89. data/lib/axlsx/drawing/val_axis_data.rb~ +29 -0
  90. data/lib/axlsx/drawing/view_3D.rb +12 -6
  91. data/lib/axlsx/util/constants.rb +0 -3
  92. data/lib/axlsx/util/simple_typed_list.rb +7 -2
  93. data/lib/axlsx/version.rb +4 -0
  94. data/lib/axlsx/workbook/worksheet/worksheet.rb +9 -1
  95. data/test/drawing/tc_axis.rb +1 -0
  96. data/test/drawing/tc_cat_axis_data.rb +18 -0
  97. data/test/drawing/tc_cat_axis_data.rb~ +32 -0
  98. data/test/drawing/tc_chart.rb +12 -0
  99. data/test/drawing/tc_line_series.rb +27 -0
  100. data/test/drawing/{tc_line_series.tc → tc_line_series.rb~} +0 -0
  101. data/test/drawing/tc_ser_axis.rb +13 -5
  102. data/test/drawing/tc_two_cell_anchor.rb +18 -17
  103. data/test/drawing/tc_val_axis.rb +5 -0
  104. data/test/drawing/tc_val_axis_data.rb +18 -0
  105. data/test/drawing/tc_val_axis_data.rb~ +18 -0
  106. data/test/drawing/tc_view_3D.rb +10 -1
  107. data/test/tc_package.rb +13 -13
  108. metadata +21 -6
@@ -1,30 +1,29 @@
1
1
  module Axlsx
2
- #A SarAxis object defines a series axis
2
+ #A SerAxis object defines a series axis
3
3
  class SerAxis < Axis
4
4
 
5
- # @return [Boolean]
5
+ # The number of tick lables to skip between labels
6
+ # @return [Integer]
6
7
  attr_accessor :tickLblSkip
7
8
 
9
+ # The number of tickmarks to be skipped before the next one is rendered.
8
10
  # @return [Boolean]
9
11
  attr_accessor :tickMarkSkip
10
12
 
11
13
  # Creates a new SerAxis object
12
- # @param [Integer] axId the id of this axis
13
- # @param [Integer] crossAx the id of the perpendicular axis
14
- # @option options [Symbol] axPos
15
- # @option options [Symbol] tickLblPos
16
- # @option options [Symbol] crosses
17
- # @option options [Boolean] tickLblSkip
18
- # @option options [Symbol] tickMarkSkip
14
+ # @param [Integer] axId the id of this axis. Inherited
15
+ # @param [Integer] crossAx the id of the perpendicular axis. Inherited
16
+ # @option options [Symbol] axPos. Inherited
17
+ # @option options [Symbol] tickLblPos. Inherited
18
+ # @option options [Symbol] crosses. Inherited
19
+ # @option options [Integer] tickLblSkip
20
+ # @option options [Integer] tickMarkSkip
19
21
  def initialize(axId, crossAx, options={})
20
22
  super(axId, crossAx, options)
21
- options.each do |o|
22
- self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
23
- end
24
23
  end
25
24
 
26
- def tickLblSkip=(v) Axlsx::validate_boolean(v); @tickLblSkip = v; end
27
- def tickMarkSkip=(v) Axlsx::validate_boolean(v); @tickMarkSkip = v; end
25
+ def tickLblSkip=(v) Axlsx::validate_unsigned_int(v); @tickLblSkip = v; end
26
+ def tickMarkSkip=(v) Axlsx::validate_unsigned_int(v); @tickMarkSkip = v; end
28
27
 
29
28
  # Serializes the series axis
30
29
  # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
@@ -1,5 +1,5 @@
1
1
  module Axlsx
2
- # A Series defines the title, data and labels for chart data.
2
+ # A Series defines the common series attributes and is the super class for all concrete series types.
3
3
  # @note The recommended way to manage series is to use Chart#add_series
4
4
  # @see Worksheet#add_chart
5
5
  # @see Chart#add_series
@@ -13,7 +13,7 @@ module Axlsx
13
13
  # @return [Integer]
14
14
  attr_reader :index
15
15
 
16
- # The order of this series in the chart's series.
16
+ # The order of this series in the chart's series. By default the order is the index of the series.
17
17
  # @return [Integer]
18
18
  attr_accessor :order
19
19
 
@@ -33,7 +33,6 @@ module Axlsx
33
33
  end
34
34
  end
35
35
 
36
- # retrieves the series index in the chart's series collection
37
36
  def index
38
37
  @chart.series.index(self)
39
38
  end
@@ -1,5 +1,5 @@
1
1
  module Axlsx
2
- # A series title is a Title with a slightly different serialization
2
+ # A series title is a Title with a slightly different serialization than chart titles.
3
3
  class SeriesTitle < Title
4
4
 
5
5
  # Serializes the series title
@@ -23,51 +23,24 @@ module Axlsx
23
23
  # @return [Integer]
24
24
  attr_reader :index
25
25
 
26
- # Creates a new TwoCellAnchor object
26
+ # Creates a new TwoCellAnchor object and sets up a reference to the from and to markers in the
27
+ # graphic_frame's chart. That means that you can do stuff like
28
+ # c = worksheet.add_chart Axlsx::Chart
29
+ # c.start_at 5, 9
27
30
  # @param [Drawing] drawing
28
- # @param [Chart] chart
29
- # @option options [Array] start_at
30
- # @option options [Array] end_at
31
+ # @param [Class] chart_type This is passed to the graphic frame for instantiation. must be Chart or a subclass of Chart
32
+ # @option options [Array] start_at the col, row to start at
33
+ # @option options [Array] end_at the col, row to end at
31
34
  def initialize(drawing, chart_type, options)
32
35
  @drawing = drawing
33
36
  drawing.anchors << self
34
-
35
37
  @from, @to = Marker.new, Marker.new(:col => 5, :row=>10)
36
38
  @graphic_frame = GraphicFrame.new(self, chart_type, options)
37
-
38
- self.start_at(options[:start_at][0], options[:start_at][1]) if options[:start_at].is_a?(Array)
39
- self.end_at(options[:end_at][0], options[:end_at][1]) if options[:end_at].is_a?(Array)
40
- # passing a reference to our start and end markers for convenience
41
- # this lets us access the markers directly from the chart.
42
- @graphic_frame.chart.send(:start_at=, @from)
43
- @graphic_frame.chart.send(:end_at=, @to)
44
39
  end
45
40
 
46
41
  def index
47
42
  @drawing.anchors.index(self)
48
43
  end
49
-
50
-
51
- # This is a short cut method to set the start anchor position
52
- # @param [Integer] x The column
53
- # @param [Integer] y The row
54
- # @return [Marker]
55
- def start_at(x, y)
56
- @from.col = x
57
- @from.row = y
58
- @from
59
- end
60
-
61
- # This is a short cut method to set the end anchor position
62
- # @param [Integer] x The column
63
- # @param [Integer] y The row
64
- # @return [Marker]
65
- def end_at(x, y)
66
- @to.col = x
67
- @to.row = y
68
- @to
69
- end
70
-
71
44
  # Serializes the two cell anchor
72
45
  # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
73
46
  # @return [String]
@@ -84,5 +57,8 @@ module Axlsx
84
57
  xml.send('xdr:clientData')
85
58
  }
86
59
  end
60
+
61
+ private
62
+
87
63
  end
88
64
  end
@@ -2,7 +2,7 @@ module Axlsx
2
2
  # the ValAxis class defines a chart value axis.
3
3
  class ValAxis < Axis
4
4
 
5
- # This element specifies whether the value axis crosses the category axis between categories.
5
+ # This element specifies how the value axis crosses the category axis.
6
6
  # must be one of [:between, :midCat]
7
7
  # @return [Symbol]
8
8
  attr_accessor :crossBetween
@@ -11,17 +11,17 @@ module Axlsx
11
11
  # @param [Integer] axId the id of this axis
12
12
  # @param [Integer] crossAx the id of the perpendicular axis
13
13
  # @option options [Symbol] axPos
14
- # @option options [Symbol] crosses
15
14
  # @option options [Symbol] tickLblPos
15
+ # @option options [Symbol] crosses
16
16
  # @option options [Symbol] crossesBetween
17
17
  def initialize(axId, crossAx, options={})
18
- @crossBetween = :between
18
+ self.crossBetween = :between
19
19
  super(axId, crossAx, options)
20
20
  end
21
21
 
22
22
  def crossBetween=(v) RestrictionValidator.validate "ValAxis.crossBetween", [:between, :midCat], v; @crossBetween = v; end
23
23
 
24
- # Serializes the value axis
24
+ # Serializes the value axis
25
25
  # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
26
26
  # @return [String]
27
27
  def to_xml(xml)
@@ -0,0 +1,28 @@
1
+ module Axlsx
2
+ # The ValAxisData class manages the values for a chart value series.
3
+ class ValAxisData < CatAxisData
4
+
5
+ # Serializes the value axis data
6
+ # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to.
7
+ # @return [String]
8
+ def to_xml(xml)
9
+ xml.send('c:val') {
10
+ xml.send('c:numRef') {
11
+ xml.send('c:f', Axlsx::cell_range(@list))
12
+ xml.send('c:numCache') {
13
+ xml.send('c:formatCode', 'General')
14
+ xml.send('c:ptCount', :val=>size)
15
+ each_with_index do |item, index|
16
+ v = item.is_a?(Cell) ? item.value : item
17
+ xml.send('c:pt', :idx=>index) {
18
+ xml.send('c:v', v)
19
+ }
20
+ end
21
+ }
22
+ }
23
+ }
24
+ end
25
+
26
+ end
27
+
28
+ end
@@ -0,0 +1,29 @@
1
+ module Axlsx
2
+
3
+ class ValAxisData < SimpleTypedList
4
+ def initialize(data=[])
5
+ super Object
6
+ @list.concat data if data.is_a?(Array)
7
+ end
8
+
9
+ def to_xml(xml)
10
+ xml.send('c:val') {
11
+ xml.send('c:numRef') {
12
+ xml.send('c:f', Axlsx::cell_range(@list))
13
+ xml.send('c:numCache') {
14
+ xml.send('c:formatCode', 'General')
15
+ xml.send('c:ptCount', :val=>data.size)
16
+ each_with_index do |item, index|
17
+ v = item.is_a?(Cell) ? item.value : item
18
+ xml.send('c:pt', :idx=>index) {
19
+ xml.send('c:v', v)
20
+ }
21
+ end
22
+ }
23
+ }
24
+ }
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -1,6 +1,13 @@
1
1
  module Axlsx
2
2
  # 3D attributes for a chart.
3
3
  class View3D
4
+
5
+ # Validation for hPercent
6
+ H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/
7
+
8
+ # validation for depthPercent
9
+ DEPTH_PERCENT_REGEX = /0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)%/
10
+
4
11
  # x rotation for the chart
5
12
  # must be between -90 and 90
6
13
  # @return [Integer]
@@ -41,18 +48,17 @@ module Axlsx
41
48
  self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
42
49
  end
43
50
  end
44
-
45
- # Validation for hPercent
46
- H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/
47
-
48
- # validation for depthPercent
49
- DEPTH_PERCENT_REGEX = /0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)%/
50
51
 
51
52
  def rotX=(v) DataTypeValidator.validate "#{self.class}.rotX", [Integer, Fixnum], v, lambda {|v| v >= -90 && v <= 90 }; @rotX = v; end
53
+
52
54
  def hPercent=(v) RegexValidator.validate "#{self.class}.rotX", H_PERCENT_REGEX, v; @hPercent = v; end
55
+
53
56
  def rotY=(v) DataTypeValidator.validate "#{self.class}.rotY", [Integer, Fixnum], v, lambda {|v| v >= 0 && v <= 360 }; @rotY = v; end
57
+
54
58
  def depthPercent=(v) RegexValidator.validate "#{self.class}.depthPercent", DEPTH_PERCENT_REGEX, v; @depthPercent = v; end
59
+
55
60
  def rAngAx=(v) Axlsx::validate_boolean(v); @rAngAx = v; end
61
+
56
62
  def perspective=(v) DataTypeValidator.validate "#{self.class}.perspective", [Integer, Fixnum], v, lambda {|v| v >= 0 && v <= 240 }; @perspective = v; end
57
63
 
58
64
  # Serializes the view3D properties
@@ -1,8 +1,5 @@
1
1
  module Axlsx
2
2
 
3
- # version
4
- VERSION="1.0.6"
5
-
6
3
  # XML Encoding
7
4
  ENCODING = "UTF-8"
8
5
 
@@ -100,6 +100,11 @@ module Axlsx
100
100
  index < @locked_at
101
101
  end
102
102
 
103
+ # override the equality method so that this object can be compared to a simple array.
104
+ # if this object's list is equal to the specifiec array, we return true.
105
+ def ==(v)
106
+ v == @list
107
+ end
103
108
  # method_mission override to pass allowed methods to the list.
104
109
  # @note
105
110
  # the following methods are not allowed
@@ -123,12 +128,12 @@ module Axlsx
123
128
  # :drop_while
124
129
  # :delete_if
125
130
  # :clear
126
- # :concat
127
131
  def method_missing(meth, *args, &block)
128
- raise ArgumentError, "#{meth} not supported" if [:replace, :insert, :collect!, :map!, :pop, :delete_if, :reverse!, :shift, :shuffle!, :slice!, :sort!, :uniq!, :unshift, :zip, :flatten!, :fill, :drop, :drop_while, :delete_if, :clear, :concat].include? meth.to_sym
132
+ raise ArgumentError, "#{meth} not supported" if [:replace, :insert, :collect!, :map!, :pop, :delete_if, :reverse!, :shift, :shuffle!, :slice!, :sort!, :uniq!, :unshift, :zip, :flatten!, :fill, :drop, :drop_while, :delete_if, :clear].include? meth.to_sym
129
133
  if @list.respond_to? meth
130
134
  @list.send(meth, *args, &block)
131
135
  else
136
+ puts "method:#{meth.inspect}"
132
137
  super
133
138
  end
134
139
  end
@@ -0,0 +1,4 @@
1
+ module Axlsx
2
+ # version
3
+ VERSION="1.0.7"
4
+ end
@@ -100,11 +100,19 @@ module Axlsx
100
100
  @rows.last
101
101
  end
102
102
 
103
- # Adds a chart to this worksheets drawing.
103
+ # Adds a chart to this worksheets drawing. This is the recommended way to create charts for your worksheet. This method wraps the complexity of dealing with ooxml drawing, anchors, markers graphic frames chart objects and all the other dirty details.
104
104
  # @param [Class] chart_type
105
105
  # @option options [Array] start_at
106
106
  # @option options [Array] end_at
107
107
  # @option options [Cell, String] title
108
+ # @option options [Boolean] show_legend
109
+ # @option options [Integer] style
110
+ # @note each chart type also specifies additional options
111
+ # @see Chart
112
+ # @see Pie3DChart
113
+ # @see Bar3DChart
114
+ # @see Line3DChart
115
+ # @see README for examples
108
116
  def add_chart(chart_type, options={})
109
117
  chart = drawing.add_chart(chart_type, options)
110
118
  yield chart if block_given?
@@ -14,6 +14,7 @@ class TestAxis < Test::Unit::TestCase
14
14
  assert_equal(@axis.tickLblPos, :nextTo, "tick label position default incorrect")
15
15
  assert_equal(@axis.crosses, :autoZero, "tick label position default incorrect")
16
16
  assert(@axis.scaling.is_a?(Axlsx::Scaling) && @axis.scaling.orientation == :minMax, "scaling default incorrect")
17
+ assert_raise(ArgumentError) { Axlsx::Axis.new -1234, 'abcd' }
17
18
  end
18
19
 
19
20
  def test_axis_position
@@ -0,0 +1,18 @@
1
+ require 'test/unit'
2
+ require 'axlsx.rb'
3
+
4
+ class TestCatAxisData < Test::Unit::TestCase
5
+
6
+ def setup
7
+ p = Axlsx::Package.new
8
+ @ws = p.workbook.add_worksheet
9
+ chart = @ws.drawing.add_chart Axlsx::Bar3DChart
10
+ @series = chart.add_series :labels=>["zero", "one", "two"]
11
+ end
12
+
13
+ def test_initialize
14
+ assert(@series.labels.is_a?Axlsx::SimpleTypedList)
15
+ assert_equal(@series.labels, ["zero", "one", "two"])
16
+ end
17
+
18
+ end
@@ -0,0 +1,32 @@
1
+ require 'test/unit'
2
+ require 'axlsx.rb'
3
+
4
+ class TestCatAxisData < Test::Unit::TestCase
5
+
6
+ def setup
7
+ p = Axlsx::Package.new
8
+ @ws = p.workbook.add_worksheet :name=>"hmmm"
9
+ chart = @ws.drawing.add_chart Axlsx::Bar3DChart, :title => "fishery"
10
+ @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob"
11
+ end
12
+
13
+ def test_initialize
14
+ assert(@series.data.is_a?Axlsx::SimpleTypedList)
15
+ assert_equal(@series.data, [0,1,2], "data option applied")
16
+ end
17
+
18
+ def test_data
19
+ assert_equal(@series.data, [0,1,2])
20
+ end
21
+
22
+ def test_labels
23
+ assert_equal(@series.labels, ["zero", "one", "two"])
24
+ end
25
+
26
+ def test_shape
27
+ assert_raise(ArgumentError, "require valid shape") { @series.shape = :teardropt }
28
+ assert_nothing_raised("allow valid shape") { @series.shape = :cone }
29
+ assert(@series.shape == :cone)
30
+ end
31
+
32
+ end
@@ -34,6 +34,18 @@ class TestChart < Test::Unit::TestCase
34
34
  assert_equal(@chart.style, 2)
35
35
  end
36
36
 
37
+ def test_start_at
38
+ @chart.start_at 15,25
39
+ assert_equal(@chart.graphic_frame.anchor.from.col, 15)
40
+ assert_equal(@chart.graphic_frame.anchor.from.row, 25)
41
+
42
+ end
43
+
44
+ def end_at
45
+ @chart.end_at 25, 90
46
+ assert_equal(@chart.graphic_frame.anchor.from.col, 25)
47
+ assert_equal(@chart.graphic_frame.anchor.to.row, 90)
48
+ end
37
49
 
38
50
  def test_add_series
39
51
  s = @chart.add_series :data=>[0,1,2,3], :labels => ["one", 1, "anything"], :title=>"bob"
@@ -0,0 +1,27 @@
1
+ require 'test/unit'
2
+ require 'axlsx.rb'
3
+
4
+ class TestLineSeries < Test::Unit::TestCase
5
+
6
+ def setup
7
+ p = Axlsx::Package.new
8
+ @ws = p.workbook.add_worksheet :name=>"hmmm"
9
+ chart = @ws.drawing.add_chart Axlsx::Line3DChart, :title => "fishery"
10
+ @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob"
11
+ end
12
+
13
+ def test_initialize
14
+ assert_equal(@series.title.text, "bob", "series title has been applied")
15
+ assert_equal(@series.data, [0,1,2], "data option applied")
16
+ assert_equal(@series.labels, ["zero", "one","two"], "labels option applied")
17
+ end
18
+
19
+ def test_data
20
+ assert_equal(@series.data, [0,1,2])
21
+ end
22
+
23
+ def test_labels
24
+ assert_equal(@series.labels, ["zero", "one", "two"])
25
+ end
26
+
27
+ end