axlsx 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +21 -0
- data/LICENSE +1 -1
- data/README.md +38 -415
- data/examples/#extractive.csv# +0 -0
- data/examples/#extractive.rb# +45 -0
- data/examples/chart_colors.rb +73 -0
- data/examples/chart_colors.rb~ +0 -0
- data/examples/chart_colors.xlsx +0 -0
- data/examples/colored_series_data.xlsx +0 -0
- data/examples/conditional_formatting/getting_barred.xlsx +0 -0
- data/examples/example.rb +174 -113
- data/examples/example.xlsx +0 -0
- data/examples/example_streamed.xlsx +0 -0
- data/examples/extractive.csv +1 -0
- data/examples/extractive.csv~ +1 -0
- data/examples/extractive.rb +42 -0
- data/examples/extractive.rb~ +3 -0
- data/examples/extractive.xlsx +0 -0
- data/examples/no-use_autowidth.xlsx +0 -0
- data/examples/shared_strings_example.xlsx +0 -0
- data/examples/stack.rb +21 -0
- data/examples/stack.rb~ +27 -0
- data/examples/stack.xlsx +0 -0
- data/examples/~$chart_colors.xlsx +0 -0
- data/examples/~$extractive.xlsx +0 -0
- data/lib/axlsx/drawing/ax_data_source.rb +25 -0
- data/lib/axlsx/drawing/ax_data_source.rb~ +55 -0
- data/lib/axlsx/drawing/axis.rb +12 -3
- data/lib/axlsx/drawing/bar_series.rb +23 -6
- data/lib/axlsx/drawing/cat_axis.rb +24 -0
- data/lib/axlsx/drawing/chart.rb +7 -5
- data/lib/axlsx/drawing/data_source.rb~ +51 -0
- data/lib/axlsx/drawing/drawing.rb +8 -4
- data/lib/axlsx/drawing/line_series.rb +20 -4
- data/lib/axlsx/drawing/num_data.rb +52 -0
- data/lib/axlsx/drawing/num_data.rb~ +51 -0
- data/lib/axlsx/drawing/num_data_source.rb +58 -0
- data/lib/axlsx/drawing/num_data_source.rb~ +54 -0
- data/lib/axlsx/drawing/num_val.rb +32 -0
- data/lib/axlsx/drawing/num_val.rb~ +40 -0
- data/lib/axlsx/drawing/pie_series.rb +18 -4
- data/lib/axlsx/drawing/ref.rb~ +41 -0
- data/lib/axlsx/drawing/scatter_series.rb +28 -2
- data/lib/axlsx/drawing/ser_axis.rb +1 -1
- data/lib/axlsx/drawing/series.rb +1 -1
- data/lib/axlsx/drawing/str_data.rb +42 -0
- data/lib/axlsx/drawing/str_data.rb~ +58 -0
- data/lib/axlsx/drawing/str_val.rb +33 -0
- data/lib/axlsx/drawing/str_val.rb~ +35 -0
- data/lib/axlsx/drawing/view_3D.rb +6 -3
- data/lib/axlsx/util/validators.rb +1 -1
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/worksheet/col.rb +2 -1
- data/lib/axlsx/workbook/worksheet/row.rb +44 -5
- data/lib/axlsx/workbook/worksheet/table.rb +1 -1
- data/test/drawing/tc_bar_series.rb +18 -13
- data/test/drawing/tc_cat_axis_data.rb +23 -13
- data/test/drawing/tc_chart.rb +0 -2
- data/test/drawing/tc_data_source.rb +17 -0
- data/test/drawing/tc_data_source.rb~ +30 -0
- data/test/drawing/tc_line_series.rb +3 -9
- data/test/drawing/tc_named_axis_data.rb +27 -0
- data/test/drawing/tc_num_data.rb +27 -0
- data/test/drawing/tc_num_data.rb~ +35 -0
- data/test/drawing/tc_num_val.rb +29 -0
- data/test/drawing/tc_num_val.rb~ +29 -0
- data/test/drawing/tc_pie_series.rb +4 -11
- data/test/drawing/tc_scatter_series.rb +6 -5
- data/test/drawing/tc_str_data.rb +18 -0
- data/test/drawing/tc_str_data.rb~ +30 -0
- data/test/drawing/tc_str_val.rb +21 -0
- data/test/drawing/tc_str_val.rb~ +26 -0
- data/test/drawing/tc_two_cell_anchor.rb +1 -1
- data/test/workbook/worksheet/tc_row.rb +6 -0
- metadata +65 -13
- data/lib/axlsx/drawing/cat_axis_data.rb +0 -34
- data/lib/axlsx/drawing/named_axis_data.rb +0 -36
- data/lib/axlsx/drawing/val_axis_data.rb +0 -27
- data/test/drawing/tc_val_axis_data.rb +0 -17
@@ -16,13 +16,22 @@ module Axlsx
|
|
16
16
|
# @return [NamedAxisData]
|
17
17
|
attr_reader :yData
|
18
18
|
|
19
|
+
# The fill color for this series.
|
20
|
+
# Red, green, and blue is expressed as sequence of hex digits, RRGGBB. A perceptual gamma of 2.2 is used.
|
21
|
+
# @return [String]
|
22
|
+
attr_reader :color
|
23
|
+
|
19
24
|
# Creates a new ScatterSeries
|
20
25
|
def initialize(chart, options={})
|
21
26
|
@xData, @yData = nil
|
22
27
|
super(chart, options)
|
28
|
+
@xData = AxDataSource.new(:tag_name => :xVal, :data => options[:xData]) unless options[:xData].nil?
|
29
|
+
@yData = NumDataSource.new({:tag_name => :yVal, :data => options[:yData]}) unless options[:yData].nil?
|
30
|
+
end
|
23
31
|
|
24
|
-
|
25
|
-
|
32
|
+
# @see color
|
33
|
+
def color=(v)
|
34
|
+
@color = v
|
26
35
|
end
|
27
36
|
|
28
37
|
# Serializes the object
|
@@ -30,6 +39,23 @@ module Axlsx
|
|
30
39
|
# @return [String]
|
31
40
|
def to_xml_string(str = '')
|
32
41
|
super(str) do |inner_str|
|
42
|
+
# needs to override the super color here to push in ln/and something else!
|
43
|
+
if color
|
44
|
+
str << '<c:spPr><a:solidFill>'
|
45
|
+
str << '<a:srgbClr val="' << color << '"/>'
|
46
|
+
str << '</a:solidFill>'
|
47
|
+
str << '<a:ln><a:solidFill>'
|
48
|
+
str << '<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>'
|
49
|
+
str << '</c:spPr>'
|
50
|
+
str << '<c:marker>'
|
51
|
+
str << '<c:spPr><a:solidFill>'
|
52
|
+
str << '<a:srgbClr val="' << color << '"/>'
|
53
|
+
str << '</a:solidFill>'
|
54
|
+
str << '<a:ln><a:solidFill>'
|
55
|
+
str << '<a:srgbClr val="' << color << '"/></a:solidFill></a:ln>'
|
56
|
+
str << '</c:spPr>'
|
57
|
+
str << '</c:marker>'
|
58
|
+
end
|
33
59
|
@xData.to_xml_string(inner_str) unless @xData.nil?
|
34
60
|
@yData.to_xml_string(inner_str) unless @yData.nil?
|
35
61
|
end
|
@@ -20,7 +20,7 @@ module Axlsx
|
|
20
20
|
# @option options [Integer] tickLblSkip
|
21
21
|
# @option options [Integer] tickMarkSkip
|
22
22
|
def initialize(axId, crossAx, options={})
|
23
|
-
@tickLblSkip, @tickMarkSkip =
|
23
|
+
@tickLblSkip, @tickMarkSkip = 1, 1
|
24
24
|
super(axId, crossAx, options)
|
25
25
|
end
|
26
26
|
|
data/lib/axlsx/drawing/series.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Axlsx
|
3
|
+
|
4
|
+
#This specifies the last string data used for a chart. (e.g. strLit and strCache)
|
5
|
+
# This class is extended for NumData to include the formatCode attribute required for numLit and numCache
|
6
|
+
class StrData
|
7
|
+
|
8
|
+
# creates a new StrVal object
|
9
|
+
# @option options [Array] :data
|
10
|
+
# @option options [String] :tag_name
|
11
|
+
def initialize(options={})
|
12
|
+
@tag_prefix = :str
|
13
|
+
@type = StrVal
|
14
|
+
@pt = SimpleTypedList.new(@type)
|
15
|
+
options.each do |o|
|
16
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# Creates the val objects for this data set. I am not overly confident this is going to play nicely with time and data types.
|
21
|
+
# @param [Array] values An array of cells or values.
|
22
|
+
def data=(values=[])
|
23
|
+
@tag_name = values.first.is_a?(Cell) ? :strCache : :strLit
|
24
|
+
values.each do |value|
|
25
|
+
v = value.is_a?(Cell) ? value.value : value
|
26
|
+
@pt << @type.new(:v => v)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# serialize the object
|
31
|
+
def to_xml_string(str = "")
|
32
|
+
str << '<c:' << @tag_name.to_s << '>'
|
33
|
+
str << '<c:ptCount val="' << @pt.size.to_s << '"/>'
|
34
|
+
@pt.each_with_index do |value, index|
|
35
|
+
value.to_xml_string index, str
|
36
|
+
end
|
37
|
+
str << '</c:' << @tag_name.to_s << '>'
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Axlsx
|
3
|
+
|
4
|
+
#This specifies the last string data used for a chart. (e.g. strLit and strCache)
|
5
|
+
# This class is extended for NumData to include the formatCode attribute required for numLit and numCache
|
6
|
+
class StrData
|
7
|
+
|
8
|
+
def self.allowed_tag_names
|
9
|
+
[:strCache, :strLit]
|
10
|
+
end
|
11
|
+
|
12
|
+
# A list of NumVal objects
|
13
|
+
# @return [SimpleTypedList]
|
14
|
+
attr_reader :pt
|
15
|
+
|
16
|
+
# The tag name to use when serializing this object.
|
17
|
+
# this is restricted to the values returnd by self.allowed_tag_names
|
18
|
+
attr_reader :tag_name
|
19
|
+
|
20
|
+
# creates a new StrVal object
|
21
|
+
# @option options [Array] :data
|
22
|
+
# @option options [String] :tag_name
|
23
|
+
def initialize(options={})
|
24
|
+
@tag_prefix = :str
|
25
|
+
@type = StrVal
|
26
|
+
@pt = SimpleTypedList.new(@type)
|
27
|
+
options.each do |o|
|
28
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def data=(values)
|
33
|
+
# raise ArgumentError, 'data assignation must be done with an array' unless values.is_a?(Array)
|
34
|
+
@tag_name = values.first.is_a?(Cell) ? "#{@tag_prefix.to_s}Cache".to_sym : "#{@tag_prefix.to_s}Lit".to_sym
|
35
|
+
values.each do |value|
|
36
|
+
v = value.is_a?(Cell)? v.value : value
|
37
|
+
@pt << @type.new(:v => v)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def tag_name=(v)
|
42
|
+
Axlsx::RestrictionValidator.validate "#{self.class.name}.tag_name", self.class.allowed_tag_names, v
|
43
|
+
@tag_name = v
|
44
|
+
end
|
45
|
+
|
46
|
+
# serialize the object
|
47
|
+
def to_xml_string(idx, str = "")
|
48
|
+
str << '<c:' << tag_name.to_s << '>'
|
49
|
+
str << '<c:ptCount val="' << @pt.size.to_s << '"/>'
|
50
|
+
pt.each_with_index do |value, index|
|
51
|
+
value.to_xml_string index, str
|
52
|
+
end
|
53
|
+
str << '</c:' << tag_name.to_s << '>'
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Axlsx
|
3
|
+
|
4
|
+
#This class specifies data for a particular data point.
|
5
|
+
class StrVal
|
6
|
+
|
7
|
+
# a string value.
|
8
|
+
# @return [String]
|
9
|
+
attr_reader :v
|
10
|
+
|
11
|
+
# creates a new StrVal object
|
12
|
+
# @option options [String] v
|
13
|
+
def initialize(options={})
|
14
|
+
@v = ""
|
15
|
+
@idx = 0
|
16
|
+
options.each do |o|
|
17
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
18
|
+
end
|
19
|
+
end
|
20
|
+
# @see v
|
21
|
+
def v=(v)
|
22
|
+
@v = v.to_s
|
23
|
+
end
|
24
|
+
|
25
|
+
# serialize the object
|
26
|
+
def to_xml_string(idx, str = "")
|
27
|
+
Axlsx::validate_unsigned_int(idx)
|
28
|
+
str << '<c:pt idx="' << idx.to_s << '"><c:v>' << v.to_s << '</c:v></c:pt>'
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
module Axlsx
|
3
|
+
|
4
|
+
#This class specifies data for a particular data point.
|
5
|
+
class StrVal
|
6
|
+
|
7
|
+
# a string value.
|
8
|
+
# @return [String]
|
9
|
+
attr_reader :v
|
10
|
+
|
11
|
+
# creates a new StrVal object
|
12
|
+
# @option options [String] v
|
13
|
+
def initialize(options={})
|
14
|
+
@v = ""
|
15
|
+
@idx = 0
|
16
|
+
options.each do |o|
|
17
|
+
self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
# @see v
|
22
|
+
def v=(v)
|
23
|
+
Axlsx::validate_string(v)
|
24
|
+
@v = v
|
25
|
+
end
|
26
|
+
|
27
|
+
# serialize the object
|
28
|
+
def to_xml_string(idx, str = "")
|
29
|
+
Axlsx::validate_unsigned_int(idx)
|
30
|
+
str << '<c:pt idx="' << idx.to_s << '"><c:v>' << v.to_s << '</c:v></c:pt>'
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -4,10 +4,10 @@ module Axlsx
|
|
4
4
|
class View3D
|
5
5
|
|
6
6
|
# Validation for hPercent
|
7
|
-
H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)
|
7
|
+
H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)/
|
8
8
|
|
9
9
|
# validation for depthPercent
|
10
|
-
DEPTH_PERCENT_REGEX = /0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)
|
10
|
+
DEPTH_PERCENT_REGEX = /0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)/
|
11
11
|
|
12
12
|
# x rotation for the chart
|
13
13
|
# must be between -90 and 90
|
@@ -55,7 +55,10 @@ module Axlsx
|
|
55
55
|
def rotX=(v) DataTypeValidator.validate "#{self.class}.rotX", [Integer, Fixnum], v, lambda {|arg| arg >= -90 && arg <= 90 }; @rotX = v; end
|
56
56
|
|
57
57
|
# @see hPercent
|
58
|
-
def hPercent=(v)
|
58
|
+
def hPercent=(v)
|
59
|
+
RegexValidator.validate "#{self.class}.hPercent", H_PERCENT_REGEX, v
|
60
|
+
@hPercent = v
|
61
|
+
end
|
59
62
|
|
60
63
|
# @see rotY
|
61
64
|
def rotY=(v) DataTypeValidator.validate "#{self.class}.rotY", [Integer, Fixnum], v, lambda {|arg| arg >= 0 && arg <= 360 }; @rotY = v; end
|
@@ -20,7 +20,7 @@ module Axlsx
|
|
20
20
|
# @param [Regexp] regex The regular expression to evaluate
|
21
21
|
# @param [Any] v The value to validate.
|
22
22
|
def self.validate(name, regex, v)
|
23
|
-
raise ArgumentError, (ERR_REGEX % [v.inspect, regex.to_s]) unless (v.respond_to?(
|
23
|
+
raise ArgumentError, (ERR_REGEX % [v.inspect, regex.to_s]) unless (v.respond_to?(:to_s) && v.to_s.match(regex))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
# Validate that the class of the value provided is either an instance or the class of the allowed types and that any specified additional validation returns true.
|
data/lib/axlsx/version.rb
CHANGED
@@ -5,6 +5,6 @@ module Axlsx
|
|
5
5
|
# When using bunle exec rake and referencing the gem on github or locally
|
6
6
|
# it will use the gemspec, which preloads this constant for the gem's version.
|
7
7
|
# We check to make sure that it has not already been loaded
|
8
|
-
VERSION="1.1.
|
8
|
+
VERSION="1.1.4" unless defined? Axlsx::VERSION
|
9
9
|
|
10
10
|
end
|
@@ -5,6 +5,7 @@ module Axlsx
|
|
5
5
|
# @see Worksheet#add_row
|
6
6
|
class Row
|
7
7
|
|
8
|
+
SERIALIZABLE_ATTRIBUTES = [:hidden, :outlineLevel, :collapsed, :style]
|
8
9
|
# The worksheet this row belongs to
|
9
10
|
# @return [Worksheet]
|
10
11
|
attr_reader :worksheet
|
@@ -17,13 +18,29 @@ module Axlsx
|
|
17
18
|
# @return [Float]
|
18
19
|
attr_reader :height
|
19
20
|
|
21
|
+
# Flag indicating if the outlining of the affected column(s) is in the collapsed state.
|
22
|
+
# @return [Boolean]
|
23
|
+
attr_reader :collapsed
|
24
|
+
|
25
|
+
# Flag indicating if the affected column(s) are hidden on this worksheet.
|
26
|
+
# @return [Boolean]
|
27
|
+
attr_reader :hidden
|
28
|
+
|
29
|
+
# Outline level of affected column(s). Range is 0 to 7.
|
30
|
+
# @return [Integer]
|
31
|
+
attr_reader :outlineLevel
|
32
|
+
|
33
|
+
# Default style for the affected column(s). Affects cells not yet allocated in the column(s). In other words, this style applies to new columns.
|
34
|
+
# @return [Integer]
|
35
|
+
attr_reader :style
|
36
|
+
|
20
37
|
# TODO 18.3.1.73
|
21
|
-
# collapsed
|
38
|
+
# # collapsed
|
22
39
|
# customFormat
|
23
|
-
# hidden
|
24
|
-
# outlineLevel
|
40
|
+
# # hidden
|
41
|
+
# # outlineLevel
|
25
42
|
# ph
|
26
|
-
# s (style)
|
43
|
+
# # s (style)
|
27
44
|
# spans
|
28
45
|
# thickTop
|
29
46
|
# thickBottom
|
@@ -53,6 +70,25 @@ module Axlsx
|
|
53
70
|
array_to_cells(values, options)
|
54
71
|
end
|
55
72
|
|
73
|
+
# @see Row#collapsed
|
74
|
+
def collapsed=(v)
|
75
|
+
Axlsx.validate_boolean(v)
|
76
|
+
@collapsed = v
|
77
|
+
end
|
78
|
+
|
79
|
+
# @see Row#hidden
|
80
|
+
def hidden=(v)
|
81
|
+
Axlsx.validate_boolean(v)
|
82
|
+
@hidden = v
|
83
|
+
end
|
84
|
+
|
85
|
+
# @see Row#outline
|
86
|
+
def outlineLevel=(v)
|
87
|
+
Axlsx.validate_unsigned_numeric(v)
|
88
|
+
@outlineLevel = v
|
89
|
+
end
|
90
|
+
|
91
|
+
|
56
92
|
# The index of this row in the worksheet
|
57
93
|
# @return [Integer]
|
58
94
|
def index
|
@@ -65,6 +101,9 @@ module Axlsx
|
|
65
101
|
# @return [String]
|
66
102
|
def to_xml_string(r_index, str = '')
|
67
103
|
str << '<row r="' << (r_index + 1 ).to_s << '" '
|
104
|
+
instance_values.select { |key, value| SERIALIZABLE_ATTRIBUTES.include? key.to_sym }.each do |key, value|
|
105
|
+
str << key << '="' << value.to_s << '" '
|
106
|
+
end
|
68
107
|
if custom_height?
|
69
108
|
str << 'customHeight="1" ht="' << height.to_s << '">'
|
70
109
|
else
|
@@ -79,7 +118,7 @@ module Axlsx
|
|
79
118
|
# @return [Cell]
|
80
119
|
def add_cell(value="", options={})
|
81
120
|
c = Cell.new(self, value, options)
|
82
|
-
worksheet.send(:update_column_info, self.cells, self.cells.map(&:style))
|
121
|
+
worksheet.send(:update_column_info, self.cells, [], self.cells.map(&:style))
|
83
122
|
c
|
84
123
|
end
|
85
124
|
|
@@ -5,29 +5,34 @@ class TestBarSeries < Test::Unit::TestCase
|
|
5
5
|
def setup
|
6
6
|
p = Axlsx::Package.new
|
7
7
|
@ws = p.workbook.add_worksheet :name=>"hmmm"
|
8
|
-
chart = @ws.drawing.add_chart Axlsx::Bar3DChart, :title => "fishery"
|
9
|
-
@series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob"
|
8
|
+
@chart = @ws.drawing.add_chart Axlsx::Bar3DChart, :title => "fishery"
|
9
|
+
@series = @chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob", :colors => ['FF0000', '00FF00', '0000FF'], :shape => :cone
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_initialize
|
13
13
|
assert_equal(@series.title.text, "bob", "series title has been applied")
|
14
|
-
assert_equal(@series.data,
|
15
|
-
assert_equal(@series.
|
16
|
-
|
14
|
+
assert_equal(@series.data.class, Axlsx::NumDataSource, "data option applied")
|
15
|
+
assert_equal(@series.shape, :cone, "series shape has been applied")
|
16
|
+
assert(@series.data.is_a?(Axlsx::NumDataSource))
|
17
|
+
assert(@series.labels.is_a?(Axlsx::AxDataSource))
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
-
assert_equal(@series.
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_labels
|
24
|
-
assert_equal(@series.labels, ["zero", "one", "two"])
|
20
|
+
def test_colors
|
21
|
+
assert_equal(@series.colors.size, 3)
|
25
22
|
end
|
26
23
|
|
27
24
|
def test_shape
|
28
25
|
assert_raise(ArgumentError, "require valid shape") { @series.shape = :teardropt }
|
29
|
-
assert_nothing_raised("allow valid shape") { @series.shape = :
|
30
|
-
assert(@series.shape == :
|
26
|
+
assert_nothing_raised("allow valid shape") { @series.shape = :box }
|
27
|
+
assert(@series.shape == :box)
|
31
28
|
end
|
32
29
|
|
30
|
+
def test_to_xml_string
|
31
|
+
doc = Nokogiri::XML(@chart.to_xml_string)
|
32
|
+
@series.colors.each_with_index do |color, index|
|
33
|
+
assert_equal(doc.xpath("//c:dPt/c:idx[@val='#{index}']").size,1)
|
34
|
+
assert_equal(doc.xpath("//c:dPt/c:spPr/a:solidFill/a:srgbClr[@val='#{@series.colors[index]}']").size,1)
|
35
|
+
end
|
36
|
+
assert_equal(doc.xpath("//c:shape[@val='#{@series.shape.to_s}']").size, 1)
|
37
|
+
end
|
33
38
|
end
|
@@ -1,17 +1,27 @@
|
|
1
|
-
require 'tc_helper.rb'
|
1
|
+
# require 'tc_helper.rb'
|
2
2
|
|
3
|
-
class TestCatAxisData < Test::Unit::TestCase
|
3
|
+
# class TestCatAxisData < Test::Unit::TestCase
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
# def setup
|
6
|
+
# p = Axlsx::Package.new
|
7
|
+
# @ws = p.workbook.add_worksheet
|
8
|
+
# @chart = @ws.drawing.add_chart Axlsx::Bar3DChart
|
9
|
+
# @series = @chart.add_series :labels=>["zero", "one", "two"]
|
10
|
+
# end
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
# def test_initialize
|
13
|
+
# assert(@series.labels.is_a?Axlsx::SimpleTypedList)
|
14
|
+
# assert_equal(@series.labels, ["zero", "one", "two"])
|
15
|
+
# end
|
16
16
|
|
17
|
-
|
17
|
+
# def test_to_xml_string
|
18
|
+
# doc = Nokogiri::XML(@chart.to_xml_string)
|
19
|
+
# assert_equal(doc.xpath("//c:cat/c:strRef/c:f").size,1)
|
20
|
+
# assert_equal(doc.xpath("//c:strCache/c:ptCount[@val='#{@series.labels.size}']").size,1)
|
21
|
+
# @series.labels.each_with_index do |label, index|
|
22
|
+
# assert_equal(doc.xpath("//c:strCache/c:pt[@idx='#{index}']").size,1)
|
23
|
+
# assert_equal(doc.xpath("//c:strCache/c:pt/c:v[text()='#{label}']").size,1)
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
|
27
|
+
# end
|