caxlsx 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -10
- data/README.md +1 -1
- data/lib/axlsx/drawing/bar_3D_chart.rb +5 -8
- data/lib/axlsx/drawing/bar_chart.rb +13 -18
- data/lib/axlsx/drawing/bar_series.rb +18 -1
- data/lib/axlsx/version.rb +1 -1
- data/lib/axlsx/workbook/worksheet/row.rb +1 -1
- data/lib/axlsx.rb +5 -4
- data/test/drawing/tc_bar_3D_chart.rb +26 -11
- data/test/drawing/tc_bar_chart.rb +26 -11
- data/test/drawing/tc_bar_series.rb +10 -1
- metadata +99 -99
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef44b04d373e873848cd74d5bebae4d327cd0d9cba06ee74de6d0aac35b51ab9
|
4
|
+
data.tar.gz: b54abdd82f277253216da4ad9d938c2508c9f1ed54abd080d4437e5523c470e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bce9d28013a2ec3ffec4be335a2b933ba38fb508dbc4f486a3df135dc81122a236ff9439792ac8bc64c4150e523af261deea02c5a86b9f3838a38b2a26e0d537
|
7
|
+
data.tar.gz: 1bca0d82c582818a822feefbb499caef3b622f8d4203543a1c6d11f57876944df01db0bafb30d6238f9a268d731a0a78de0ed4efa97a205db43465d73dab7d74
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
3
|
|
4
|
+
- **September.22.21**: 3.1.1
|
5
|
+
- [PR #107](https://github.com/caxlsx/caxlsx/pull/107) - Add overlap to bar charts
|
6
|
+
- [PR #108](https://github.com/caxlsx/caxlsx/pull/108) - Fix gap depth and gap depth validators for bar charts and 3D bar charts
|
7
|
+
|
4
8
|
- **March.27.21**: 3.1.0
|
5
9
|
- [PR #95](https://github.com/caxlsx/caxlsx/pull/95) - Replace mimemagic with marcel
|
6
10
|
- [PR #87](https://github.com/caxlsx/caxlsx/pull/87) - Implement :offset option for worksheet#add_row
|
@@ -11,7 +15,7 @@ CHANGELOG
|
|
11
15
|
- **January.5.21**: 3.0.4
|
12
16
|
- [PR #72](https://github.com/caxlsx/caxlsx/pull/72) - Relax Ruby dependency to allow for Ruby 3. This required Travis to be upgraded from Ubuntu Trusty to Ubuntu Bionic. rbx-3 was dropped.
|
13
17
|
- [PR #71](https://github.com/caxlsx/caxlsx/pull/71) - Adds date type to validator so sheet.add_data_validation works with date type. Addresses [I #26](https://github.com/caxlsx/caxlsx/issues/26) - Date Data Validation not working
|
14
|
-
- [PR #70](https://github.com/caxlsx/caxlsx/pull/70) - Fix worksheet title length enforcement caused by switching from size to bytesize. Addresses [I #67](https://github.com/caxlsx/caxlsx/issues/67) - character length error in worksheet name when using Japanese, which was introduced by addressing [I #588](https://github.com/randym/axlsx/issues/588) in the old Axlsx repo.
|
18
|
+
- [PR #70](https://github.com/caxlsx/caxlsx/pull/70) - Fix worksheet title length enforcement caused by switching from size to bytesize. Addresses [I #67](https://github.com/caxlsx/caxlsx/issues/67) - character length error in worksheet name when using Japanese, which was introduced by addressing [I #588](https://github.com/randym/axlsx/issues/588) in the old Axlsx repo.
|
15
19
|
|
16
20
|
|
17
21
|
- **December.7.20**: 3.0.3
|
@@ -19,7 +23,7 @@ CHANGELOG
|
|
19
23
|
- [PR #56](https://github.com/caxlsx/caxlsx/pull/56) - Add `zip_command` option to `#serialize` for faster serialization of large Excel files by using a zip binary
|
20
24
|
- [PR #54](https://github.com/caxlsx/caxlsx/pull/54) - Fix type detection for floats with out-of-rage exponents
|
21
25
|
- [I #67](https://github.com/caxlsx/caxlsx/issues/67) - Fix regression in worksheet name length enforcement: Some unicode characters were counted incorrectly, so that names that previously worked fine now stopped working. (This was introduced in 3.0.2)
|
22
|
-
|
26
|
+
|
23
27
|
- **July.16.20**: 3.0.2
|
24
28
|
- [I #51](https://github.com/caxlsx/caxlsx/issues/51) - Images do not import on Windows. IO read set explicitly to binary mode.
|
25
29
|
- [PR #53](https://github.com/caxlsx/caxlsx/pull/53) - Limit column width to 255. Maximum column width limit in MS Excel is 255 characters, see https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
|
@@ -152,7 +156,7 @@ CHANGELOG
|
|
152
156
|
- added in interop requirements so that charts are properly exported
|
153
157
|
to PDF from Libra Office
|
154
158
|
- various readability improvements and work standardizing attribute
|
155
|
-
names to snake_case. Aliases are provided for backward compatiblity
|
159
|
+
names to snake_case. Aliases are provided for backward compatiblity
|
156
160
|
|
157
161
|
- **June.11.12**: 1.1.7
|
158
162
|
- fix chart rendering issue when label offset is specified as a
|
@@ -193,23 +197,23 @@ in value caches
|
|
193
197
|
- Added support for specifying the color of data series in charts.
|
194
198
|
- bugfix using add_cell on row mismanaged calls to update_column_info.
|
195
199
|
|
196
|
-
- **
|
200
|
+
- **April.25.12:**: 1.1.3
|
197
201
|
- Primarily because I am stupid.....Updates to readme to properly report version, add in missing docs and restructure example directory.
|
198
202
|
|
199
|
-
- **
|
203
|
+
- **April.25.12:**: 1.1.2
|
200
204
|
- Conditional Formatting completely implemented.
|
201
205
|
- refactoring / documentation for Style#add_style
|
202
206
|
- added in label rotation for chart axis labels
|
203
207
|
- bugfix to properly assign style and type info to cells when only partial information is provided in the types/style option
|
204
208
|
|
205
|
-
- **
|
209
|
+
- **April.18.12**: 1.1.1
|
206
210
|
- bugfix for autowidth calculations across multiple rows
|
207
211
|
- bugfix for dimension calculations with nil cells.
|
208
212
|
- REMOVED RMAGICK dependency WOOT!
|
209
213
|
- Update readme to show screenshot of gem output.
|
210
214
|
- Cleanup benchmark and add benchmark rake task
|
211
215
|
|
212
|
-
- **
|
216
|
+
- **April.3.12**: 1.1.0
|
213
217
|
- bugfix patch name_to_indecies to properly handle extended ranges.
|
214
218
|
- bugfix properly serialize chart title.
|
215
219
|
- lower rake minimum requirement for 1.8.7 apps that don't want to move on to 0.9 NOTE this will be reverted for 2.0.0 with workbook parsing!
|
@@ -224,7 +228,7 @@ in value caches
|
|
224
228
|
- Major (like 7x faster!) performance updates.
|
225
229
|
- Gem now supports for JRuby 1.6.7, as well as experimental support for Rubinius
|
226
230
|
|
227
|
-
- **
|
231
|
+
- **March.5.12**: 1.0.18
|
228
232
|
https://github.com/randym/axlsx/compare/1.0.17...1.0.18
|
229
233
|
- bugfix custom borders are not properly applied when using styles.add_style
|
230
234
|
- interop worksheet names must be 31 characters or less or some versions of office complain about repairs
|
@@ -234,14 +238,14 @@ in value caches
|
|
234
238
|
- added << alias for add_row
|
235
239
|
- removed presetting of date1904 based on authoring platform. Now defaults to use 1900 epoch (date1904 = false)
|
236
240
|
|
237
|
-
- **
|
241
|
+
- **February.14.12**: 1.0.17
|
238
242
|
https://github.com/randym/axlsx/compare/1.0.16...1.0.17
|
239
243
|
- Added in support for serializing to StringIO
|
240
244
|
- Added in support for using shared strings table. This makes most of the features in axlsx interoperable with iWorks Numbers
|
241
245
|
- Added in support for fixed column_widths
|
242
246
|
- Removed unneeded dependencies on active-support and i18n
|
243
247
|
|
244
|
-
- **
|
248
|
+
- **February.2.12**: 1.0.16
|
245
249
|
https://github.com/randym/axlsx/compare/1.0.15...1.0.16
|
246
250
|
- Bug fix for schema file locations when validating in rails
|
247
251
|
- Added hyperlink to images
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![Gem
|
4
4
|
Version](https://badge.fury.io/rb/caxlsx.svg)](http://badge.fury.io/rb/caxlsx)
|
5
5
|
![Total downloads](http://ruby-gem-downloads-badge.herokuapp.com/caxlsx?type=total)
|
6
|
-
![Downloads for 3.
|
6
|
+
![Downloads for 3.1.1 (latest)](http://ruby-gem-downloads-badge.herokuapp.com/caxlsx/3.1.1?label=downloads%203.1.1)
|
7
7
|
|
8
8
|
## Notice: Community Axlsx Organization
|
9
9
|
|
@@ -31,17 +31,17 @@ module Axlsx
|
|
31
31
|
alias :barDir :bar_dir
|
32
32
|
|
33
33
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
34
|
-
# @return [
|
34
|
+
# @return [Integer]
|
35
35
|
attr_reader :gap_depth
|
36
36
|
alias :gapDepth :gap_depth
|
37
37
|
|
38
38
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
39
|
-
# @return [
|
39
|
+
# @return [Integer]
|
40
40
|
def gap_width
|
41
41
|
@gap_width ||= 150
|
42
42
|
end
|
43
43
|
alias :gapWidth :gap_width
|
44
|
-
|
44
|
+
|
45
45
|
#grouping for a column, line, or area chart.
|
46
46
|
# must be one of [:percentStacked, :clustered, :standard, :stacked]
|
47
47
|
# @return [Symbol]
|
@@ -56,9 +56,6 @@ module Axlsx
|
|
56
56
|
@shape ||= :box
|
57
57
|
end
|
58
58
|
|
59
|
-
# validation regex for gap amount percent
|
60
|
-
GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/
|
61
|
-
|
62
59
|
# Creates a new bar chart object
|
63
60
|
# @param [GraphicFrame] frame The workbook that owns this chart.
|
64
61
|
# @option options [Cell, String] title
|
@@ -102,14 +99,14 @@ module Axlsx
|
|
102
99
|
|
103
100
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
104
101
|
def gap_width=(v)
|
105
|
-
|
102
|
+
RangeValidator.validate "Bar3DChart.gap_width", 0, 500, v
|
106
103
|
@gap_width=(v)
|
107
104
|
end
|
108
105
|
alias :gapWidth= :gap_width=
|
109
106
|
|
110
107
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
111
108
|
def gap_depth=(v)
|
112
|
-
|
109
|
+
RangeValidator.validate "Bar3DChart.gap_depth", 0, 500, v
|
113
110
|
@gap_depth=(v)
|
114
111
|
end
|
115
112
|
alias :gapDepth= :gap_depth=
|
@@ -31,12 +31,7 @@ module Axlsx
|
|
31
31
|
alias :barDir :bar_dir
|
32
32
|
|
33
33
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
34
|
-
# @return [
|
35
|
-
attr_reader :gap_depth
|
36
|
-
alias :gapDepth :gap_depth
|
37
|
-
|
38
|
-
# space between bar or column clusters, as a percentage of the bar or column width.
|
39
|
-
# @return [String]
|
34
|
+
# @return [Integer]
|
40
35
|
def gap_width
|
41
36
|
@gap_width ||= 150
|
42
37
|
end
|
@@ -49,6 +44,12 @@ module Axlsx
|
|
49
44
|
@grouping ||= :clustered
|
50
45
|
end
|
51
46
|
|
47
|
+
# Overlap between series
|
48
|
+
# @return [Integer]
|
49
|
+
def overlap
|
50
|
+
@overlap ||= 0
|
51
|
+
end
|
52
|
+
|
52
53
|
# The shape of the bars or columns
|
53
54
|
# must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
|
54
55
|
# @return [Symbol]
|
@@ -56,9 +57,6 @@ module Axlsx
|
|
56
57
|
@shape ||= :box
|
57
58
|
end
|
58
59
|
|
59
|
-
# validation regex for gap amount percent
|
60
|
-
GAP_AMOUNT_PERCENT = /0*(([0-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/
|
61
|
-
|
62
60
|
# Creates a new bar chart object
|
63
61
|
# @param [GraphicFrame] frame The workbook that owns this chart.
|
64
62
|
# @option options [Cell, String] title
|
@@ -66,12 +64,11 @@ module Axlsx
|
|
66
64
|
# @option options [Symbol] bar_dir
|
67
65
|
# @option options [Symbol] grouping
|
68
66
|
# @option options [String] gap_width
|
69
|
-
# @option options [String] gap_depth
|
70
67
|
# @option options [Symbol] shape
|
71
68
|
# @see Chart
|
72
69
|
def initialize(frame, options={})
|
73
70
|
@vary_colors = true
|
74
|
-
@gap_width, @
|
71
|
+
@gap_width, @overlap, @shape = nil, nil, nil
|
75
72
|
super(frame, options)
|
76
73
|
@series_type = BarSeries
|
77
74
|
@d_lbls = nil
|
@@ -94,17 +91,15 @@ module Axlsx
|
|
94
91
|
|
95
92
|
# space between bar or column clusters, as a percentage of the bar or column width.
|
96
93
|
def gap_width=(v)
|
97
|
-
|
94
|
+
RangeValidator.validate "BarChart.gap_width", 0, 500, v
|
98
95
|
@gap_width=(v)
|
99
96
|
end
|
100
97
|
alias :gapWidth= :gap_width=
|
101
98
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
@gap_depth=(v)
|
99
|
+
def overlap=(v)
|
100
|
+
RangeValidator.validate "BarChart.overlap", -100, 100, v
|
101
|
+
@overlap=(v)
|
106
102
|
end
|
107
|
-
alias :gapDepth= :gap_depth=
|
108
103
|
|
109
104
|
# The shape of the bars or columns
|
110
105
|
# must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax]
|
@@ -124,8 +119,8 @@ module Axlsx
|
|
124
119
|
str << ('<c:varyColors val="' << vary_colors.to_s << '"/>')
|
125
120
|
@series.each { |ser| ser.to_xml_string(str) }
|
126
121
|
@d_lbls.to_xml_string(str) if @d_lbls
|
122
|
+
str << ('<c:overlap val="' << @overlap.to_s << '"/>') unless @overlap.nil?
|
127
123
|
str << ('<c:gapWidth val="' << @gap_width.to_s << '"/>') unless @gap_width.nil?
|
128
|
-
str << ('<c:gapDepth val="' << @gap_depth.to_s << '"/>') unless @gap_depth.nil?
|
129
124
|
str << ('<c:shape val="' << @shape.to_s << '"/>') unless @shape.nil?
|
130
125
|
axes.to_xml_string(str, :ids => true)
|
131
126
|
str << '</c:barChart>'
|
@@ -22,12 +22,18 @@ module Axlsx
|
|
22
22
|
# An array of rgb colors to apply to your bar chart.
|
23
23
|
attr_reader :colors
|
24
24
|
|
25
|
+
# The fill color for this series.
|
26
|
+
# Red, green, and blue is expressed as sequence of hex digits, RRGGBB.
|
27
|
+
# @return [String]
|
28
|
+
attr_reader :series_color
|
29
|
+
|
25
30
|
# Creates a new series
|
26
31
|
# @option options [Array, SimpleTypedList] data
|
27
32
|
# @option options [Array, SimpleTypedList] labels
|
28
33
|
# @option options [String] title
|
29
34
|
# @option options [String] shape
|
30
35
|
# @option options [String] colors an array of colors to use when rendering each data point
|
36
|
+
# @option options [String] series_color a color to use when rendering series
|
31
37
|
# @param [Chart] chart
|
32
38
|
def initialize(chart, options={})
|
33
39
|
@shape = :box
|
@@ -40,6 +46,10 @@ module Axlsx
|
|
40
46
|
# @see colors
|
41
47
|
def colors=(v) DataTypeValidator.validate "BarSeries.colors", [Array], v; @colors = v end
|
42
48
|
|
49
|
+
def series_color=(v)
|
50
|
+
@series_color = v
|
51
|
+
end
|
52
|
+
|
43
53
|
# @see shape
|
44
54
|
def shape=(v)
|
45
55
|
RestrictionValidator.validate "BarSeries.shape", [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax], v
|
@@ -60,9 +70,16 @@ module Axlsx
|
|
60
70
|
str << '</a:solidFill></c:spPr></c:dPt>'
|
61
71
|
end
|
62
72
|
|
73
|
+
if series_color
|
74
|
+
str << '<c:spPr><a:solidFill>'
|
75
|
+
str << ('<a:srgbClr val="' << series_color << '"/>')
|
76
|
+
str << '</a:solidFill>'
|
77
|
+
str << '</c:spPr>'
|
78
|
+
end
|
79
|
+
|
63
80
|
@labels.to_xml_string(str) unless @labels.nil?
|
64
81
|
@data.to_xml_string(str) unless @data.nil?
|
65
|
-
# this is actually only required for shapes other than box
|
82
|
+
# this is actually only required for shapes other than box
|
66
83
|
str << ('<c:shape val="' << shape.to_s << '"></c:shape>')
|
67
84
|
end
|
68
85
|
end
|
data/lib/axlsx/version.rb
CHANGED
data/lib/axlsx.rb
CHANGED
@@ -51,10 +51,11 @@ module Axlsx
|
|
51
51
|
# determines the cell range for the items provided
|
52
52
|
def self.cell_range(cells, absolute=true)
|
53
53
|
return "" unless cells.first.is_a? Cell
|
54
|
-
|
55
|
-
|
54
|
+
|
55
|
+
first_cell, last_cell = cells.minmax_by(&:pos)
|
56
|
+
reference = "#{first_cell.reference(absolute)}:#{last_cell.reference(absolute)}"
|
56
57
|
if absolute
|
57
|
-
escaped_name =
|
58
|
+
escaped_name = first_cell.row.worksheet.name.gsub ''', "''"
|
58
59
|
"'#{escaped_name}'!#{reference}"
|
59
60
|
else
|
60
61
|
reference
|
@@ -66,7 +67,7 @@ module Axlsx
|
|
66
67
|
# @param [Array] cells
|
67
68
|
# @return [Array]
|
68
69
|
def self.sort_cells(cells)
|
69
|
-
cells.
|
70
|
+
cells.sort_by(&:pos)
|
70
71
|
end
|
71
72
|
|
72
73
|
#global reference html entity encoding
|
@@ -32,18 +32,19 @@ class TestBar3DChart < Test::Unit::TestCase
|
|
32
32
|
assert(@chart.grouping == :standard)
|
33
33
|
end
|
34
34
|
|
35
|
+
def test_gap_width
|
36
|
+
assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = -1 }
|
37
|
+
assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 501 }
|
38
|
+
assert_nothing_raised("allow valid gapWidth") { @chart.gap_width = 200 }
|
39
|
+
assert_equal(@chart.gap_width, 200, 'gap width is incorrect')
|
40
|
+
end
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
def test_gapDepth
|
43
|
-
assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 200 }
|
44
|
-
assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = "200%" }
|
45
|
-
assert(@chart.gap_depth == "200%")
|
46
|
-
end
|
42
|
+
def test_gap_depth
|
43
|
+
assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = -1 }
|
44
|
+
assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 501 }
|
45
|
+
assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = 200 }
|
46
|
+
assert_equal(@chart.gap_depth, 200, 'gap depth is incorrect')
|
47
|
+
end
|
47
48
|
|
48
49
|
def test_shape
|
49
50
|
assert_raise(ArgumentError, "require valid shape") { @chart.shape = :star }
|
@@ -68,4 +69,18 @@ class TestBar3DChart < Test::Unit::TestCase
|
|
68
69
|
val_axis_position = str.index(@chart.axes[:val_axis].id.to_s)
|
69
70
|
assert(cat_axis_position < val_axis_position, "cat_axis must occur earlier than val_axis in the XML")
|
70
71
|
end
|
72
|
+
|
73
|
+
def test_to_xml_string_has_gap_depth
|
74
|
+
gap_depth_value = rand(0..500)
|
75
|
+
@chart.gap_depth = gap_depth_value
|
76
|
+
doc = Nokogiri::XML(@chart.to_xml_string)
|
77
|
+
assert_equal(doc.xpath("//c:bar3DChart/c:gapDepth").first.attribute('val').value, gap_depth_value.to_s)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_to_xml_string_has_gap_width
|
81
|
+
gap_width_value = rand(0..500)
|
82
|
+
@chart.gap_width = gap_width_value
|
83
|
+
doc = Nokogiri::XML(@chart.to_xml_string)
|
84
|
+
assert_equal(doc.xpath("//c:bar3DChart/c:gapWidth").first.attribute('val').value, gap_width_value.to_s)
|
85
|
+
end
|
71
86
|
end
|
@@ -32,18 +32,19 @@ class TestBarChart < Test::Unit::TestCase
|
|
32
32
|
assert(@chart.grouping == :standard)
|
33
33
|
end
|
34
34
|
|
35
|
+
def test_gap_width
|
36
|
+
assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = -1 }
|
37
|
+
assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 501 }
|
38
|
+
assert_nothing_raised("allow valid gap width") { @chart.gap_width = 200 }
|
39
|
+
assert_equal(@chart.gap_width, 200, 'gap width is incorrect')
|
40
|
+
end
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
def test_gapDepth
|
43
|
-
assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 200 }
|
44
|
-
assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = "200%" }
|
45
|
-
assert(@chart.gap_depth == "200%")
|
46
|
-
end
|
42
|
+
def test_overlap
|
43
|
+
assert_raise(ArgumentError, "require valid overlap") { @chart.overlap = -101 }
|
44
|
+
assert_raise(ArgumentError, "require valid overlap") { @chart.overlap = 101 }
|
45
|
+
assert_nothing_raised("allow valid overlap") { @chart.overlap = 100 }
|
46
|
+
assert_equal(@chart.overlap, 100, 'overlap is incorrect')
|
47
|
+
end
|
47
48
|
|
48
49
|
def test_shape
|
49
50
|
assert_raise(ArgumentError, "require valid shape") { @chart.shape = :star }
|
@@ -68,4 +69,18 @@ class TestBarChart < Test::Unit::TestCase
|
|
68
69
|
val_axis_position = str.index(@chart.axes[:val_axis].id.to_s)
|
69
70
|
assert(cat_axis_position < val_axis_position, "cat_axis must occur earlier than val_axis in the XML")
|
70
71
|
end
|
72
|
+
|
73
|
+
def test_to_xml_string_has_gap_width
|
74
|
+
gap_width_value = rand(0..500)
|
75
|
+
@chart.gap_width = gap_width_value
|
76
|
+
doc = Nokogiri::XML(@chart.to_xml_string)
|
77
|
+
assert_equal(doc.xpath("//c:barChart/c:gapWidth").first.attribute('val').value, gap_width_value.to_s)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_to_xml_string_has_overlap
|
81
|
+
overlap_value = rand(-100..100)
|
82
|
+
@chart.overlap = overlap_value
|
83
|
+
doc = Nokogiri::XML(@chart.to_xml_string)
|
84
|
+
assert_equal(doc.xpath("//c:barChart/c:overlap").first.attribute('val').value, overlap_value.to_s)
|
85
|
+
end
|
71
86
|
end
|
@@ -6,13 +6,21 @@ class TestBarSeries < Test::Unit::TestCase
|
|
6
6
|
p = Axlsx::Package.new
|
7
7
|
@ws = p.workbook.add_worksheet :name=>"hmmm"
|
8
8
|
@chart = @ws.add_chart Axlsx::Bar3DChart, :title => "fishery"
|
9
|
-
@series = @chart.add_series
|
9
|
+
@series = @chart.add_series(
|
10
|
+
data: [0, 1, 2],
|
11
|
+
labels: ['zero', 'one', 'two'],
|
12
|
+
title: 'bob',
|
13
|
+
colors: ['FF0000', '00FF00', '0000FF'],
|
14
|
+
shape: :cone,
|
15
|
+
series_color: '5A5A5A'
|
16
|
+
)
|
10
17
|
end
|
11
18
|
|
12
19
|
def test_initialize
|
13
20
|
assert_equal(@series.title.text, "bob", "series title has been applied")
|
14
21
|
assert_equal(@series.data.class, Axlsx::NumDataSource, "data option applied")
|
15
22
|
assert_equal(@series.shape, :cone, "series shape has been applied")
|
23
|
+
assert_equal(@series.series_color, '5A5A5A', 'series color has been applied')
|
16
24
|
assert(@series.data.is_a?(Axlsx::NumDataSource))
|
17
25
|
assert(@series.labels.is_a?(Axlsx::AxDataSource))
|
18
26
|
end
|
@@ -33,5 +41,6 @@ class TestBarSeries < Test::Unit::TestCase
|
|
33
41
|
assert_equal(doc.xpath("//c:dPt/c:idx[@val='#{index}']").size,1)
|
34
42
|
assert_equal(doc.xpath("//c:dPt/c:spPr/a:solidFill/a:srgbClr[@val='#{@series.colors[index]}']").size,1)
|
35
43
|
end
|
44
|
+
assert_equal(doc.xpath('//c:spPr[not(ancestor::c:dPt)]/a:solidFill/a:srgbClr').first.get_attribute('val'), '5A5A5A', 'series color has been applied')
|
36
45
|
end
|
37
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caxlsx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Randy Morgan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -467,132 +467,132 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
467
467
|
- !ruby/object:Gem::Version
|
468
468
|
version: '0'
|
469
469
|
requirements: []
|
470
|
-
rubygems_version: 3.0.
|
470
|
+
rubygems_version: 3.0.9
|
471
471
|
signing_key:
|
472
472
|
specification_version: 4
|
473
473
|
summary: Excel OOXML (xlsx) with charts, styles, images and autowidth columns.
|
474
474
|
test_files:
|
475
|
-
- test/
|
476
|
-
- test/
|
477
|
-
- test/
|
478
|
-
- test/
|
479
|
-
- test/doc_props/tc_app.rb
|
480
|
-
- test/doc_props/tc_core.rb
|
481
|
-
- test/drawing/tc_area_chart.rb
|
482
|
-
- test/drawing/tc_area_series.rb
|
483
|
-
- test/drawing/tc_axes.rb
|
484
|
-
- test/drawing/tc_axis.rb
|
485
|
-
- test/drawing/tc_bar_3D_chart.rb
|
486
|
-
- test/drawing/tc_bar_chart.rb
|
487
|
-
- test/drawing/tc_bar_series.rb
|
488
|
-
- test/drawing/tc_bubble_chart.rb
|
489
|
-
- test/drawing/tc_bubble_series.rb
|
475
|
+
- test/drawing/tc_num_data.rb
|
476
|
+
- test/drawing/tc_two_cell_anchor.rb
|
477
|
+
- test/drawing/tc_view_3D.rb
|
478
|
+
- test/drawing/tc_series_title.rb
|
490
479
|
- test/drawing/tc_cat_axis.rb
|
491
|
-
- test/drawing/tc_cat_axis_data.rb
|
492
480
|
- test/drawing/tc_chart.rb
|
481
|
+
- test/drawing/tc_num_val.rb
|
482
|
+
- test/drawing/tc_axis.rb
|
483
|
+
- test/drawing/tc_line_chart.rb
|
484
|
+
- test/drawing/tc_marker.rb
|
485
|
+
- test/drawing/tc_bubble_series.rb
|
493
486
|
- test/drawing/tc_d_lbls.rb
|
494
|
-
- test/drawing/
|
495
|
-
- test/drawing/
|
496
|
-
- test/drawing/tc_graphic_frame.rb
|
497
|
-
- test/drawing/tc_hyperlink.rb
|
487
|
+
- test/drawing/tc_str_val.rb
|
488
|
+
- test/drawing/tc_bar_chart.rb
|
498
489
|
- test/drawing/tc_line_3d_chart.rb
|
499
|
-
- test/drawing/
|
490
|
+
- test/drawing/tc_cat_axis_data.rb
|
491
|
+
- test/drawing/tc_area_chart.rb
|
500
492
|
- test/drawing/tc_line_series.rb
|
501
|
-
- test/drawing/
|
502
|
-
- test/drawing/
|
503
|
-
- test/drawing/
|
504
|
-
- test/drawing/tc_num_val.rb
|
505
|
-
- test/drawing/tc_one_cell_anchor.rb
|
493
|
+
- test/drawing/tc_scatter_series.rb
|
494
|
+
- test/drawing/tc_bar_series.rb
|
495
|
+
- test/drawing/tc_hyperlink.rb
|
506
496
|
- test/drawing/tc_pic.rb
|
507
|
-
- test/drawing/
|
508
|
-
- test/drawing/
|
509
|
-
- test/drawing/
|
510
|
-
- test/drawing/
|
497
|
+
- test/drawing/tc_named_axis_data.rb
|
498
|
+
- test/drawing/tc_bubble_chart.rb
|
499
|
+
- test/drawing/tc_str_data.rb
|
500
|
+
- test/drawing/tc_drawing.rb
|
511
501
|
- test/drawing/tc_scatter_chart.rb
|
512
|
-
- test/drawing/tc_scatter_series.rb
|
513
|
-
- test/drawing/tc_ser_axis.rb
|
514
502
|
- test/drawing/tc_series.rb
|
515
|
-
- test/drawing/tc_series_title.rb
|
516
|
-
- test/drawing/tc_str_data.rb
|
517
|
-
- test/drawing/tc_str_val.rb
|
518
503
|
- test/drawing/tc_title.rb
|
519
|
-
- test/drawing/
|
520
|
-
- test/drawing/
|
521
|
-
- test/drawing/
|
522
|
-
- test/drawing/tc_vml_drawing.rb
|
504
|
+
- test/drawing/tc_ser_axis.rb
|
505
|
+
- test/drawing/tc_picture_locking.rb
|
506
|
+
- test/drawing/tc_pie_series.rb
|
523
507
|
- test/drawing/tc_vml_shape.rb
|
524
|
-
- test/
|
525
|
-
- test/
|
526
|
-
- test/
|
527
|
-
- test/
|
528
|
-
- test/
|
529
|
-
- test/
|
530
|
-
- test/
|
531
|
-
- test/
|
508
|
+
- test/drawing/tc_axes.rb
|
509
|
+
- test/drawing/tc_vml_drawing.rb
|
510
|
+
- test/drawing/tc_pie_3D_chart.rb
|
511
|
+
- test/drawing/tc_area_series.rb
|
512
|
+
- test/drawing/tc_graphic_frame.rb
|
513
|
+
- test/drawing/tc_one_cell_anchor.rb
|
514
|
+
- test/drawing/tc_data_source.rb
|
515
|
+
- test/drawing/tc_val_axis.rb
|
516
|
+
- test/drawing/tc_scaling.rb
|
517
|
+
- test/drawing/tc_bar_3D_chart.rb
|
518
|
+
- test/util/tc_simple_typed_list.rb
|
519
|
+
- test/util/tc_mime_type_utils.rb
|
520
|
+
- test/util/tc_validators.rb
|
521
|
+
- test/util/tc_serialized_attributes.rb
|
522
|
+
- test/tc_axlsx.rb
|
523
|
+
- test/stylesheet/tc_fill.rb
|
532
524
|
- test/stylesheet/tc_border.rb
|
525
|
+
- test/stylesheet/tc_gradient_stop.rb
|
526
|
+
- test/stylesheet/tc_gradient_fill.rb
|
527
|
+
- test/stylesheet/tc_table_style.rb
|
528
|
+
- test/stylesheet/tc_font.rb
|
529
|
+
- test/stylesheet/tc_pattern_fill.rb
|
530
|
+
- test/stylesheet/tc_color.rb
|
531
|
+
- test/stylesheet/tc_num_fmt.rb
|
532
|
+
- test/stylesheet/tc_styles.rb
|
533
533
|
- test/stylesheet/tc_border_pr.rb
|
534
|
-
- test/stylesheet/tc_cell_alignment.rb
|
535
534
|
- test/stylesheet/tc_cell_protection.rb
|
535
|
+
- test/stylesheet/tc_xf.rb
|
536
536
|
- test/stylesheet/tc_cell_style.rb
|
537
|
-
- test/stylesheet/
|
537
|
+
- test/stylesheet/tc_table_styles.rb
|
538
538
|
- test/stylesheet/tc_dxf.rb
|
539
|
-
- test/stylesheet/tc_fill.rb
|
540
|
-
- test/stylesheet/tc_font.rb
|
541
|
-
- test/stylesheet/tc_gradient_fill.rb
|
542
|
-
- test/stylesheet/tc_gradient_stop.rb
|
543
|
-
- test/stylesheet/tc_num_fmt.rb
|
544
|
-
- test/stylesheet/tc_pattern_fill.rb
|
545
|
-
- test/stylesheet/tc_styles.rb
|
546
|
-
- test/stylesheet/tc_table_style.rb
|
547
539
|
- test/stylesheet/tc_table_style_element.rb
|
548
|
-
- test/stylesheet/
|
549
|
-
- test/stylesheet/tc_xf.rb
|
550
|
-
- test/tc_axlsx.rb
|
540
|
+
- test/stylesheet/tc_cell_alignment.rb
|
551
541
|
- test/tc_helper.rb
|
542
|
+
- test/doc_props/tc_core.rb
|
543
|
+
- test/doc_props/tc_app.rb
|
544
|
+
- test/content_type/tc_override.rb
|
545
|
+
- test/content_type/tc_content_type.rb
|
546
|
+
- test/content_type/tc_default.rb
|
547
|
+
- test/rels/tc_relationship.rb
|
548
|
+
- test/rels/tc_relationships.rb
|
549
|
+
- test/profile.rb
|
550
|
+
- test/fixtures/image1_fake.jpg
|
551
|
+
- test/fixtures/image1.jpeg
|
552
|
+
- test/fixtures/image1.gif
|
553
|
+
- test/fixtures/image1.png
|
554
|
+
- test/fixtures/image1.jpg
|
555
|
+
- test/benchmark.rb
|
552
556
|
- test/tc_package.rb
|
553
|
-
- test/util/tc_mime_type_utils.rb
|
554
|
-
- test/util/tc_serialized_attributes.rb
|
555
|
-
- test/util/tc_simple_typed_list.rb
|
556
|
-
- test/util/tc_validators.rb
|
557
|
-
- test/workbook/tc_defined_name.rb
|
558
|
-
- test/workbook/tc_shared_strings_table.rb
|
559
|
-
- test/workbook/tc_workbook.rb
|
560
557
|
- test/workbook/tc_workbook_view.rb
|
561
|
-
- test/workbook/
|
562
|
-
- test/workbook/worksheet/auto_filter/tc_filter_column.rb
|
563
|
-
- test/workbook/worksheet/auto_filter/tc_filters.rb
|
564
|
-
- test/workbook/worksheet/tc_break.rb
|
565
|
-
- test/workbook/worksheet/tc_cell.rb
|
566
|
-
- test/workbook/worksheet/tc_cfvo.rb
|
567
|
-
- test/workbook/worksheet/tc_col.rb
|
568
|
-
- test/workbook/worksheet/tc_color_scale.rb
|
569
|
-
- test/workbook/worksheet/tc_comment.rb
|
570
|
-
- test/workbook/worksheet/tc_comments.rb
|
571
|
-
- test/workbook/worksheet/tc_conditional_formatting.rb
|
558
|
+
- test/workbook/tc_defined_name.rb
|
572
559
|
- test/workbook/worksheet/tc_data_bar.rb
|
560
|
+
- test/workbook/worksheet/tc_worksheet_hyperlink.rb
|
573
561
|
- test/workbook/worksheet/tc_data_validation.rb
|
574
|
-
- test/workbook/worksheet/tc_date_time_converter.rb
|
575
|
-
- test/workbook/worksheet/tc_header_footer.rb
|
576
|
-
- test/workbook/worksheet/tc_icon_set.rb
|
577
|
-
- test/workbook/worksheet/tc_outline_pr.rb
|
578
|
-
- test/workbook/worksheet/tc_page_margins.rb
|
579
|
-
- test/workbook/worksheet/tc_page_set_up_pr.rb
|
580
|
-
- test/workbook/worksheet/tc_page_setup.rb
|
581
|
-
- test/workbook/worksheet/tc_pane.rb
|
582
|
-
- test/workbook/worksheet/tc_pivot_table.rb
|
583
562
|
- test/workbook/worksheet/tc_pivot_table_cache_definition.rb
|
584
|
-
- test/workbook/worksheet/tc_print_options.rb
|
585
563
|
- test/workbook/worksheet/tc_protected_range.rb
|
586
|
-
- test/workbook/worksheet/tc_rich_text.rb
|
587
|
-
- test/workbook/worksheet/tc_rich_text_run.rb
|
588
|
-
- test/workbook/worksheet/tc_row.rb
|
589
564
|
- test/workbook/worksheet/tc_selection.rb
|
565
|
+
- test/workbook/worksheet/tc_rich_text.rb
|
566
|
+
- test/workbook/worksheet/tc_date_time_converter.rb
|
567
|
+
- test/workbook/worksheet/tc_table_style_info.rb
|
568
|
+
- test/workbook/worksheet/tc_conditional_formatting.rb
|
569
|
+
- test/workbook/worksheet/tc_page_setup.rb
|
570
|
+
- test/workbook/worksheet/tc_comments.rb
|
571
|
+
- test/workbook/worksheet/tc_sheet_view.rb
|
590
572
|
- test/workbook/worksheet/tc_sheet_calc_pr.rb
|
591
|
-
- test/workbook/worksheet/
|
573
|
+
- test/workbook/worksheet/tc_color_scale.rb
|
574
|
+
- test/workbook/worksheet/tc_worksheet.rb
|
575
|
+
- test/workbook/worksheet/tc_rich_text_run.rb
|
592
576
|
- test/workbook/worksheet/tc_sheet_pr.rb
|
577
|
+
- test/workbook/worksheet/auto_filter/tc_filters.rb
|
578
|
+
- test/workbook/worksheet/auto_filter/tc_auto_filter.rb
|
579
|
+
- test/workbook/worksheet/auto_filter/tc_filter_column.rb
|
580
|
+
- test/workbook/worksheet/tc_cell.rb
|
593
581
|
- test/workbook/worksheet/tc_sheet_protection.rb
|
594
|
-
- test/workbook/worksheet/
|
582
|
+
- test/workbook/worksheet/tc_pane.rb
|
583
|
+
- test/workbook/worksheet/tc_header_footer.rb
|
595
584
|
- test/workbook/worksheet/tc_table.rb
|
596
|
-
- test/workbook/worksheet/
|
597
|
-
- test/workbook/worksheet/
|
598
|
-
- test/workbook/worksheet/
|
585
|
+
- test/workbook/worksheet/tc_page_margins.rb
|
586
|
+
- test/workbook/worksheet/tc_cfvo.rb
|
587
|
+
- test/workbook/worksheet/tc_col.rb
|
588
|
+
- test/workbook/worksheet/tc_pivot_table.rb
|
589
|
+
- test/workbook/worksheet/tc_break.rb
|
590
|
+
- test/workbook/worksheet/tc_sheet_format_pr.rb
|
591
|
+
- test/workbook/worksheet/tc_print_options.rb
|
592
|
+
- test/workbook/worksheet/tc_comment.rb
|
593
|
+
- test/workbook/worksheet/tc_outline_pr.rb
|
594
|
+
- test/workbook/worksheet/tc_row.rb
|
595
|
+
- test/workbook/worksheet/tc_icon_set.rb
|
596
|
+
- test/workbook/worksheet/tc_page_set_up_pr.rb
|
597
|
+
- test/workbook/tc_shared_strings_table.rb
|
598
|
+
- test/workbook/tc_workbook.rb
|