axlsx 1.3.5 → 1.3.6

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 (38) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +26 -17
  4. data/examples/conditional_formatting/example_conditional_formatting.rb +4 -2
  5. data/examples/example.rb +22 -9
  6. data/examples/pivot_table.rb +0 -2
  7. data/lib/axlsx/drawing/axes.rb +57 -0
  8. data/lib/axlsx/drawing/axis.rb +16 -13
  9. data/lib/axlsx/drawing/bar_3D_chart.rb +16 -12
  10. data/lib/axlsx/drawing/cat_axis.rb +2 -10
  11. data/lib/axlsx/drawing/d_lbls.rb +1 -1
  12. data/lib/axlsx/drawing/drawing.rb +2 -0
  13. data/lib/axlsx/drawing/line_3D_chart.rb +27 -70
  14. data/lib/axlsx/drawing/line_chart.rb +99 -0
  15. data/lib/axlsx/drawing/line_series.rb +20 -2
  16. data/lib/axlsx/drawing/scatter_chart.rb +27 -17
  17. data/lib/axlsx/drawing/ser_axis.rb +15 -16
  18. data/lib/axlsx/drawing/val_axis.rb +14 -13
  19. data/lib/axlsx/drawing/vml_shape.rb +18 -77
  20. data/lib/axlsx/util/serialized_attributes.rb +0 -1
  21. data/lib/axlsx/version.rb +1 -1
  22. data/lib/axlsx/workbook/worksheet/comment.rb +10 -23
  23. data/lib/axlsx/workbook/worksheet/conditional_formatting_rule.rb +5 -3
  24. data/test/benchmark.rb +0 -1
  25. data/test/drawing/tc_axis.rb +15 -17
  26. data/test/drawing/tc_cat_axis.rb +9 -9
  27. data/test/drawing/tc_line_chart.rb +39 -0
  28. data/test/drawing/tc_line_series.rb +8 -2
  29. data/test/drawing/tc_ser_axis.rb +13 -12
  30. data/test/drawing/tc_val_axis.rb +6 -6
  31. data/test/drawing/tc_vml_shape.rb +9 -3
  32. data/test/profile.rb +5 -11
  33. data/test/tc_helper.rb +1 -0
  34. data/test/util/tc_validators.rb +5 -1
  35. data/test/workbook/worksheet/tc_comment.rb +5 -1
  36. data/test/workbook/worksheet/tc_comments.rb +2 -2
  37. data/test/workbook/worksheet/tc_conditional_formatting.rb +7 -0
  38. metadata +21 -55
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d5ac3fa208421a6a360082bbc4b4365cc4109e89
4
+ data.tar.gz: 45f0bc90cd313ae0042a63c868166177ab312184
5
+ SHA512:
6
+ metadata.gz: 1c9396cf2d1f3841902f4de9787a7f793fd98795bd21a0a77af383e38c29e8428ea9b8d507d7b9b24e4a25a548ffa561a92c7f9cfb48e59e87fc87ba33a9f390
7
+ data.tar.gz: 7d48a79d7beb734a9f4d8abe3011df69c10a5fab90b284bbd0924742d66b70adbff793d4462248bafc682418aca7096668b2e49fecb0acb6841fd23823dd239e
@@ -1,6 +1,13 @@
1
1
  CHANGELOG
2
2
  ---------
3
-
3
+ - **November.5.12**:1.3.2
4
+ - MASSIVE REFACTORING
5
+ - Patch for apostrophes in worksheet names
6
+ - added sheet_by_name for workbook so you can now find your worksheets
7
+ by name
8
+ - added insert_worksheet so you can now add a worksheet to an
9
+ arbitrary position in the worksheets list.
10
+ - reduced memory consumption for package parts post serialization
4
11
  - **September.30.12**: 1.3.1
5
12
  - Improved control character handling
6
13
  - Added stored auto filter values and date grouping items
@@ -221,3 +228,4 @@ in value caches
221
228
  - Updated documentation
222
229
 
223
230
  ##October.20.11: 0.1.0 release
231
+
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  Axlsx: Office Open XML Spreadsheet Generation
2
2
  ====================================
3
- [![Build Status](https://secure.travis-ci.org/randym/axlsx.png)](http://travis-ci.org/randym/axlsx/)
3
+ [![Build Status](https://secure.travis-ci.org/randym/axlsx.png?branch=master)](http://travis-ci.org/randym/axlsx/)
4
4
 
5
5
  If you are using axlsx for comercial purposes, or just want to show your
6
6
  appreciation for the gem, please don't hesitate to make a donation.
@@ -17,28 +17,30 @@ appreciation for the gem, please don't hesitate to make a donation.
17
17
 
18
18
  **Author**: Randy Morgan
19
19
 
20
- **Copyright**: 2011 - 2012
20
+ **Copyright**: 2011 - 2013
21
21
 
22
22
  **License**: MIT License
23
23
 
24
- **Latest Version**: 1.3.5
24
+ **Latest Version**: 1.3.6
25
25
 
26
- **Ruby Version**: 1.8.7, 1.9.2, 1.9.3
26
+ **Ruby Version**: 1.8.7 (soon to be depreciated!!!), 1.9.2, 1.9.3, 2.0.0
27
27
 
28
28
  **JRuby Version**: 1.6.7 1.8 and 1.9 modes
29
29
 
30
30
  **Rubinius Version**: rubinius 2.0.0dev * lower versions may run, this gem always tests against head.
31
31
 
32
- **Release Date**: February 4th 2013
32
+ **Release Date**: April 24th 2013
33
33
 
34
34
  If you are working in rails, or with active record see:
35
- * http://github.com/randym/acts_as_xlsx
35
+ [acts_as_xlsx](http://github.com/randym/acts_as_xlsx)
36
+
36
37
  acts_as_xlsx is a simple ActiveRecord mixin that lets you generate a workbook with:
37
38
 
38
39
  ```ruby
39
40
  Posts.where(created_at > Time.now-30.days).to_xlsx
40
41
  ```
41
42
 
43
+
42
44
  ** and **
43
45
 
44
46
  * http://github.com/straydogstudio/axlsx_rails
@@ -47,6 +49,12 @@ Axlsx_Rails provides an Axlsx renderer so you can move all your spreadsheet code
47
49
  There are guides for using axlsx and acts_as_xlsx here:
48
50
  [http://axlsx.blog.randym.net](http://axlsx.blog.randym.net)
49
51
 
52
+ If you are working with ActiveAdmin see:
53
+
54
+ [activeadmin_axlsx](http://github.com/randym/activeadmin_axlsx)
55
+
56
+ It provies a plugin and dsl for generating downloadable reports.
57
+
50
58
  The examples directory contains a number of more specific examples as
51
59
  well.
52
60
 
@@ -152,6 +160,13 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem,
152
160
 
153
161
  #Change log
154
162
  ---------
163
+ - **April.24.13**:1.3.6
164
+ - Fixed LibreOffice/OpenOffice issue to properly apply colors to lines
165
+ in charts.
166
+ - Added support for specifying between/notBetween formula in an array.
167
+ *thanks* straydogstudio!
168
+ - Added standard line chart support. *thanks* scambra
169
+ - Fixed straydogstudio's link in the README. *thanks* nogara!
155
170
  - **February.4.13**:1.3.5
156
171
  - converted vary_colors for chart data to instance variable with appropriate defulats for the various charts.
157
172
  - Added trust_input method on Axlsx to instruct the serializer to skip HTML escaping. This will give you a tremendous performance boost,
@@ -172,14 +187,6 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem,
172
187
  - Improvements in autowidth calculation.
173
188
  - **November.8.12**:1.3.3
174
189
  - Patched cell run styles for u and validation for family
175
- - **November.5.12**:1.3.2
176
- - MASSIVE REFACTORING
177
- - Patch for apostrophes in worksheet names
178
- - added sheet_by_name for workbook so you can now find your worksheets
179
- by name
180
- - added insert_worksheet so you can now add a worksheet to an
181
- arbitrary position in the worksheets list.
182
- - reduced memory consumption for package parts post serialization
183
190
 
184
191
  Please see the {file:CHANGELOG.md} document for past release information.
185
192
 
@@ -247,7 +254,7 @@ done without the help of the people below.
247
254
 
248
255
  [rfc2616](https://github.com/rfc2616) - for FINALLY working out the interop issues with google docs.
249
256
 
250
- [straydogstudio](https://github.com/straydocstudio) - For making an AWESOME axlsx templating gem for rails.
257
+ [straydogstudio](https://github.com/straydogstudio) - For making an AWESOME axlsx templating gem for rails.
251
258
 
252
259
  [MitchellAJ](https://github.com/MitchellAJ) - For catching a bug in font_size calculations, finding some old code in an example and above all for reporting all of that brilliantly
253
260
 
@@ -262,11 +269,13 @@ air and our feet on the ground.
262
269
 
263
270
  [ball-hayden](https://github.com/ball-hayden) - For making sure we only get the right characters in our sheet names.
264
271
 
265
- [nibus](https://github.com/nibus) - For patching sheet name unequeness.
272
+ [nibus](https://github.com/nibus) - For patching sheet name uniqueness.
273
+
274
+ [scambra](https://github.com/scambra) - for keeping our lines in line!
266
275
 
267
276
  #Copyright and License
268
277
  ----------
269
278
 
270
- Axlsx © 2011-2012 by [Randy Morgan](mailto:digial.ipseity@gmail.com).
279
+ Axlsx © 2011-2013 by [Randy Morgan](mailto:digial.ipseity@gmail.com).
271
280
 
272
281
  Axlsx is licensed under the MIT license. Please see the LICENSE document for more information.
@@ -11,8 +11,8 @@ percent = book.styles.add_style(:format_code => "0.00%", :border => Axlsx::STYLE
11
11
  money = book.styles.add_style(:format_code => '0,000', :border => Axlsx::STYLE_THIN_BORDER)
12
12
 
13
13
  # define the style for conditional formatting
14
- profitable = book.styles.add_style( :fg_color=>"FF428751",
15
- :type => :dxf)
14
+ profitable = book.styles.add_style( :fg_color => "FF428751", :type => :dxf )
15
+ unprofitable = wb.styles.add_style( :fg_color => "FF0000", :type => :dxf )
16
16
 
17
17
  book.add_worksheet(:name => "Cell Is") do |ws|
18
18
 
@@ -27,6 +27,8 @@ book.add_worksheet(:name => "Cell Is") do |ws|
27
27
 
28
28
  # Apply conditional formatting to range B3:B100 in the worksheet
29
29
  ws.add_conditional_formatting("B3:B100", { :type => :cellIs, :operator => :greaterThan, :formula => "100000", :dxfId => profitable, :priority => 1 })
30
+ # Apply conditional using the between operator; NOTE: supply an array to :formula for between/notBetween
31
+ sheet.add_conditional_formatting("C3:C100", { :type => :cellIs, :operator => :between, :formula => ["0.00%","100.00%"], :dxfId => unprofitable, :priority => 1 })
30
32
  end
31
33
 
32
34
  book.add_worksheet(:name => "Color Scale") do |ws|
@@ -408,7 +408,7 @@ if examples.include? :bar_chart
408
408
  sheet.add_row ["A Simple Bar Chart"]
409
409
  %w(first second third).each { |label| sheet.add_row [label, rand(24)+1] }
410
410
  sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A6", :end_at => "F20") do |chart|
411
- chart.add_series :data => sheet["B2:B4"], :labels => sheet["A2:A4"], :title => sheet["A1"]
411
+ chart.add_series :data => sheet["B2:B4"], :labels => sheet["A2:A4"], :title => sheet["A1"], :colors => ["00FF00", "0000FF"]
412
412
  end
413
413
  end
414
414
  end
@@ -423,7 +423,7 @@ if examples.include? :chart_gridlines
423
423
  sheet.add_row ["Bar Chart without gridlines"]
424
424
  %w(first second third).each { |label| sheet.add_row [label, rand(24)+1] }
425
425
  sheet.add_chart(Axlsx::Bar3DChart, :start_at => "A6", :end_at => "F20") do |chart|
426
- chart.add_series :data => sheet["B2:B4"], :labels => sheet["A2:A4"]
426
+ chart.add_series :data => sheet["B2:B4"], :labels => sheet["A2:A4"], :colors => ["00FF00", "FF0000"]
427
427
  chart.valAxis.gridlines = false
428
428
  chart.catAxis.gridlines = false
429
429
  end
@@ -455,14 +455,23 @@ if examples.include? :line_chart
455
455
  4.times do
456
456
  sheet.add_row [ rand(24)+1, rand(24)+1]
457
457
  end
458
- sheet.add_chart(Axlsx::Line3DChart, :title => "Simple Line Chart", :rotX => 30, :rotY => 20) do |chart|
458
+ sheet.add_chart(Axlsx::Line3DChart, :title => "Simple 3D Line Chart", :rotX => 30, :rotY => 20) do |chart|
459
459
  chart.start_at 0, 5
460
460
  chart.end_at 10, 20
461
- chart.add_series :data => sheet["A3:A6"], :title => sheet["A2"]
462
- chart.add_series :data => sheet["B3:B6"], :title => sheet["B2"]
461
+ chart.add_series :data => sheet["A3:A6"], :title => sheet["A2"], :color => "0000FF"
462
+ chart.add_series :data => sheet["B3:B6"], :title => sheet["B2"], :color => "FF0000"
463
463
  chart.catAxis.title = 'X Axis'
464
464
  chart.valAxis.title = 'Y Axis'
465
465
  end
466
+ sheet.add_chart(Axlsx::LineChart, :title => "Simple Line Chart", :rotX => 30, :rotY => 20) do |chart|
467
+ chart.start_at 0, 21
468
+ chart.end_at 10, 41
469
+ chart.add_series :data => sheet["A3:A6"], :title => sheet["A2"], :color => "FF0000"
470
+ chart.add_series :data => sheet["B3:B6"], :title => sheet["B2"], :color => "00FF00"
471
+ chart.catAxis.title = 'X Axis'
472
+ chart.valAxis.title = 'Y Axis'
473
+ end
474
+
466
475
  end
467
476
  end
468
477
  #```
@@ -479,8 +488,8 @@ if examples.include? :scatter_chart
479
488
  sheet.add_chart(Axlsx::ScatterChart, :title => "example 7: Scatter Chart") do |chart|
480
489
  chart.start_at 0, 4
481
490
  chart.end_at 10, 19
482
- chart.add_series :xData => sheet["B1:E1"], :yData => sheet["B2:E2"], :title => sheet["A1"]
483
- chart.add_series :xData => sheet["B3:E3"], :yData => sheet["B4:E4"], :title => sheet["A3"]
491
+ chart.add_series :xData => sheet["B1:E1"], :yData => sheet["B2:E2"], :title => sheet["A1"], :color => "FF0000"
492
+ chart.add_series :xData => sheet["B3:E3"], :yData => sheet["B4:E4"], :title => sheet["A3"], :color => "00FF00"
484
493
  end
485
494
  end
486
495
  end
@@ -583,6 +592,8 @@ if examples.include? :comments
583
592
  wb.add_worksheet(:name => 'comments') do |sheet|
584
593
  sheet.add_row ['Can we build it?']
585
594
  sheet.add_comment :ref => 'A1', :author => 'Bob', :text => 'Yes We Can!'
595
+ sheet.add_comment :ref => 'A2', :author => 'Bob', :text => 'Yes We Can! - but I dont think you need to know about it!', :visible => false
596
+
586
597
  end
587
598
  end
588
599
 
@@ -636,8 +647,8 @@ if examples.include? :conditional_formatting
636
647
  money = wb.styles.add_style(:format_code => '0,000', :border => Axlsx::STYLE_THIN_BORDER)
637
648
 
638
649
  # define the style for conditional formatting
639
- profitable = wb.styles.add_style( :fg_color=>"FF428751",
640
- :type => :dxf)
650
+ profitable = wb.styles.add_style( :fg_color => "FF428751", :type => :dxf )
651
+ unprofitable = wb.styles.add_style( :fg_color => "FF0000", :type => :dxf )
641
652
 
642
653
  wb.add_worksheet(:name => "Conditional Cell Is") do |sheet|
643
654
 
@@ -652,6 +663,8 @@ if examples.include? :conditional_formatting
652
663
 
653
664
  # Apply conditional formatting to range B3:B100 in the worksheet
654
665
  sheet.add_conditional_formatting("B3:B100", { :type => :cellIs, :operator => :greaterThan, :formula => "100000", :dxfId => profitable, :priority => 1 })
666
+ # Apply conditional using the between operator; NOTE: supply an array to :formula for between/notBetween
667
+ sheet.add_conditional_formatting("C3:C100", { :type => :cellIs, :operator => :between, :formula => ["0.00%","100.00%"], :dxfId => unprofitable, :priority => 1 })
655
668
  end
656
669
 
657
670
  wb.add_worksheet(:name => "Conditional Color Scale") do |sheet|
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env ruby -w -s
2
- # -*- coding: utf-8 -*-
3
-
4
2
  $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
5
3
  require 'axlsx'
6
4
 
@@ -0,0 +1,57 @@
1
+ module Axlsx
2
+
3
+ # The Axes class creates and manages axis information and
4
+ # serialization for charts.
5
+ class Axes
6
+
7
+ # @param [Hash] options options used to generate axis each key
8
+ # should be an axis name like :val_axix and its value should be the
9
+ # class of the axis type to construct.
10
+ def initialize(options={})
11
+ options.each do |name, axis_class|
12
+ add_axis(name, axis_class)
13
+ end
14
+ end
15
+
16
+ # [] provides assiciative access to a specic axis store in an axes
17
+ # instance.
18
+ # @return [Axis]
19
+ def [](name)
20
+ axes.assoc(name)[1]
21
+ end
22
+
23
+ # Serializes the object
24
+ # @param [String] str
25
+ # @param [Hash] options
26
+ # @option options ids
27
+ # If the ids option is specified only the axis identifier is
28
+ # serialized. Otherwise, each axis is serialized in full.
29
+ def to_xml_string(str = '', options = {})
30
+ if options[:ids]
31
+ axes.inject(str) { |string, axis| string << '<c:axId val="' << axis[1].id.to_s << '"/>' }
32
+ else
33
+ axes.each { |axis| axis[1].to_xml_string(str) }
34
+ end
35
+ end
36
+
37
+ # Adds an axis to the collection
38
+ # @param [Symbol] name The name of the axis
39
+ # @param [Axis] axis_class The axis class to generate
40
+ def add_axis(name, axis_class)
41
+ axis = axis_class.new
42
+ set_cross_axis(axis)
43
+ axes << [name, axis]
44
+ end
45
+
46
+ private
47
+
48
+ def axes
49
+ @axes ||= []
50
+ end
51
+
52
+ def set_cross_axis(axis)
53
+ axes.first[1].cross_axis = axis if axes.size == 1
54
+ axis.cross_axis = axes.first[1] unless axes.empty?
55
+ end
56
+ end
57
+ end
@@ -7,17 +7,13 @@ module Axlsx
7
7
  include Axlsx::OptionsParser
8
8
 
9
9
  # Creates an Axis object
10
- # @param [Integer] ax_id the id of this axis
11
- # @param [Integer] cross_ax the id of the perpendicular axis
10
+ # @option options [Axis] cross_axis the perpendicular axis
12
11
  # @option options [Symbol] ax_pos
13
12
  # @option options [Symbol] crosses
14
13
  # @option options [Symbol] tick_lbl_pos
15
14
  # @raise [ArgumentError] If axi_id or cross_ax are not unsigned integers
16
- def initialize(ax_id, cross_ax, options={})
17
- Axlsx::validate_unsigned_int(ax_id)
18
- Axlsx::validate_unsigned_int(cross_ax)
19
- @ax_id = ax_id
20
- @cross_ax = cross_ax
15
+ def initialize(options={})
16
+ @id = rand(8 ** 8)
21
17
  @format_code = "General"
22
18
  @delete = @label_rotation = 0
23
19
  @scaling = Scaling.new(:orientation=>:minMax)
@@ -37,13 +33,13 @@ module Axlsx
37
33
 
38
34
  # the id of the axis.
39
35
  # @return [Integer]
40
- attr_reader :ax_id
41
- alias :axID :ax_id
36
+ attr_reader :id
37
+ alias :axID :id
42
38
 
43
39
  # The perpendicular axis
44
40
  # @return [Integer]
45
- attr_reader :cross_ax
46
- alias :crossAx :cross_ax
41
+ attr_reader :cross_axis
42
+ alias :crossAx :cross_axis
47
43
 
48
44
  # The scaling of the axis
49
45
  # @see Scaling
@@ -94,6 +90,13 @@ module Axlsx
94
90
  def color=(color_rgb)
95
91
  @color = color_rgb
96
92
  end
93
+
94
+ # The crossing axis for this axis
95
+ # @param [Axis] axis
96
+ def cross_axis=(axis)
97
+ DataTypeValidator.validate "#{self.class}.cross_axis", [Axis], axis
98
+ @cross_axis = axis
99
+ end
97
100
 
98
101
  # The position of the axis
99
102
  # must be one of [:l, :r, :t, :b]
@@ -147,7 +150,7 @@ module Axlsx
147
150
  # @param [String] str
148
151
  # @return [String]
149
152
  def to_xml_string(str = '')
150
- str << '<c:axId val="' << @ax_id.to_s << '"/>'
153
+ str << '<c:axId val="' << @id.to_s << '"/>'
151
154
  @scaling.to_xml_string str
152
155
  str << '<c:delete val="'<< @delete.to_s << '"/>'
153
156
  str << '<c:axPos val="' << @ax_pos.to_s << '"/>'
@@ -175,7 +178,7 @@ module Axlsx
175
178
  end
176
179
  # some potential value in implementing this in full. Very detailed!
177
180
  str << '<c:txPr><a:bodyPr rot="' << @label_rotation.to_s << '"/><a:lstStyle/><a:p><a:pPr><a:defRPr/></a:pPr><a:endParaRPr/></a:p></c:txPr>'
178
- str << '<c:crossAx val="' << @cross_ax.to_s << '"/>'
181
+ str << '<c:crossAx val="' << @cross_axis.id.to_s << '"/>'
179
182
  str << '<c:crosses val="' << @crosses.to_s << '"/>'
180
183
  end
181
184
 
@@ -10,12 +10,16 @@ module Axlsx
10
10
 
11
11
  # the category axis
12
12
  # @return [CatAxis]
13
- attr_reader :cat_axis
13
+ def cat_axis
14
+ axes[:cat_axis]
15
+ end
14
16
  alias :catAxis :cat_axis
15
17
 
16
18
  # the value axis
17
19
  # @return [ValAxis]
18
- attr_reader :val_axis
20
+ def val_axis
21
+ axes[:val_axis]
22
+ end
19
23
  alias :valAxis :val_axis
20
24
 
21
25
  # The direction of the bars in the chart
@@ -75,10 +79,6 @@ module Axlsx
75
79
  def initialize(frame, options={})
76
80
  @vary_colors = true
77
81
  @gap_width, @gap_depth, @shape = nil, nil, nil
78
- @cat_ax_id = rand(8 ** 8)
79
- @val_ax_id = rand(8 ** 8)
80
- @cat_axis = CatAxis.new(@cat_ax_id, @val_ax_id)
81
- @val_axis = ValAxis.new(@val_ax_id, @cat_ax_id, :tick_lbl_pos => :low, :ax_pos => :l)
82
82
  super(frame, options)
83
83
  @series_type = BarSeries
84
84
  @view_3D = View3D.new({:r_ang_ax=>1}.merge(options))
@@ -131,17 +131,21 @@ module Axlsx
131
131
  str_inner << '<c:grouping val="' << grouping.to_s << '"/>'
132
132
  str_inner << '<c:varyColors val="' << vary_colors.to_s << '"/>'
133
133
  @series.each { |ser| ser.to_xml_string(str_inner) }
134
- @d_lbls.to_xml_string(str) if @d_lbls
134
+ @d_lbls.to_xml_string(str_inner) if @d_lbls
135
135
  str_inner << '<c:gapWidth val="' << @gap_width.to_s << '"/>' unless @gap_width.nil?
136
136
  str_inner << '<c:gapDepth val="' << @gap_depth.to_s << '"/>' unless @gap_depth.nil?
137
137
  str_inner << '<c:shape val="' << @shape.to_s << '"/>' unless @shape.nil?
138
- str_inner << '<c:axId val="' << @cat_ax_id.to_s << '"/>'
139
- str_inner << '<c:axId val="' << @val_ax_id.to_s << '"/>'
140
- str_inner << '<c:axId val="0"/>'
138
+ axes.to_xml_string(str_inner, :ids => true)
141
139
  str_inner << '</c:bar3DChart>'
142
- @cat_axis.to_xml_string str_inner
143
- @val_axis.to_xml_string str_inner
140
+ axes.to_xml_string(str_inner)
144
141
  end
145
142
  end
143
+
144
+ # A hash of axes used by this chart. Bar charts have a value and
145
+ # category axes specified via axex[:val_axes] and axes[:cat_axis]
146
+ # @return [Axes]
147
+ def axes
148
+ @axes ||= Axes.new(:val_axis => ValAxis, :cat_axis => CatAxis)
149
+ end
146
150
  end
147
151
  end
@@ -4,23 +4,15 @@ module Axlsx
4
4
  class CatAxis < Axis
5
5
 
6
6
  # Creates a new CatAxis object
7
- # @param [Integer] ax_id the id of this axis. Inherited
8
- # @param [Integer] cross_ax the id of the perpendicular axis. Inherited
9
- # @option options [Symbol] ax_pos. Inherited
10
- # @option options [Symbol] tick_lbl_pos. Inherited
11
- # @option options [Symbol] crosses. Inherited
12
- # @option options [Boolean] auto
13
- # @option options [Symbol] lbl_algn
14
- # @option options [Integer] lbl_offset
15
7
  # @option options [Integer] tick_lbl_skip
16
8
  # @option options [Integer] tick_mark_skip
17
- def initialize(ax_id, cross_ax, options={})
9
+ def initialize(options={})
18
10
  @tick_lbl_skip = 1
19
11
  @tick_mark_skip = 1
20
12
  self.auto = 1
21
13
  self.lbl_algn = :ctr
22
14
  self.lbl_offset = "100"
23
- super(ax_id, cross_ax, options)
15
+ super(options)
24
16
  end
25
17
 
26
18
  # From the docs: This element specifies that this axis is a date or text axis based on the data that is used for the axis labels, not a specific choice.