From 6739c249e7bf3cf7d2132b2aa49b6faf6bebec29 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Wed, 23 Nov 2011 12:28:10 +0900 Subject: -refactoring chart position and axis data/category for chart. -additional specs and documentation improvements. --- .yardoc/checksums | 44 +- .yardoc/objects/root.dat | Bin 425341 -> 427683 bytes .yardoc/proxy_types | Bin 38 -> 53 bytes .yardopts_guide | 19 + README.md | 23 +- doc/Axlsx.html | 6 +- doc/Axlsx/App.html | 2 +- doc/Axlsx/Axis.html | 64 ++- doc/Axlsx/Bar3DChart.html | 241 ++++---- doc/Axlsx/BarSeries.html | 70 +-- doc/Axlsx/Border.html | 2 +- doc/Axlsx/BorderPr.html | 2 +- doc/Axlsx/CatAxis.html | 65 +-- doc/Axlsx/CatAxisData.html | 400 +++++++++++++ doc/Axlsx/Cell.html | 2 +- doc/Axlsx/CellAlignment.html | 2 +- doc/Axlsx/CellProtection.html | 2 +- doc/Axlsx/CellStyle.html | 2 +- doc/Axlsx/Chart.html | 661 +++++++++++++++------- doc/Axlsx/Color.html | 2 +- doc/Axlsx/ContentType.html | 4 +- doc/Axlsx/Core.html | 2 +- doc/Axlsx/DataTypeValidator.html | 2 +- doc/Axlsx/Default.html | 2 +- doc/Axlsx/Drawing.html | 156 +++--- doc/Axlsx/Fill.html | 2 +- doc/Axlsx/Font.html | 2 +- doc/Axlsx/GradientFill.html | 2 +- doc/Axlsx/GradientStop.html | 2 +- doc/Axlsx/GraphicFrame.html | 12 +- doc/Axlsx/Line3DChart.html | 137 ++++- doc/Axlsx/LineSeries.html | 90 +-- doc/Axlsx/Marker.html | 2 +- doc/Axlsx/NumFmt.html | 2 +- doc/Axlsx/Override.html | 2 +- doc/Axlsx/Package.html | 2 +- doc/Axlsx/PatternFill.html | 2 +- doc/Axlsx/Pie3DChart.html | 184 +++--- doc/Axlsx/PieSeries.html | 119 +--- doc/Axlsx/RegexValidator.html | 2 +- doc/Axlsx/Relationship.html | 2 +- doc/Axlsx/Relationships.html | 4 +- doc/Axlsx/RestrictionValidator.html | 2 +- doc/Axlsx/Row.html | 2 +- doc/Axlsx/Scaling.html | 2 +- doc/Axlsx/SerAxis.html | 89 +-- doc/Axlsx/Series.html | 35 +- doc/Axlsx/SeriesTitle.html | 5 +- doc/Axlsx/SimpleTypedList.html | 103 +++- doc/Axlsx/Styles.html | 2 +- doc/Axlsx/TableStyle.html | 4 +- doc/Axlsx/TableStyleElement.html | 2 +- doc/Axlsx/TableStyles.html | 4 +- doc/Axlsx/Title.html | 2 +- doc/Axlsx/TwoCellAnchor.html | 320 ++--------- doc/Axlsx/ValAxis.html | 15 +- doc/Axlsx/ValAxisData.html | 326 +++++++++++ doc/Axlsx/View3D.html | 78 +-- doc/Axlsx/Workbook.html | 2 +- doc/Axlsx/Worksheet.html | 123 ++-- doc/Axlsx/Xf.html | 2 +- doc/_index.html | 16 +- doc/class_list.html | 2 +- doc/file.README.html | 24 +- doc/index.html | 24 +- doc/method_list.html | 894 ++++++++++++++++-------------- doc/top-level-namespace.html | 2 +- examples/example.rb | 5 +- lib/axlsx/drawing/axis.rb | 13 +- lib/axlsx/drawing/bar_3D_chart.rb | 42 +- lib/axlsx/drawing/bar_series.rb | 41 +- lib/axlsx/drawing/cat_axis.rb | 18 +- lib/axlsx/drawing/cat_axis_data.rb | 34 ++ lib/axlsx/drawing/chart.rb | 69 ++- lib/axlsx/drawing/drawing.rb | 26 +- lib/axlsx/drawing/graphic_frame.rb | 1 + lib/axlsx/drawing/line_3D_chart.rb | 12 +- lib/axlsx/drawing/line_series.rb | 50 +- lib/axlsx/drawing/pie_3D_chart.rb | 51 +- lib/axlsx/drawing/pie_series.rb | 56 +- lib/axlsx/drawing/ser_axis.rb | 27 +- lib/axlsx/drawing/series.rb | 5 +- lib/axlsx/drawing/series_title.rb | 2 +- lib/axlsx/drawing/two_cell_anchor.rb | 44 +- lib/axlsx/drawing/val_axis.rb | 8 +- lib/axlsx/drawing/val_axis_data.rb | 28 + lib/axlsx/drawing/view_3D.rb | 18 +- lib/axlsx/util/simple_typed_list.rb | 9 +- lib/axlsx/workbook/worksheet/worksheet.rb | 10 +- test/drawing/tc_axis.rb | 1 + test/drawing/tc_cat_axis_data.rb | 18 + test/drawing/tc_chart.rb | 12 + test/drawing/tc_line_series.rb | 27 + test/drawing/tc_line_series.tc | 34 -- test/drawing/tc_ser_axis.rb | 18 +- test/drawing/tc_two_cell_anchor.rb | 35 +- test/drawing/tc_val_axis.rb | 5 + test/drawing/tc_val_axis_data.rb | 18 + test/drawing/tc_view_3D.rb | 11 +- 99 files changed, 3067 insertions(+), 2104 deletions(-) create mode 100644 .yardopts_guide create mode 100644 doc/Axlsx/CatAxisData.html create mode 100644 doc/Axlsx/ValAxisData.html create mode 100644 lib/axlsx/drawing/cat_axis_data.rb create mode 100644 lib/axlsx/drawing/val_axis_data.rb create mode 100644 test/drawing/tc_cat_axis_data.rb create mode 100644 test/drawing/tc_line_series.rb delete mode 100644 test/drawing/tc_line_series.tc create mode 100644 test/drawing/tc_val_axis_data.rb diff --git a/.yardoc/checksums b/.yardoc/checksums index 5e186a00..4281ee7b 100644 --- a/.yardoc/checksums +++ b/.yardoc/checksums @@ -1,54 +1,56 @@ lib/axlsx/stylesheet/table_styles.rb 04b778652c29d612f63e93080d06c3936e48d765 lib/axlsx/stylesheet/table_style.rb b592135b8b02969a29bd24c28a13282f6af76f30 -lib/axlsx/drawing/pie_3D_chart.rb dd669c8dc9ef1f762d45a9589260c8c17308d944 +lib/axlsx/drawing/pie_3D_chart.rb 9370e48b73000c96ebd50712dc4b4a958ad8527d lib/axlsx/stylesheet/border_pr.rb 09dcb61ec7b0cf49f2da4c4f8ccba8f7e0df7b07 lib/axlsx/stylesheet/color.rb 4927aaebe27dda42d78bb7baf9a44edc1753c77f lib/axlsx/drawing/marker.rb 3507738522c02a3733a01f115d9ef22fae4ea542 lib/axlsx/util/constants.rb 20e4a98177305d407b77eb62f0bca5ecc29b234c lib/axlsx/stylesheet/cell_protection.rb ce494f9add6de0a51407ddd9122fffe95759a48a lib/axlsx/stylesheet/cell_style.rb 46c6ff183bce5c6b1ab6228823257d638007b03c -lib/axlsx/drawing/series_title.rb 7ace4ba7c7835db5a7c69d2319cd59ed8c45908a -lib/axlsx/drawing/line_series.rb 80f2c27edafacbc5de9bb4fac9916b0ad0030a63 -lib/axlsx/drawing/series.rb b35c182d9e3b09d99f743d3828344c4e5ac9c373 +lib/axlsx/drawing/series_title.rb 8f088942649b5b5cc351b621bf8fb252f33cb510 +lib/axlsx/drawing/line_series.rb ada7cbca0d561c2e2f6bad56c1eb5d8ea2c1f071 +lib/axlsx/drawing/series.rb 1cf010706e32e7e51affbc9edb9d4862a26b33ef lib/axlsx/package.rb eea7499e09e0936eeb8e08d10823f05990722023 lib/axlsx/stylesheet/cell_alignment.rb f67f6a0bc16bf13669ed7b18714e4de23825ed94 lib/axlsx/content_type/default.rb 8ec0d9d1e6bf261735739823acd460c271e3f5ed lib/axlsx/drawing/title.rb b46fb082e3bea936d129c8aa0998f3b71c9838cc -lib/axlsx/drawing/axis.rb 5316065040d08d4f15e5da2751a2ee90185dad61 +lib/axlsx/drawing/axis.rb 5e37bac9f4dd258265213d5621522eed3c614954 lib/axlsx/stylesheet/table_style_element.rb bee66d743e3113fb14adc7ebdecbeb606bfb49fc lib/axlsx/content_type/content_type.rb 6c576e1618f99f7163fffa6b6e89e964653dcb5f -lib/axlsx/rels/relationships.rb 9c741e180796259bb378a789fd484fa1d8f04425 lib/axlsx/stylesheet/num_fmt.rb dc830c6540465afa824881efa2f1ce4070957c47 +lib/axlsx/rels/relationships.rb 9c741e180796259bb378a789fd484fa1d8f04425 lib/axlsx.rb 7d8c589a0bdc16acf8774ae1b77d5177b030a80c -lib/axlsx/drawing/graphic_frame.rb 5ff7476b8fa3e2101fde200d1c65844084fb42f7 +lib/axlsx/drawing/graphic_frame.rb 43496359fac0e990ded62f04254232f3cec8f736 lib/axlsx/content_type/override.rb 72245683bca868f181d709a515f9152485653229 -lib/axlsx/drawing/bar_series.rb 48eb4533dd8fa89c40a8ab05e78cdb7b8061fd62 -lib/axlsx/drawing/pie_series.rb 76c67a0227e913fb14eb70d756323974718e204a +lib/axlsx/drawing/pie_series.rb df339ed3eeb5692077e3a134339d04e77c9bc89b +lib/axlsx/drawing/bar_series.rb 044a3c42d3781755012c863ca138257b85ff5c0a lib/axlsx/stylesheet/gradient_fill.rb 5fd260ec2b94ab75a970159035528548a9d21cd6 lib/axlsx/workbook/worksheet/row.rb f866a98341ce4e604908e42d00f2af09e58c75d2 -lib/axlsx/util/simple_typed_list.rb 2ae647d5305acd9181c3303d5638db46d190b786 +lib/axlsx/util/simple_typed_list.rb b95f7e8d8958361cb1946b8545126b9384ff9fd2 lib/axlsx/workbook/workbook.rb ec98ed826e6c3ca9c6e3303dbfbe00c0b5fb9aee lib/axlsx/stylesheet/fill.rb 35966285f5d759d63451005ceae3a5ae5ba2ceca -lib/axlsx/drawing/view_3D.rb aca4d987f0c2cd5d0a653c96ac2bc1df9392583a +lib/axlsx/drawing/view_3D.rb c8e25d57901dd7d679fe7d1ed674d5549ab6f1b3 lib/axlsx/stylesheet/xf.rb e3d6e2e4c3b0b33c91de4c3db16c73aca3db4473 -lib/axlsx/drawing/two_cell_anchor.rb cc320f580ff9c639daa670f7ba1a1648bf26c157 +lib/axlsx/drawing/two_cell_anchor.rb a9400212ca7ed64263fd77826c3d336115cae185 lib/axlsx/stylesheet/styles.rb 3679a8fe86270bdef96f02bcf76f2eac27b1c2ef -lib/axlsx/drawing/val_axis.rb 710e67120c1262ef4cbbb56b632a568731df3215 -lib/axlsx/drawing/cat_axis.rb bf9eae6efae39b003a98b44cc437e6e9b4c51985 -lib/axlsx/stylesheet/font.rb 8b002d5fcba2fb0979858517f5254aadf96c7e58 +lib/axlsx/drawing/val_axis.rb da067622f8b09e6caf5067955b277d75ab3c8943 +lib/axlsx/drawing/cat_axis.rb f046262d1e8d04ff697fe29b88725225cd406cb2 lib/axlsx/util/validators.rb 2320eee50ceee29cc0dbab95721a6c633dc660e1 +lib/axlsx/stylesheet/font.rb 8b002d5fcba2fb0979858517f5254aadf96c7e58 lib/axlsx/doc_props/app.rb 52f01e985a33253987177798d4e79ed208649b30 -lib/axlsx/workbook/worksheet/worksheet.rb 1af6b7e4a54b41e770709c26ad7100ed516448b8 +lib/axlsx/workbook/worksheet/worksheet.rb ba299b3a4f1e82f7da4fb6e28fad264dd6e2fbed lib/axlsx/workbook/worksheet/cell.rb 939623ffc2065e9ec26bc56d9e289d9137fe57d3 lib/axlsx/rels/relationship.rb a160c998acf7fd0ab8195ea6162b1eb2eab4963c lib/axlsx/stylesheet/border.rb 517bfcb43380919ce7abef494d5d3e50911b7c19 -lib/axlsx/drawing/ser_axis.rb e1072fa920f084e22fc6ef4697d3f7d455fb0550 -lib/axlsx/drawing/drawing.rb ca457723c04ec7f2c9d3d16846b4cf0a9045da07 -lib/axlsx/drawing/chart.rb 059fa0f1af9e145f2b28871ea4aaa70653ec589f +lib/axlsx/drawing/ser_axis.rb 6d15f6cc2092ef5c3baa314ed1af793247418d9b +lib/axlsx/drawing/drawing.rb a5d71d9c7e86f15fdea03754ab258009035151dd +lib/axlsx/drawing/chart.rb 2907d74c75580cd5f029a71140a750d4e69c869e lib/axlsx/version.rb eb4274097b7f8f3f60e4e3dd8d57fb6bf6148f36 lib/axlsx/stylesheet/gradient_stop.rb de34e289aeccb4abd9a3b7e60e816a0b12ffacff +lib/axlsx/drawing/cat_axis_data.rb efc95067f90bf8d0bb4ce0fa6e35b7b9d642e8b5 +lib/axlsx/drawing/val_axis_data.rb c57c0abf5abb4aca9fba774f20e2f2c04d3020e8 lib/axlsx/doc_props/core.rb 90ebc8086f6606af02275c27068c359a5647faf0 -lib/axlsx/drawing/bar_3D_chart.rb 90ee990d00f63aaa8bfa23805580b3fea16a74ac +lib/axlsx/drawing/bar_3D_chart.rb e5199cf0a33e416ea5ddf66677031ee08e5c116f lib/axlsx/drawing/scaling.rb d3b59eed1897dc2b07bb41b2245c6e4b3e274d7e lib/axlsx/stylesheet/pattern_fill.rb 817cf55beb3db160b2b56edb6c94de1ecf1ecee7 -lib/axlsx/drawing/line_3D_chart.rb 062b83115dccb3b67c737faea1adf5f0cfce1cea +lib/axlsx/drawing/line_3D_chart.rb de0a2c8a49259e0348fd2c642c08eb4c567bcf1b diff --git a/.yardoc/objects/root.dat b/.yardoc/objects/root.dat index ddb44a40..489afdf0 100644 Binary files a/.yardoc/objects/root.dat and b/.yardoc/objects/root.dat differ diff --git a/.yardoc/proxy_types b/.yardoc/proxy_types index 97e24d35..bc38fbb8 100644 Binary files a/.yardoc/proxy_types and b/.yardoc/proxy_types differ diff --git a/.yardopts_guide b/.yardopts_guide new file mode 100644 index 00000000..2a52073e --- /dev/null +++ b/.yardopts_guide @@ -0,0 +1,19 @@ +-t guide +--title YARD +-o doc_guide +--exclude /server/templates/ +--exclude /yard/rubygems/ +--asset docs/images:images +- +docs/WhatsNew.md +docs/GettingStarted.md +docs/Overview.md +docs/CodeObjects.md +docs/Tags.md +docs/Parser.md +docs/Handlers.md +docs/Templates.md +docs/Glossary.md +ChangeLog +LICENSE +LEGAL \ No newline at end of file diff --git a/README.md b/README.md index 4946ea13..7dfa0ba8 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Usage require 'rubygems' require 'axlsx' -A Simple Workbooka +A Simple Workbook p = Axlsx::Package.new p.workbook.add_worksheet do |sheet| @@ -124,10 +124,13 @@ Generating A Line Chart p.workbook.add_worksheet do |sheet| sheet.add_row ["First", 1, 5, 7, 9] sheet.add_row ["Second", 5, 2, 14, 9] - sheet.add_chart(Axlsx::Line3DChart, :start_at => [0,2], :end_at => [10, 15], :title=>"example 6: Line Chart") do |chart| + sheet.add_chart(Axlsx::Line3DChart, :title=>"example 6: Line Chart") do |chart| + chart.start_at 0, 2 + chart.end_at 10, 15 chart.add_series :data=>sheet.rows.first.cells[(1..-1)], :title=> sheet.rows.first.cells.first chart.add_series :data=>sheet.rows.last.cells[(1..-1)], :title=> sheet.rows.last.cells.first end + end p.serialize("example6.xlsx") @@ -147,19 +150,19 @@ This gem has 100% test coverage using test/unit. To execute tests for this gem, Changelog --------- -- **October.22.11**: 1.0.7 release +- **October.23.11**: 1.0.7 release preparation + - Added support for 3D options when creating a new chart. This lets you set the persective, rotation and other 3D attributes when using worksheet.add_chart - Updated serialization write test to verify write permissions and warn if it cannot run the test due to permission restrcitions. - - updated rake to include build, genoc and deploy commands. + - updated rake to include build, genoc and deploy tasks. - rebuilt documentation. - moved version constant to its own file - + - fixed bug in SerAxis that was requiring tickLblSkip and tickMarkSkip to be boolean. Should be unsigned int. + - Review and improve docs + - rebuild of anchor positioning to remove some spagetti code. Chart now supports a start_at and end_at method that accept an arrar for col/row positioning. See example6 for an example. You can still pass :start_at and :end_at options to worksheet.add_chart. + - Refactored cat and val axis data to keep series serialization a bit more DRY + Please see the {file:CHANGELOG.md} document for past release information. -On Deck -------- - -- Verification with ruby 1.9.3 -- Active Record support via package::serialize_ar so you can dump an AR result into a worksheet in one go. Copyright --------- diff --git a/doc/Axlsx.html b/doc/Axlsx.html index 1ec19a9a..02a04a9a 100644 --- a/doc/Axlsx.html +++ b/doc/Axlsx.html @@ -73,7 +73,7 @@
Defined in:
lib/axlsx/package.rb,
- lib/axlsx.rb,
lib/axlsx/version.rb,
lib/axlsx/drawing/axis.rb,
lib/axlsx/stylesheet/xf.rb,
lib/axlsx/doc_props/app.rb,
lib/axlsx/drawing/title.rb,
lib/axlsx/drawing/chart.rb,
lib/axlsx/drawing/series.rb,
lib/axlsx/util/constants.rb,
lib/axlsx/doc_props/core.rb,
lib/axlsx/drawing/marker.rb,
lib/axlsx/drawing/drawing.rb,
lib/axlsx/drawing/view_3D.rb,
lib/axlsx/stylesheet/fill.rb,
lib/axlsx/util/validators.rb,
lib/axlsx/drawing/scaling.rb,
lib/axlsx/stylesheet/font.rb,
lib/axlsx/drawing/ser_axis.rb,
lib/axlsx/stylesheet/color.rb,
lib/axlsx/drawing/cat_axis.rb,
lib/axlsx/drawing/val_axis.rb,
lib/axlsx/stylesheet/border.rb,
lib/axlsx/rels/relationship.rb,
lib/axlsx/stylesheet/styles.rb,
lib/axlsx/workbook/workbook.rb,
lib/axlsx/drawing/pie_series.rb,
lib/axlsx/drawing/bar_series.rb,
lib/axlsx/stylesheet/num_fmt.rb,
lib/axlsx/rels/relationships.rb,
lib/axlsx/drawing/line_series.rb,
lib/axlsx/drawing/bar_3D_chart.rb,
lib/axlsx/drawing/series_title.rb,
lib/axlsx/stylesheet/border_pr.rb,
lib/axlsx/drawing/pie_3D_chart.rb,
lib/axlsx/content_type/default.rb,
lib/axlsx/drawing/line_3D_chart.rb,
lib/axlsx/content_type/override.rb,
lib/axlsx/drawing/graphic_frame.rb,
lib/axlsx/stylesheet/cell_style.rb,
lib/axlsx/util/simple_typed_list.rb,
lib/axlsx/workbook/worksheet/row.rb,
lib/axlsx/stylesheet/table_style.rb,
lib/axlsx/workbook/worksheet/cell.rb,
lib/axlsx/stylesheet/pattern_fill.rb,
lib/axlsx/drawing/two_cell_anchor.rb,
lib/axlsx/stylesheet/table_styles.rb,
lib/axlsx/stylesheet/gradient_fill.rb,
lib/axlsx/stylesheet/gradient_stop.rb,
lib/axlsx/stylesheet/cell_alignment.rb,
lib/axlsx/content_type/content_type.rb,
lib/axlsx/stylesheet/cell_protection.rb,
lib/axlsx/workbook/worksheet/worksheet.rb,
lib/axlsx/stylesheet/table_style_element.rb
+ lib/axlsx.rb,
lib/axlsx/version.rb,
lib/axlsx/drawing/axis.rb,
lib/axlsx/doc_props/app.rb,
lib/axlsx/drawing/title.rb,
lib/axlsx/stylesheet/xf.rb,
lib/axlsx/drawing/chart.rb,
lib/axlsx/drawing/series.rb,
lib/axlsx/util/constants.rb,
lib/axlsx/drawing/marker.rb,
lib/axlsx/doc_props/core.rb,
lib/axlsx/drawing/view_3D.rb,
lib/axlsx/stylesheet/font.rb,
lib/axlsx/drawing/drawing.rb,
lib/axlsx/util/validators.rb,
lib/axlsx/drawing/scaling.rb,
lib/axlsx/stylesheet/fill.rb,
lib/axlsx/stylesheet/color.rb,
lib/axlsx/drawing/ser_axis.rb,
lib/axlsx/drawing/cat_axis.rb,
lib/axlsx/drawing/val_axis.rb,
lib/axlsx/stylesheet/border.rb,
lib/axlsx/workbook/workbook.rb,
lib/axlsx/stylesheet/styles.rb,
lib/axlsx/rels/relationship.rb,
lib/axlsx/drawing/bar_series.rb,
lib/axlsx/drawing/pie_series.rb,
lib/axlsx/rels/relationships.rb,
lib/axlsx/stylesheet/num_fmt.rb,
lib/axlsx/drawing/line_series.rb,
lib/axlsx/stylesheet/border_pr.rb,
lib/axlsx/drawing/series_title.rb,
lib/axlsx/content_type/default.rb,
lib/axlsx/drawing/bar_3D_chart.rb,
lib/axlsx/drawing/pie_3D_chart.rb,
lib/axlsx/drawing/line_3D_chart.rb,
lib/axlsx/stylesheet/cell_style.rb,
lib/axlsx/drawing/val_axis_data.rb,
lib/axlsx/content_type/override.rb,
lib/axlsx/drawing/cat_axis_data.rb,
lib/axlsx/drawing/graphic_frame.rb,
lib/axlsx/util/simple_typed_list.rb,
lib/axlsx/stylesheet/table_style.rb,
lib/axlsx/workbook/worksheet/row.rb,
lib/axlsx/stylesheet/table_styles.rb,
lib/axlsx/drawing/two_cell_anchor.rb,
lib/axlsx/workbook/worksheet/cell.rb,
lib/axlsx/stylesheet/pattern_fill.rb,
lib/axlsx/stylesheet/gradient_fill.rb,
lib/axlsx/stylesheet/gradient_stop.rb,
lib/axlsx/content_type/content_type.rb,
lib/axlsx/stylesheet/cell_alignment.rb,
lib/axlsx/stylesheet/cell_protection.rb,
lib/axlsx/workbook/worksheet/worksheet.rb,
lib/axlsx/stylesheet/table_style_element.rb
@@ -98,7 +98,7 @@ cell styles, automatically resized column widths and 3D pie charts. - Classes: App, Axis, Bar3DChart, BarSeries, Border, BorderPr, CatAxis, Cell, CellAlignment, CellProtection, CellStyle, Chart, Color, ContentType, Core, DataTypeValidator, Default, Drawing, Fill, Font, GradientFill, GradientStop, GraphicFrame, Line3DChart, LineSeries, Marker, NumFmt, Override, Package, PatternFill, Pie3DChart, PieSeries, RegexValidator, Relationship, Relationships, RestrictionValidator, Row, Scaling, SerAxis, Series, SeriesTitle, SimpleTypedList, Styles, TableStyle, TableStyleElement, TableStyles, Title, TwoCellAnchor, ValAxis, View3D, Workbook, Worksheet, Xf + Classes: App, Axis, Bar3DChart, BarSeries, Border, BorderPr, CatAxis, CatAxisData, Cell, CellAlignment, CellProtection, CellStyle, Chart, Color, ContentType, Core, DataTypeValidator, Default, Drawing, Fill, Font, GradientFill, GradientStop, GraphicFrame, Line3DChart, LineSeries, Marker, NumFmt, Override, Package, PatternFill, Pie3DChart, PieSeries, RegexValidator, Relationship, Relationships, RestrictionValidator, Row, Scaling, SerAxis, Series, SeriesTitle, SimpleTypedList, Styles, TableStyle, TableStyleElement, TableStyles, Title, TwoCellAnchor, ValAxis, ValAxisData, View3D, Workbook, Worksheet, Xf

@@ -2434,7 +2434,7 @@ The value validated diff --git a/doc/Axlsx/App.html b/doc/Axlsx/App.html index ead90508..fcbd72ee 100644 --- a/doc/Axlsx/App.html +++ b/doc/Axlsx/App.html @@ -2631,7 +2631,7 @@ The document as a string diff --git a/doc/Axlsx/Axis.html b/doc/Axlsx/Axis.html index 7f4d1e0b..4ae315c3 100644 --- a/doc/Axlsx/Axis.html +++ b/doc/Axlsx/Axis.html @@ -95,7 +95,7 @@

Overview

-the access class defines common properties and values for chart axis +the access class defines common properties and values for a chart axis.

@@ -242,7 +242,7 @@ specifies how the perpendicular axis is crossed must be one of [:autoZero,

-The number format format code for this axis. +The number format format code for this axis default :General.

@@ -487,6 +487,25 @@ a customizable set of options +

Raises:

+
    + +
  • + + + (ArgumentError) + + + + — +

    +If axId or crossAx are not unsigned integers +

    +
    + +
  • + +
@@ -494,7 +513,6 @@ a customizable set of options
 
 
-44
 45
 46
 47
@@ -507,20 +525,21 @@ a customizable set of options
 54
 55
 56
-57
+57 +58
-
# File 'lib/axlsx/drawing/axis.rb', line 44
+      
# File 'lib/axlsx/drawing/axis.rb', line 45
 
 def initialize(axId, crossAx, options={})
   Axlsx::validate_unsigned_int(axId)
   Axlsx::validate_unsigned_int(crossAx)
   @axId = axId
   @crossAx = crossAx
+  @scaling = Scaling.new(:orientation=>:minMax)
   self.axPos = :l
   self.tickLblPos = :nextTo
-  @scaling = Scaling.new(:orientation=>:minMax)
-  @formatCode = ""
+  self.format_code = "General"
   self.crosses = :autoZero
   options.each do |o|
     self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
@@ -550,7 +569,7 @@ a customizable set of options
 

-the id of the axis +the id of the axis.

@@ -578,12 +597,12 @@ the id of the axis
 
 
+7
 8
-9
-10
+9
-
# File 'lib/axlsx/drawing/axis.rb', line 8
+      
# File 'lib/axlsx/drawing/axis.rb', line 7
 
 def axId
   @axId
@@ -692,12 +711,12 @@ The perpendicular axis
       
 
 
+11
 12
-13
-14
+13
-
# File 'lib/axlsx/drawing/axis.rb', line 12
+      
# File 'lib/axlsx/drawing/axis.rb', line 11
 
 def crossAx
   @crossAx
@@ -779,7 +798,7 @@ specifies how the perpendicular axis is crossed must be one of [:autoZero,
 

-The number format format code for this axis +The number format format code for this axis default :General

@@ -858,6 +877,13 @@ The scaling of the axis +

See Also:

+ +
@@ -1003,7 +1029,6 @@ The document builder instance this objects xml will be added to.
 
 
-67
 68
 69
 70
@@ -1012,10 +1037,11 @@ The document builder instance this objects xml will be added to.
 73
 74
 75
-76
+76 +77
-
# File 'lib/axlsx/drawing/axis.rb', line 67
+      
# File 'lib/axlsx/drawing/axis.rb', line 68
 
 def to_xml(xml)
   xml.send('c:axId', :val=>@axId)
@@ -1038,7 +1064,7 @@ The document builder instance this objects xml will be added to.
 
     
     
diff --git a/doc/Axlsx/Bar3DChart.html b/doc/Axlsx/Bar3DChart.html
index 8cb43ac0..fcee1a86 100644
--- a/doc/Axlsx/Bar3DChart.html
+++ b/doc/Axlsx/Bar3DChart.html
@@ -106,54 +106,18 @@ that you can add to your worksheet.
 
 
-
-

Examples:

- -

-Creating a chart -

-

-
# This example creates two charts in a single sheet.
-# The first uses data directly fed to the sheet, while the second references cells withing the worksheet for data.
-
-require "rubygems" # if that is your preferred way to manage gems!
-require "axlsx"
-
-p = Axlsx::Package.new
-ws = p.workbook.add_worksheet
-ws.add_row :values => ["This is a chart with no data in the sheet"]
-
-chart = ws.add_chart(Axlsx::Bar3DChart, :start_at=> [0,1], :end_at=>[0,6], :title=>"Most Popular Pets")
-chart.add_series :data => [1, 9, 10], :labels => ["Slimy Reptiles", "Fuzzy Bunnies", "Rottweiler"]
-
-ws.add_row :values => ["This chart uses the data below"]
-title_row = ws.add_row :values => ["Least Popular Pets"]
-label_row = ws.add_row :values => ["", "Dry Skinned Reptiles", "Bald Cats", "Violent Parrots"]
-data_row = ws.add_row :values => ["Votes", 6, 4, 1]
-
-chart = ws.add_chart(Axlsx::Pie3DChart, :start_at => [0,11], :end_at =>[0,16], :title => title_row.cells.last)
-chart.add_series :data => data_row.cells[(1..-1)], :labels => label_row.cells  
-
-f = File.open('example_pie_3d_chart.xlsx', 'w')
-p.serialize(f)
-
- -
-

See Also:

@@ -347,8 +311,8 @@ grouping for a column, line, or area chart.

-The shabe of the bars or columns must be one of [:percentStacked, -:clustered, :standard, :stacked]. +The shabe of the bars or columns must be one of [:cone, :coneToMax, :box, +:cylinder, :pyramid, :pyramidToMax].

@@ -375,7 +339,7 @@ The shabe of the bars or columns must be one of [:percentStacked,

-the category axis. +the valueaxis.

@@ -392,7 +356,7 @@ the category axis.

Attributes inherited from Chart

-

end_at, graphic_frame, index, pn, series, series_type, show_legend, start_at, style, title, view3D

+

graphic_frame, index, pn, series, series_type, show_legend, style, title, view3D

@@ -465,7 +429,7 @@ Serializes the bar chart.

Methods inherited from Chart

-

#add_series

+

#add_series, #end_at, #from, #start_at, #to

Constructor Details

@@ -598,30 +562,93 @@ a customizable set of options +
  • + rotX + (Integer) + + + + +
  • + +
  • + hPercent + (String) + + + + +
  • + +
  • + rotY + (Integer) + + + + +
  • + +
  • + depthPercent + (String) + + + + +
  • + +
  • + rAngAx + (Boolean) + + + + +
  • + +
  • + perspective + (Integer) + + + + +
  • + +

    See Also:

    + +
    @@ -686,12 +713,12 @@ The direction of the bars in the chart must be one of [:bar, :col]
     
     
    -47
    -48
    -49
    +21 +22 +23 @@ -674,73 +674,15 @@ The document builder instance this objects xml will be added to. 46 47 48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -65 -66 -67 -68 -69 -70 -71 -72 -73 -74 -75 -76 -77 -78 +49 @@ -529,12 +532,12 @@ based on the data that is used for the axis labels, not a specific choice.
     
     
    -6
     7
    -8
    +8 +9 @@ -1137,19 +1138,19 @@ The starting marker for this chart - - + +
    -

    +

    - - (Integer) style + - (Title) title

    -The style for the chart. see ECMA Part 1 §21.2.2.196 +The title object for the chart.

    @@ -1163,7 +1164,7 @@ The style for the chart. see ECMA Part 1 §21.2.2.196
  • - (Integer) + (Title) @@ -1177,15 +1178,15 @@ The style for the chart. see ECMA Part 1 §21.2.2.196
     
     
    -14
    -15
    -16
    +37 +38 +39
  • @@ -1194,19 +1195,67 @@ The style for the chart. see ECMA Part 1 §21.2.2.196 - - + +
    -

    +

    - - (Title) title + - (Object) view3D

    -The title object for the chart. +The 3D view properties for the chart +

    + + +
    +
    +
    + + +
     
     
    -79
    -80
    -81
    -82
    -83
    -84
    -85
    -86
    -87
    -88
    -89
    +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71
    -
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 79
    +      
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 61
     
     def initialize(frame, options={})
       @barDir = :bar
    @@ -630,9 +657,9 @@ a customizable set of options
       @valAxId = rand(8 ** 8)
       @catAxis = CatAxis.new(@catAxId, @valAxId)
       @valAxis = ValAxis.new(@valAxId, @catAxId)
    -  @view3D = View3D.new(:rAngAx=>1)
       super(frame, options)      
       @series_type = BarSeries
    +  @view3D = View3D.new({:rAngAx=>1}.merge(options))
     end
     
    -
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 47
    +      
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 21
     
     def barDir
       @barDir
    @@ -743,12 +770,12 @@ the category axis
           
     
     
    -38
    -39
    -40
    +12 +13 +14
    -
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 38
    +      
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 12
     
     def catAxis
       @catAxis
    @@ -801,12 +828,12 @@ width.
           
     
     
    -51
    -52
    -53
    +25 +26 +27
    -
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 51
    +      
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 25
     
     def gapDepth
       @gapDepth
    @@ -859,12 +886,12 @@ width.
           
     
     
    -55
    -56
    -57
    +29 +30 +31
    -
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 55
    +      
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 29
     
     def gapWidth
       @gapWidth
    @@ -917,12 +944,12 @@ grouping for a column, line, or area chart. must be one of
           
     
     
    -60
    -61
    -62
    +34 +35 +36
    -
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 60
    +      
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 34
     
     def grouping
       @grouping
    @@ -946,8 +973,8 @@ grouping for a column, line, or area chart. must be one of
     

    -The shabe of the bars or columns must be one of [:percentStacked, -:clustered, :standard, :stacked] +The shabe of the bars or columns must be one of [:cone, :coneToMax, :box, +:cylinder, :pyramid, :pyramidToMax]

    @@ -975,12 +1002,12 @@ The shabe of the bars or columns must be one of [:percentStacked,
     
     
    -65
    -66
    -67
    +39 +40 +41
    -
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 65
    +      
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 39
     
     def shape
       @shape
    @@ -1004,7 +1031,7 @@ The shabe of the bars or columns must be one of [:percentStacked,
     

    -the category axis +the valueaxis

    @@ -1032,12 +1059,12 @@ the category axis
     
     
    -42
    -43
    -44
    +16 +17 +18
    -
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 42
    +      
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 16
     
     def valAxis
       @valAxis
    @@ -1093,27 +1120,27 @@ Serializes the bar chart
           
     
     
    -119
    -120
    -121
    -122
    -123
    -124
    -125
    -126
    -127
    -128
    -129
    -130
    -131
    -132
    -133
    -134
    -135
    -136
    +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118
    -
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 119
    +      
    # File 'lib/axlsx/drawing/bar_3D_chart.rb', line 101
     
     def to_xml
       super() do |xml|
    @@ -1144,7 +1171,7 @@ Serializes the bar chart
     
         
         
    diff --git a/doc/Axlsx/BarSeries.html b/doc/Axlsx/BarSeries.html
    index 749762da..303d12f3 100644
    --- a/doc/Axlsx/BarSeries.html
    +++ b/doc/Axlsx/BarSeries.html
    @@ -416,8 +416,8 @@ a customizable set of options
     def initialize(chart, options={})
       @shape = :box
       super(chart, options)
    -  self.data = options[:data]  || []
    -  self.labels = options[:labels] || []
    +  self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil?
    +  self.data = ValAxisData.new(options[:data]) unless options[:data].nil?
     end
     
    # File 'lib/axlsx/drawing/bar_series.rb', line 43
     
     def to_xml(xml)
       super(xml) do |xml|
    -    if !labels.empty?
    -      xml.send('c:cat') {
    -        xml.send('c:strRef') {
    -          xml.send('c:f', Axlsx::cell_range(labels))
    -          xml.send('c:strCache') {
    -            xml.send('c:ptCount', :val=>labels.size)
    -            labels.each_with_index do |cell, index|
    -              v = cell.is_a?(Cell) ? cell.value : cell
    -              xml.send('c:pt', :idx=>index) {
    -                xml.send('c:v', v)
    -              }                          
    -            end
    -          }
    -        }
    -      }
    -    end
    -    xml.send('c:val') {
    -      xml.send('c:numRef') {
    -        xml.send('c:f', Axlsx::cell_range(data))
    -        xml.send('c:numCache') {
    -          xml.send('c:formatCode', 'General')
    -          xml.send('c:ptCount', :val=>data.size)
    -          data.each_with_index do |cell, index|
    -            v = cell.is_a?(Cell) ? cell.value : cell
    -            xml.send('c:pt', :idx=>index) {
    -              xml.send('c:v', v) 
    -            }
    -          end
    -        }                        
    -      }
    -    }
    +    @labels.to_xml(xml) unless @labels.nil?
    +    @data.to_xml(xml) unless @data.nil?
         xml.send('c:shape', :val=>@shape)
       end      
     end
    @@ -755,7 +697,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/Border.html b/doc/Axlsx/Border.html
    index acb2adbc..209a4388 100644
    --- a/doc/Axlsx/Border.html
    +++ b/doc/Axlsx/Border.html
    @@ -766,7 +766,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/BorderPr.html b/doc/Axlsx/BorderPr.html
    index cbacb66f..e4bcb6ab 100644
    --- a/doc/Axlsx/BorderPr.html
    +++ b/doc/Axlsx/BorderPr.html
    @@ -700,7 +700,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/CatAxis.html b/doc/Axlsx/CatAxis.html
    index 82f7c980..5babf097 100644
    --- a/doc/Axlsx/CatAxis.html
    +++ b/doc/Axlsx/CatAxis.html
    @@ -336,7 +336,7 @@ Creates a new CatAxis object
           
             —
             

    -the id of this axis +the id of this axis. Inherited

    @@ -353,7 +353,7 @@ the id of this axis —

    -the id of the perpendicular axis +the id of the perpendicular axis. Inherited

    @@ -391,30 +391,39 @@ a customizable set of options
    • - axPos + axPos. (Symbol) - + —

      +Inherited +

      +
    • - tickLblPos + tickLblPos. (Symbol) - + —

      +Inherited +

      +
    • - crosses + crosses. (Symbol) - + —

      +Inherited +

      +
    • @@ -454,27 +463,21 @@ a customizable set of options
       
       
      -30
       31
       32
       33
       34
       35
      -36
      -37
      -38
      +36
    -
    # File 'lib/axlsx/drawing/cat_axis.rb', line 30
    +      
    # File 'lib/axlsx/drawing/cat_axis.rb', line 31
     
     def initialize(axId, crossAx, options={})
    -  super(axId, crossAx, options)
       self.auto = true
       self.lblAlgn = :ctr
       self.lblOffset = "100%"
    -  options.each do |o|
    -    self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
    -  end
    +  super(axId, crossAx, options)
     end
     
    -
    # File 'lib/axlsx/drawing/cat_axis.rb', line 6
    +      
    # File 'lib/axlsx/drawing/cat_axis.rb', line 7
     
     def auto
       @auto
    @@ -587,12 +590,12 @@ specifies how the perpendicular axis is crossed must be one of [:ctr, :l,
           
     
     
    -11
     12
    -13
    +13 +14
    -
    # File 'lib/axlsx/drawing/cat_axis.rb', line 11
    +      
    # File 'lib/axlsx/drawing/cat_axis.rb', line 12
     
     def lblAlgn
       @lblAlgn
    @@ -644,12 +647,12 @@ The offset of the labels must be between a string between 0 and 1000
           
     
     
    -16
     17
    -18
    +18 +19
    -
    # File 'lib/axlsx/drawing/cat_axis.rb', line 16
    +      
    # File 'lib/axlsx/drawing/cat_axis.rb', line 17
     
     def lblOffset
       @lblOffset
    @@ -726,17 +729,17 @@ The document builder instance this objects xml will be added to.
           
     
     
    +45
    +46
     47
     48
     49
     50
     51
    -52
    -53
    -54
    +52
    -
    # File 'lib/axlsx/drawing/cat_axis.rb', line 47
    +      
    # File 'lib/axlsx/drawing/cat_axis.rb', line 45
     
     def to_xml(xml)
       xml.send('c:catAx') {
    @@ -757,7 +760,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/CatAxisData.html b/doc/Axlsx/CatAxisData.html
    new file mode 100644
    index 00000000..fd0ea3aa
    --- /dev/null
    +++ b/doc/Axlsx/CatAxisData.html
    @@ -0,0 +1,400 @@
    +
    +
    +  
    +    
    +
    +  Class: Axlsx::CatAxisData
    +  
    +    — Documentation by YARD 0.7.3
    +  
    +
    +
    +  
    +
    +  
    +
    +
    +
    +  
    +
    +  
    +
    +
    +  
    +  
    +    
    +    
    +    
    +    
    +    
    +    
    +    

    Class: Axlsx::CatAxisData + + + +

    + +
    + +
    Inherits:
    +
    + SimpleTypedList + + + show all + +
    + + + + + + + + + +
    Defined in:
    +
    lib/axlsx/drawing/cat_axis_data.rb
    + +
    +
    + +

    Overview

    +
    +

    +The CatAxisData class serializes the category axis data for a chart +

    + + +
    +
    +
    + + +
    +

    Direct Known Subclasses

    +

    ValAxisData

    +
    + + + + + + + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from SimpleTypedList

    +

    allowed_types, locked_at, serialize_as

    + + + +

    + Instance Method Summary + (collapse) +

    + + + + + + + + + + + + +

    Methods inherited from SimpleTypedList

    +

    #<<, #==, #[]=, #delete, #delete_at, #lock, #method_missing, #protected?, #push, #unlock

    +
    +

    Constructor Details

    + +
    +

    + + - (CatAxisData) initialize(data = []) + + + +

    +
    +

    +Create a new CatAxisData object +

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + data + + + (Array, SimpleTypedList) + + + (defaults to: []) + + + — +

      +the data for this category axis. This can be a simple array or a simple +typed list of cells. +

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +7
    +8
    +9
    +10
    +
    +
    # File 'lib/axlsx/drawing/cat_axis_data.rb', line 7
    +
    +def initialize(data=[])
    +  super Object
    +  @list.concat data if data.is_a?(Array)
    +end
    +
    +
    +
    + +
    +
    +

    Dynamic Method Handling

    +

    + This class handles dynamic methods through the method_missing method + + in the class Axlsx::SimpleTypedList + +

    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + - (String) to_xml(xml) + + + +

    +
    +

    +Serializes the category axis data +

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + xml + + + (Nokogiri::XML::Builder) + + + + — +

      +The document builder instance this objects xml will be added to. +

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +15
    +16
    +17
    +18
    +19
    +20
    +21
    +22
    +23
    +24
    +25
    +26
    +27
    +28
    +29
    +30
    +
    +
    # File 'lib/axlsx/drawing/cat_axis_data.rb', line 15
    +
    +def to_xml(xml)
    +  xml.send('c:cat') {
    +    xml.send('c:strRef') {
    +      xml.send('c:f', Axlsx::cell_range(@list))
    +      xml.send('c:strCache') {
    +        xml.send('c:ptCount', :val=>size)
    +        each_with_index do |item, index|
    +          v = item.is_a?(Cell) ? item.value : item
    +          xml.send('c:pt', :idx=>index) {
    +            xml.send('c:v', v)
    +          }                          
    +        end
    +      }
    +    }
    +  }
    +end
    +
    +
    +
    + +
    + +
    + + + + + \ No newline at end of file diff --git a/doc/Axlsx/Cell.html b/doc/Axlsx/Cell.html index 44da43ed..bef1219e 100644 --- a/doc/Axlsx/Cell.html +++ b/doc/Axlsx/Cell.html @@ -1614,7 +1614,7 @@ xml text for the cell diff --git a/doc/Axlsx/CellAlignment.html b/doc/Axlsx/CellAlignment.html index 3da3113f..4ac86068 100644 --- a/doc/Axlsx/CellAlignment.html +++ b/doc/Axlsx/CellAlignment.html @@ -1238,7 +1238,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/CellProtection.html b/doc/Axlsx/CellProtection.html index 9088a55b..267d5865 100644 --- a/doc/Axlsx/CellProtection.html +++ b/doc/Axlsx/CellProtection.html @@ -556,7 +556,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/CellStyle.html b/doc/Axlsx/CellStyle.html index a8769cbe..26d4d512 100644 --- a/doc/Axlsx/CellStyle.html +++ b/doc/Axlsx/CellStyle.html @@ -940,7 +940,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Chart.html b/doc/Axlsx/Chart.html index 2f1a6465..6665f8a0 100644 --- a/doc/Axlsx/Chart.html +++ b/doc/Axlsx/Chart.html @@ -114,6 +114,13 @@ A Chart is the superclass for specific charts
    +

    See Also:

    +
      + +
    • for examples
    • + +
    +

    Direct Known Subclasses

    Bar3DChart, Line3DChart, Pie3DChart

    @@ -126,14 +133,14 @@ A Chart is the superclass for specific charts
  • - - (Marker) end_at + - (GraphicFrame) graphic_frame - + readonly @@ -143,7 +150,7 @@ A Chart is the superclass for specific charts

    -The ending marker for this chart. +A reference to the graphic frame that owns this chart.

    @@ -153,7 +160,7 @@ The ending marker for this chart.
  • - - (GraphicFrame) graphic_frame + - (Integer) index @@ -170,7 +177,7 @@ The ending marker for this chart.

    -A reference to the graphic frame that owns this chart. +The index of this chart in the workbooks charts collection.

    @@ -180,7 +187,7 @@ A reference to the graphic frame that owns this chart.
  • - - (Integer) index + - (String) pn @@ -197,7 +204,7 @@ A reference to the graphic frame that owns this chart.

    -The index of this chart in the workbooks charts collection. +The part name for this chart.

    @@ -207,7 +214,7 @@ The index of this chart in the workbooks charts collection.
  • - - (String) pn + - (SimpleTypedList) series @@ -224,7 +231,7 @@ The index of this chart in the workbooks charts collection.

    -The part name for this chart. +A collection of series objects that are applied to the chart.

    @@ -234,7 +241,7 @@ The part name for this chart.
  • - - (SimpleTypedList) series + - (Series) series_type @@ -251,7 +258,7 @@ The part name for this chart.

    -A collection of series objects that are applied to the chart. +The type of series to use for this chart.

    @@ -261,14 +268,14 @@ A collection of series objects that are applied to the chart.
  • - - (Series) series_type + - (Boolean) show_legend - readonly + @@ -278,7 +285,7 @@ A collection of series objects that are applied to the chart.

    -The type of series to use for this chart. +Show the legend in the chart.

    @@ -288,7 +295,7 @@ The type of series to use for this chart.
  • - - (Boolean) show_legend + - (Integer) style @@ -305,7 +312,7 @@ The type of series to use for this chart.

    -Show the legend in the chart. +The style for the chart.

    @@ -315,7 +322,7 @@ Show the legend in the chart.
  • - - (Marker) start_at + - (Title) title @@ -332,7 +339,7 @@ Show the legend in the chart.

    -The starting marker for this chart. +The title object for the chart.

    @@ -342,7 +349,7 @@ The starting marker for this chart.
  • - - (Integer) style + - (Object) view3D @@ -359,26 +366,36 @@ The starting marker for this chart.

    -The style for the chart. +The 3D view properties for the chart.

  • -
  • + + + + + + +

    + Instance Method Summary + (collapse) +

    + + - - + + + + constructor + + + + + + -

    - Instance Method Summary - (collapse) -

    +

    +Creates a new chart object. +

    +
    + +
  • -
    • - - (Series) add_series(options = {}) + - (Marker) start_at(x, y) @@ -450,7 +503,9 @@ The 3D view properties for the chart.

      -Adds a new series to the chart’s series collection. +This is a short cut method to set the start anchor position If you need +finer granularity in positioning use graphic_frame.anchor.from.colOff / +rowOff.

      @@ -460,14 +515,12 @@ Adds a new series to the chart’s series collection.
    • - - (Chart) initialize(frame, options = {}) {|_self| ... } + - (Object) to - constructor - @@ -476,7 +529,8 @@ Adds a new series to the chart’s series collection.

      -Creates a new chart object. +backwards compatibility to allow chart.to and chart.from access to anchor +markers.

      @@ -641,6 +695,12 @@ the object that the method was called on
       
       
      +52
      +53
      +54
      +55
      +56
      +57
       58
       59
       60
      @@ -648,14 +708,10 @@ the object that the method was called on
       62
       63
       64
      -65
      -66
      -67
      -68
      -69
      +65
    -
    # File 'lib/axlsx/drawing/chart.rb', line 58
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 52
     
     def initialize(frame, options={})
       @style = 2
    @@ -667,6 +723,8 @@ the object that the method was called on
       options.each do |o|
         self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
       end
    +  start_at *options[:start_at] if options[:start_at]
    +  end_at *options[:end_at] if options[:start_at]
       yield self if block_given?
     end
     
    @@ -681,67 +739,10 @@ the object that the method was called on

    Instance Attribute Details

    - - -
    -

    - - - (Marker) end_at - - - -

    -
    -

    -The ending marker for this chart -

    - - -
    -
    -
    - -

    Returns:

    -
      - -
    • - - - (Marker) - - - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -48
    -49
    -50
    -
    -
    # File 'lib/axlsx/drawing/chart.rb', line 48
    -
    -def end_at
    -  @end_at
    -end
    -
    -
    -
    - - -
    -

    +

    +

    - (GraphicFrame) graphic_frame (readonly) @@ -778,12 +779,12 @@ A reference to the graphic frame that owns this chart

     
     
    -21
    -22
    -23
    +14 +15 +16
    -
    # File 'lib/axlsx/drawing/chart.rb', line 21
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 14
     
     def graphic_frame
       @graphic_frame
    @@ -835,12 +836,12 @@ The index of this chart in the workbooks charts collection
           
     
     
    -33
    -34
    -35
    +26 +27 +28
    -
    # File 'lib/axlsx/drawing/chart.rb', line 33
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 26
     
     def index
       @graphic_frame.anchor.drawing.worksheet.workbook.charts.index(self)
    @@ -892,12 +893,12 @@ The part name for this chart
           
     
     
    -37
    -38
    -39
    +30 +31 +32
    -
    # File 'lib/axlsx/drawing/chart.rb', line 37
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 30
     
     def pn
       "#{CHART_PN % (index+1)}"
    @@ -949,12 +950,12 @@ A collection of series objects that are applied to the chart
           
     
     
    -25
    -26
    -27
    +18 +19 +20
    -
    # File 'lib/axlsx/drawing/chart.rb', line 25
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 18
     
     def series
       @series
    @@ -978,7 +979,7 @@ A collection of series objects that are applied to the chart
     

    -The type of series to use for this chart +The type of series to use for this chart.

    @@ -1006,12 +1007,12 @@ The type of series to use for this chart
     
     
    -29
    -30
    -31
    +22 +23 +24
    -
    # File 'lib/axlsx/drawing/chart.rb', line 29
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 22
     
     def series_type
       @series_type
    @@ -1063,12 +1064,12 @@ Show the legend in the chart
           
     
     
    -52
    -53
    -54
    +46 +47 +48
    -
    # File 'lib/axlsx/drawing/chart.rb', line 52
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 46
     
     def show_legend
       @show_legend
    @@ -1080,19 +1081,19 @@ Show the legend in the chart
     
         
           
    -      
    -      
    +      
    +      
           
    -

    +

    - - (Marker) start_at + - (Integer) style

    -The starting marker for this chart +The style for the chart. see ECMA Part 1 §21.2.2.196

    @@ -1106,7 +1107,7 @@ The starting marker for this chart
  • - (Marker) + (Integer) @@ -1120,15 +1121,15 @@ The starting marker for this chart
     
     
    -44
    -45
    -46
    +42 +43 +44
  • -
    # File 'lib/axlsx/drawing/chart.rb', line 44
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 42
     
    -def start_at
    -  @start_at
    +def style
    +  @style
     end
     
    -
    # File 'lib/axlsx/drawing/chart.rb', line 14
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 37
     
    -def style
    -  @style
    +def title
    +  @title
     end
     
    + + + + +
    +
    +
    +
    +10
    +11
    +12
    +
    +
    # File 'lib/axlsx/drawing/chart.rb', line 10
    +
    +def view3D
    +  @view3D
    +end
    +
    +
    + + + + + +
    +

    Instance Method Details

    + + +
    +

    + + - (Series) add_series(options = {}) + + + +

    +
    +

    +Adds a new series to the chart’s series collection.

    @@ -1220,7 +1269,7 @@ The title object for the chart.
  • - (Title) + (Series) @@ -1228,21 +1277,30 @@ The title object for the chart. +

    See Also:

    + +
  • @@ -1250,27 +1308,76 @@ The title object for the chart.
     
     
    -9
    -10
    -11
    +101 +102 +103 +104
    -
    # File 'lib/axlsx/drawing/chart.rb', line 9
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 101
     
    -def title
    -  @title
    +def add_series(options={})
    +  @series_type.new(self, options)
    +  @series.last
     end
     
    - - -
    -

    +

    - - (Object) view3D + - (Marker) end_at(x, y)

    -The 3D view properties for the chart +This is a short cut method to set the end anchor position If you need finer +granularity in positioning use graphic_frame.anchor.to.colOff / rowOff

    +

    Parameters:

    +
      + +
    • + + x + + + (Integer) + + + + — +

      +The column +

      +
      + +
    • + +
    • + + y + + + (Integer) + + + + — +

      +The row +

      +
      + +
    • +
    + +

    Returns:

    +
      + +
    • + + + (Marker) + + + +
    • + +
    @@ -1278,15 +1385,17 @@ The 3D view properties for the chart
     
     
    -17
    -18
    -19
    +149 +150 +151 +152 @@ -1294,38 +1403,122 @@ The 3D view properties for the chart
    -
    # File 'lib/axlsx/drawing/chart.rb', line 17
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 149
     
    -def view3D
    -  @view3D
    +def end_at(x, y)
    +  @graphic_frame.anchor.to.col = x
    +  @graphic_frame.anchor.to.row = y
     end
     
    +
    +

    + + - (Object) from + + + +

    +
    + +
    + Note: +

    +This will be disconinued in version 2.0.0. please use the start_at method +

    +
    +

    +backwards compatibility to allow chart.to and chart.from access to anchor +markers +

    -
    -

    Instance Method Details

    - + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +94
    +95
    +96
    +
    +
    # File 'lib/axlsx/drawing/chart.rb', line 94
    +
    +def from
    +  @graphic_frame.anchor.from
    +end
    +
    +
    +
    -
    -

    +

    +

    - - (Series) add_series(options = {}) + - (Marker) start_at(x, y)

    -Adds a new series to the chart’s series collection. +This is a short cut method to set the start anchor position If you need +finer granularity in positioning use graphic_frame.anchor.from.colOff / +rowOff

    +

    Parameters:

    +
      +
    • + + x + + + (Integer) + + + + — +

      +The column +

      +
      + +
    • + +
    • + + y + + + (Integer) + + + + — +

      +The row +

      +
      + +
    • + +
    +

    Returns:

    • - (Series) + (Marker) @@ -1333,12 +1526,58 @@ Adds a new series to the chart’s series collection.
    -

    See Also:

    -
      +
    + + + + +
    +
    +
    +
    +138
    +139
    +140
    +141
    +
    +
    # File 'lib/axlsx/drawing/chart.rb', line 138
    +
    +def start_at(x, y)
    +  @graphic_frame.anchor.from.col = x
    +  @graphic_frame.anchor.from.row = y
    +end
    +
    +
    +
    -
  • Series
  • +
    +

    + + - (Object) to + + + +

    +
    - +
    + Note: +

    +This will be disconinued in version 2.0.0. Please use the end_at method +

    +
    +
    + +

    +backwards compatibility to allow chart.to and chart.from access to anchor +markers +

    + + +
    +
    +
    +
    @@ -1346,17 +1585,15 @@ Adds a new series to the chart’s series collection.
     
     
    -94
    -95
    -96
    -97
    +87 +88 +89 @@ -1389,13 +1626,6 @@ Chart Serialization serializes the chart
     
     
    -101
    -102
    -103
    -104
    -105
    -106
    -107
     108
     109
     110
    @@ -1411,10 +1641,17 @@ Chart Serialization serializes the chart
     120
     121
     122
    -123
    +123 +124 +125 +126 +127 +128 +129 +130
    -
    # File 'lib/axlsx/drawing/chart.rb', line 94
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 87
     
    -def add_series(options={})
    -  @series_type.new(self, options)
    -  @series.last
    +def to
    +  @graphic_frame.anchor.to
     end
     
    -
    # File 'lib/axlsx/drawing/chart.rb', line 101
    +      
    # File 'lib/axlsx/drawing/chart.rb', line 108
     
     def to_xml
       builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
    @@ -1450,7 +1687,7 @@ Chart Serialization serializes the chart
     
         
         
    diff --git a/doc/Axlsx/Color.html b/doc/Axlsx/Color.html
    index e856e81f..e1479faf 100644
    --- a/doc/Axlsx/Color.html
    +++ b/doc/Axlsx/Color.html
    @@ -656,7 +656,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/ContentType.html b/doc/Axlsx/ContentType.html
    index 293926d4..21d7c70d 100644
    --- a/doc/Axlsx/ContentType.html
    +++ b/doc/Axlsx/ContentType.html
    @@ -194,7 +194,7 @@ Generates the xml document for [Content_Types].xml.
       
       
       

    Methods inherited from SimpleTypedList

    -

    #<<, #[]=, #delete, #delete_at, #lock, #method_missing, #protected?, #push, #unlock

    +

    #<<, #==, #[]=, #delete, #delete_at, #lock, #method_missing, #protected?, #push, #unlock

    Constructor Details

    @@ -331,7 +331,7 @@ The document as a string.
    diff --git a/doc/Axlsx/Core.html b/doc/Axlsx/Core.html index 1271d383..ed241c2b 100644 --- a/doc/Axlsx/Core.html +++ b/doc/Axlsx/Core.html @@ -456,7 +456,7 @@ time when this method is called. diff --git a/doc/Axlsx/DataTypeValidator.html b/doc/Axlsx/DataTypeValidator.html index dedc619a..6f2f98ac 100644 --- a/doc/Axlsx/DataTypeValidator.html +++ b/doc/Axlsx/DataTypeValidator.html @@ -315,7 +315,7 @@ types or the block passed returns false diff --git a/doc/Axlsx/Default.html b/doc/Axlsx/Default.html index 27bf8b21..b53c8ea5 100644 --- a/doc/Axlsx/Default.html +++ b/doc/Axlsx/Default.html @@ -566,7 +566,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Drawing.html b/doc/Axlsx/Drawing.html index 82b6dd0a..1d2bce32 100644 --- a/doc/Axlsx/Drawing.html +++ b/doc/Axlsx/Drawing.html @@ -99,14 +99,16 @@ Note:

    The recommended way to manage drawings is to use the Worksheet.add_chart -method, specifying the chart class, start and end marker locations. +method.

    A Drawing is a canvas for charts. Each worksheet has a single drawing that -can specify multiple anchors which reference charts. +manages anchors. The anchors reference the charts via graphical frames. +This is not a trivial relationship so please do follow the advice in the +note. see README for an example of how to create a chart.

    @@ -120,8 +122,6 @@ can specify multiple anchors which reference charts.
  • Worksheet#add_chart
  • -
  • TwoCellAnchor
  • -
  • Chart
  • @@ -151,7 +151,8 @@ can specify multiple anchors which reference charts.

    -A collection of anchors for this drawing. +A collection of anchors for this drawing only TwoCellAnchors are supported +in this version.

    @@ -487,15 +488,15 @@ The worksheet that owns this drawing
     
     
    -67
    -68
    -69
    -70
     71
    -72
    +72 +73 +74 +75 +76
    -
    # File 'lib/axlsx/drawing/drawing.rb', line 67
    +      
    # File 'lib/axlsx/drawing/drawing.rb', line 71
     
     def initialize(worksheet)
       DataTypeValidator.validate "Drawing.worksheet", Worksheet, worksheet
    @@ -527,7 +528,8 @@ The worksheet that owns this drawing
     

    -A collection of anchors for this drawing +A collection of anchors for this drawing only TwoCellAnchors are supported +in this version

    @@ -555,12 +557,12 @@ A collection of anchors for this drawing
     
     
    -39
    -40
    -41
    +43 +44 +45
    -
    # File 'lib/axlsx/drawing/drawing.rb', line 39
    +      
    # File 'lib/axlsx/drawing/drawing.rb', line 43
     
     def anchors
       @anchors
    @@ -612,12 +614,12 @@ An array of charts that are associated with this drawing’s anchors
           
     
     
    -43
    -44
    -45
    +47 +48 +49
    -
    # File 'lib/axlsx/drawing/drawing.rb', line 43
    +      
    # File 'lib/axlsx/drawing/drawing.rb', line 47
     
     def charts
       @anchors.map { |a| a.graphic_frame.chart }
    @@ -670,12 +672,12 @@ collection.
           
     
     
    -47
    -48
    -49
    +51 +52 +53
    -
    # File 'lib/axlsx/drawing/drawing.rb', line 47
    +      
    # File 'lib/axlsx/drawing/drawing.rb', line 51
     
     def index
       @worksheet.workbook.drawings.index(self)
    @@ -727,12 +729,12 @@ The part name for this drawing
           
     
     
    -55
    -56
    -57
    +59 +60 +61
    -
    # File 'lib/axlsx/drawing/drawing.rb', line 55
    +      
    # File 'lib/axlsx/drawing/drawing.rb', line 59
     
     def pn
       "#{DRAWING_PN % (index+1)}"
    @@ -784,17 +786,17 @@ The drawing’s relationships.
           
     
     
    -63
    -64
    -65
    -66
     67
     68
     69
    -70
    +70 +71 +72 +73 +74
    -
    # File 'lib/axlsx/drawing/drawing.rb', line 63
    +      
    # File 'lib/axlsx/drawing/drawing.rb', line 67
     
     def relationships
       r = Relationships.new
    @@ -851,12 +853,12 @@ The relational part name for this drawing
           
     
     
    -59
    -60
    -61
    +63 +64 +65
    -
    # File 'lib/axlsx/drawing/drawing.rb', line 59
    +      
    # File 'lib/axlsx/drawing/drawing.rb', line 63
     
     def rels_pn
       "#{DRAWING_RELS_PN % (index+1)}"
    @@ -908,12 +910,12 @@ The relation reference id for this drawing
           
     
     
    -51
    -52
    -53
    +55 +56 +57
    -
    # File 'lib/axlsx/drawing/drawing.rb', line 51
    +      
    # File 'lib/axlsx/drawing/drawing.rb', line 55
     
     def rId
       "rId#{index+1}"
    @@ -965,12 +967,12 @@ The worksheet that owns the drawing
           
     
     
    -34
    -35
    -36
    +38 +39 +40
    -
    # File 'lib/axlsx/drawing/drawing.rb', line 34
    +      
    # File 'lib/axlsx/drawing/drawing.rb', line 38
     
     def worksheet
       @worksheet
    @@ -1001,7 +1003,8 @@ The worksheet that owns the drawing
       
    Note:

    -The recommended way to manage charts is to use Worksheet.add_chart. +The recommended way to manage charts is to use Worksheet.add_chart. Please +refer to that method for documentation.

    @@ -1014,41 +1017,14 @@ Adds a chart to the drawing.
    -

    Parameters:

    -
      -
    • - - chart_type - - - (Chart) - - - - — -

      -The class of the chart to be added to the drawing -

      -
      - -
    • - -
    • - - options - - - (Hash) - - - (defaults to: {}) - - -
    • - -
    +

    See Also:

    +
    @@ -1056,17 +1032,15 @@ The class of the chart to be added to the drawing
     
     
    -79
    -80
    -81
     82
    -83
    +83 +84 +85
    -
    # File 'lib/axlsx/drawing/drawing.rb', line 79
    +      
    # File 'lib/axlsx/drawing/drawing.rb', line 82
     
     def add_chart(chart_type, options={})
    -  DataTypeValidator.validate "Drawing.chart_type", Chart, chart_type 
       TwoCellAnchor.new(self, chart_type, options)
       @anchors.last.graphic_frame.chart
     end
    @@ -1114,17 +1088,17 @@ Serializes the drawing
           
     
     
    -116
    -117
     118
     119
     120
     121
     122
    -123
    +123 +124 +125
    -
    # File 'lib/axlsx/drawing/drawing.rb', line 116
    +      
    # File 'lib/axlsx/drawing/drawing.rb', line 118
     
     def to_xml
       builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
    @@ -1145,7 +1119,7 @@ Serializes the drawing
     
         
         
    diff --git a/doc/Axlsx/Fill.html b/doc/Axlsx/Fill.html
    index da35b662..f5c9b6fa 100644
    --- a/doc/Axlsx/Fill.html
    +++ b/doc/Axlsx/Fill.html
    @@ -451,7 +451,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/Font.html b/doc/Axlsx/Font.html
    index ee723a16..0091cf69 100644
    --- a/doc/Axlsx/Font.html
    +++ b/doc/Axlsx/Font.html
    @@ -1545,7 +1545,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/GradientFill.html b/doc/Axlsx/GradientFill.html
    index 7fa542ec..7cb1494f 100644
    --- a/doc/Axlsx/GradientFill.html
    +++ b/doc/Axlsx/GradientFill.html
    @@ -1017,7 +1017,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/GradientStop.html b/doc/Axlsx/GradientStop.html
    index 6f5ca4d4..89bc1e26 100644
    --- a/doc/Axlsx/GradientStop.html
    +++ b/doc/Axlsx/GradientStop.html
    @@ -517,7 +517,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/GraphicFrame.html b/doc/Axlsx/GraphicFrame.html
    index f7e91018..0c328ab9 100644
    --- a/doc/Axlsx/GraphicFrame.html
    +++ b/doc/Axlsx/GraphicFrame.html
    @@ -329,12 +329,14 @@ Creates a new GraphicFrame object
     24
     25
     26
    -27
    +27 +28
    # File 'lib/axlsx/drawing/graphic_frame.rb', line 24
     
     def initialize(anchor, chart_type, options)
    +  DataTypeValidator.validate "Drawing.chart_type", Chart, chart_type 
       @anchor = anchor
       @chart = chart_type.new(self, options)
     end
    @@ -586,7 +588,6 @@ The document builder instance this objects xml will be added to.
           
     
     
    -36
     37
     38
     39
    @@ -603,10 +604,11 @@ The document builder instance this objects xml will be added to.
     50
     51
     52
    -53
    +53 +54
    -
    # File 'lib/axlsx/drawing/graphic_frame.rb', line 36
    +      
    # File 'lib/axlsx/drawing/graphic_frame.rb', line 37
     
     def to_xml(xml)
       xml.send('xdr:graphicFrame') {        
    @@ -637,7 +639,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/Line3DChart.html b/doc/Axlsx/Line3DChart.html
    index 589a6d54..3512d2a7 100644
    --- a/doc/Axlsx/Line3DChart.html
    +++ b/doc/Axlsx/Line3DChart.html
    @@ -323,7 +323,7 @@ the category axis.
       
       
       

    Attributes inherited from Chart

    -

    end_at, graphic_frame, index, pn, series, series_type, show_legend, start_at, style, title, view3D

    +

    graphic_frame, index, pn, series, series_type, show_legend, style, title, view3D

    @@ -396,7 +396,7 @@ Serializes the bar chart.

    Methods inherited from Chart

    -

    #add_series

    +

    #add_series, #end_at, #from, #start_at, #to

    Constructor Details

    @@ -466,6 +466,24 @@ a customizable set of options

    Options Hash (options):

      +
    • + title + (Cell, String) + + + + +
    • + +
    • + show_legend + (Boolean) + + + + +
    • +
    • grouping (Symbol) @@ -484,31 +502,94 @@ a customizable set of options
    • +
    • + rotX + (Integer) + + + + +
    • + +
    • + hPercent + (String) + + + + +
    • + +
    • + rotY + (Integer) + + + + +
    • + +
    • + depthPercent + (String) + + + + +
    • + +
    • + rAngAx + (Boolean) + + + + +
    • + +
    • + perspective + (Integer) + + + + +
    • +
    +

    See Also:

    + +
    @@ -865,25 +946,25 @@ Serializes the bar chart
     
     
    -76
    -77
    -78
    -79
    -80
    -81
    -82
    -83
    -84
    -85
     86
     87
     88
     89
     90
    -91
    +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 @@ -388,7 +389,7 @@ a customizable set of options

    - - (Array, SimpleTypedList) data + - (ValAxisData) data @@ -409,7 +410,7 @@ The data for this series.

  • - (Array, SimpleTypedList) + (ValAxisData) @@ -445,7 +446,7 @@ The data for this series.

    - - (Array, SimpleTypedList) labels + - (CatAxisData) labels @@ -466,7 +467,7 @@ The labels for this series.

  • - (Array, SimpleTypedList) + (CatAxisData) @@ -513,7 +514,8 @@ The labels for this series.

    -Serializes the series +Serializes the series TODO create series_cat and series_val classes as this +serialization is duplicated

    @@ -562,78 +564,20 @@ The document builder instance this objects xml will be added to.
     
     
    -29
     30
     31
     32
     33
     34
    -35
    -36
    -37
    -38
    -39
    -40
    -41
    -42
    -43
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    -51
    -52
    -53
    -54
    -55
    -56
    -57
    -58
    -59
    -60
    -61
    -62
    -63
    +35
  •  
     
    -51
    -52
    -53
    -54
    -55
    -56
    -57
    -58
    -59
    -60
     61
    -62
    +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72
    -
    # File 'lib/axlsx/drawing/line_3D_chart.rb', line 51
    +      
    # File 'lib/axlsx/drawing/line_3D_chart.rb', line 61
     
     def initialize(frame, options={})
       @grouping = :standard
    @@ -518,9 +599,9 @@ a customizable set of options
       @catAxis = CatAxis.new(@catAxId, @valAxId)
       @valAxis = ValAxis.new(@valAxId, @catAxId)
       @serAxis = SerAxis.new(@serAxId, @valAxId)
    -  @view3D = View3D.new(:perspective=>30)
       super(frame, options)      
       @series_type = LineSeries
    +  @view3D = View3D.new({:perspective=>30}.merge(options))
     end
     
    -
    # File 'lib/axlsx/drawing/line_3D_chart.rb', line 76
    +      
    # File 'lib/axlsx/drawing/line_3D_chart.rb', line 86
     
     def to_xml
       super() do |xml|
    @@ -912,7 +993,7 @@ Serializes the bar chart
     
         
         
    diff --git a/doc/Axlsx/LineSeries.html b/doc/Axlsx/LineSeries.html
    index f6d997da..b1b59a0b 100644
    --- a/doc/Axlsx/LineSeries.html
    +++ b/doc/Axlsx/LineSeries.html
    @@ -136,7 +136,7 @@ A LineSeries defines the title, data and labels for line charts
           
  • - - (Array, SimpleTypedList) data + - (ValAxisData) data @@ -163,7 +163,7 @@ The data for this series.
  • - - (Array, SimpleTypedList) labels + - (CatAxisData) labels @@ -251,7 +251,8 @@ Creates a new series.

    -Serializes the series. +Serializes the series TODO create series_cat and series_val classes as this +serialization is duplicated.

    @@ -368,8 +369,8 @@ a customizable set of options def initialize(chart, options={}) super(chart, options) - self.data = options[:data] || [] - self.labels = options[:labels] || [] + self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil? + self.data = ValAxisData.new(options[:data]) unless options[:data].nil? end
  • -
    # File 'lib/axlsx/drawing/line_series.rb', line 29
    +      
    # File 'lib/axlsx/drawing/line_series.rb', line 30
     
     def to_xml(xml)
       super(xml) do |xml|
    -    if !labels.empty?
    -      xml.send('c:cat') {
    -        xml.send('c:strRef') {
    -          xml.send('c:f', Axlsx::cell_range(labels))
    -          xml.send('c:strCache') {
    -            xml.send('c:ptCount', :val=>labels.size)
    -            labels.each_with_index do |cell, index|
    -              v = cell.is_a?(Cell) ? cell.value : cell
    -              xml.send('c:pt', :idx=>index) {
    -                xml.send('c:v', v)
    -              }                          
    -            end
    -          }
    -        }
    -      }
    -    end
    -    xml.send('c:val') {
    -      xml.send('c:numRef') {
    -        xml.send('c:f', Axlsx::cell_range(data))
    -        xml.send('c:numCache') {
    -          xml.send('c:formatCode', 'General')
    -          xml.send('c:ptCount', :val=>data.size)
    -          data.each_with_index do |cell, index|
    -            v = cell.is_a?(Cell) ? cell.value : cell
    -            xml.send('c:pt', :idx=>index) {
    -              xml.send('c:v', v) 
    -            }
    -          end
    -        }                        
    -      }
    -    }
    +    @labels.to_xml(xml) unless @labels.nil?
    +    @data.to_xml(xml) unless @data.nil?
       end      
     end
     
    @@ -647,7 +591,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Marker.html b/doc/Axlsx/Marker.html index 3a5e0864..a35500f7 100644 --- a/doc/Axlsx/Marker.html +++ b/doc/Axlsx/Marker.html @@ -848,7 +848,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/NumFmt.html b/doc/Axlsx/NumFmt.html index b530f49a..2fe65d34 100644 --- a/doc/Axlsx/NumFmt.html +++ b/doc/Axlsx/NumFmt.html @@ -553,7 +553,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Override.html b/doc/Axlsx/Override.html index 0eeec0b6..2157fc29 100644 --- a/doc/Axlsx/Override.html +++ b/doc/Axlsx/Override.html @@ -559,7 +559,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Package.html b/doc/Axlsx/Package.html index a8875b81..dccd861b 100644 --- a/doc/Axlsx/Package.html +++ b/doc/Axlsx/Package.html @@ -1284,7 +1284,7 @@ An array of all validation errors encountered. diff --git a/doc/Axlsx/PatternFill.html b/doc/Axlsx/PatternFill.html index 00371bc9..22009d77 100644 --- a/doc/Axlsx/PatternFill.html +++ b/doc/Axlsx/PatternFill.html @@ -672,7 +672,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Pie3DChart.html b/doc/Axlsx/Pie3DChart.html index f34d11e8..668d4797 100644 --- a/doc/Axlsx/Pie3DChart.html +++ b/doc/Axlsx/Pie3DChart.html @@ -106,53 +106,15 @@ that you can add to your worksheet.
    -
    -

    Examples:

    - -

    -Creating a chart -

    -

    -
    # This example creates two charts in a single sheet.
    -# The first uses data directly fed to the sheet, while the second references cells withing the worksheet for data.
    -
    -require "rubygems" # if that is your preferred way to manage gems!
    -require "axlsx"
    -
    -p = Axlsx::Package.new
    -ws = p.workbook.add_worksheet
    -ws.add_row :values => ["This is a chart with no data in the sheet"]
    -
    -chart = ws.add_chart(Axlsx::Pie3DChart, :start_at=> [0,1], :end_at=>[0,6], :title=>"Most Popular Pets")
    -chart.add_series :data => [1, 9, 10], :labels => ["Slimy Reptiles", "Fuzzy Bunnies", "Rottweiler"]
    -
    -ws.add_row :values => ["This chart uses the data below"]
    -title_row = ws.add_row :values => ["Least Popular Pets"]
    -label_row = ws.add_row :values => ["", "Dry Skinned Reptiles", "Bald Cats", "Violent Parrots"]
    -data_row = ws.add_row :values => ["Votes", 6, 4, 1]
    -
    -chart = ws.add_chart(Axlsx::Pie3DChart, :start_at => [0,11], :end_at =>[0,16], :title => title_row.cells.last)
    -chart.add_series :data => data_row.cells[(1..-1)], :labels => label_row.cells  
    -
    -f = File.open('example_pie_3d_chart.xlsx', 'w')
    -p.serialize(f)
    -
    - -
    -

    See Also:

    @@ -170,7 +132,7 @@ Creating a chart

    Instance Attribute Summary

    Attributes inherited from Chart

    -

    end_at, graphic_frame, index, pn, series, series_type, show_legend, start_at, style, title, view3D

    +

    graphic_frame, index, pn, series, series_type, show_legend, style, title, view3D

    @@ -184,7 +146,7 @@ Creating a chart
  • - - (Pie3DChart) initialize(workbook, options = {}) + - (Pie3DChart) initialize(frame, options = {}) @@ -243,14 +205,14 @@ Serializes the pie chart.

    Methods inherited from Chart

    -

    #add_series

    +

    #add_series, #end_at, #from, #start_at, #to

    Constructor Details

    - - (Pie3DChart) initialize(workbook, options = {}) + - (Pie3DChart) initialize(frame, options = {}) @@ -269,10 +231,10 @@ Creates a new pie chart object

  • - workbook + frame - (Workbook) + (GraphicFrame) @@ -322,31 +284,121 @@ a customizable set of options
  • +
  • + show_legend + (Boolean) + + + + +
  • + +
  • + grouping + (Symbol) + + + + +
  • + +
  • + gapDepth + (String) + + + + +
  • + +
  • + rotX + (Integer) + + + + +
  • + +
  • + hPercent + (String) + + + + +
  • + +
  • + rotY + (Integer) + + + + +
  • + +
  • + depthPercent + (String) + + + + +
  • + +
  • + rAngAx + (Boolean) + + + + +
  • + +
  • + perspective + (Integer) + + + + +
  • + +

    See Also:

    + +
    @@ -399,17 +451,17 @@ Serializes the pie chart
     
     
    -50
    -51
    -52
    -53
    -54
    -55
    -56
    -57
    +33 +34 +35 +36 +37 +38 +39 +40 @@ -433,7 +434,7 @@ a customizable set of options

    - - (Array, SimpleTypedList) data + - (SimpleTypedList) data @@ -454,7 +455,7 @@ The data for this series.

  • - (Array, SimpleTypedList) + (SimpleTypedList) @@ -490,7 +491,7 @@ The data for this series.

    - - (Array, SimpleTypedList) explosion + - (Integert) explosion @@ -511,7 +512,7 @@ The explosion for this series

  • - (Array, SimpleTypedList) + (Integert) @@ -525,12 +526,12 @@ The explosion for this series
     
     
    -20
    -21
    -22
    +18 +19 +20
  • @@ -418,13 +427,16 @@ a customizable set of options

    - - (Boolean) tickLblSkip + - (Integer) tickLblSkip

    - +

    +The number of tick lables to skip between labels +

    +
    @@ -436,7 +448,7 @@ a customizable set of options
  • - (Boolean) + (Integer) @@ -450,12 +462,12 @@ a customizable set of options
     
     
    -6
     7
    -8
    +8 +9
  • @@ -815,199 +767,7 @@ A marker that returns the to cell anchor. The default to column and row are
    -

    - - - (Marker) end_at(x, y) - - - -

    -
    -

    -This is a short cut method to set the end anchor position -

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - x - - - (Integer) - - - - — -

      -The column -

      -
      - -
    • - -
    • - - y - - - (Integer) - - - - — -

      -The row -

      -
      - -
    • - -
    - -

    Returns:

    -
      - -
    • - - - (Marker) - - - -
    • - -
    - -
     
     
    -41
    -42
    -43
    -44
    -45
    -46
    +24 +25 +26 +27 +28 +29
    -
    # File 'lib/axlsx/drawing/pie_3D_chart.rb', line 41
    +      
    # File 'lib/axlsx/drawing/pie_3D_chart.rb', line 24
     
    -def initialize(workbook, options={})
    -  # this charts series type
    -  super(workbook, options)
    +def initialize(frame, options={})
    +  super(frame, options)
       @series_type = PieSeries
    -  @view3D = View3D.new(:rotX => 30, :perspective => 30)
    +  @view3D = View3D.new({:rotX=>30, :perspective=>30}.merge(options))
    +
     end
     
    -
    # File 'lib/axlsx/drawing/pie_3D_chart.rb', line 50
    +      
    # File 'lib/axlsx/drawing/pie_3D_chart.rb', line 33
     
     def to_xml
       super() do |xml|
    @@ -430,7 +482,7 @@ Serializes the pie chart
     
         
         
    diff --git a/doc/Axlsx/PieSeries.html b/doc/Axlsx/PieSeries.html
    index 7e5d747b..07ca6f75 100644
    --- a/doc/Axlsx/PieSeries.html
    +++ b/doc/Axlsx/PieSeries.html
    @@ -106,7 +106,8 @@ The recommended way to manage series is to use Chart#add_series
       
     
     

    -A PieSeries defines the title, data and labels for pie charts +A PieSeries defines the data and labels and explosion for pie charts +series.

    @@ -136,7 +137,7 @@ A PieSeries defines the title, data and labels for pie charts
  • - - (Array, SimpleTypedList) data + - (SimpleTypedList) data @@ -163,7 +164,7 @@ The data for this series.
  • - - (Array, SimpleTypedList) explosion + - (Integert) explosion @@ -190,7 +191,7 @@ The explosion for this series.
  • - - (Array, SimpleTypedList) labels + - (SimpleTypedList) labels @@ -402,19 +403,19 @@ a customizable set of options
     
     
    +26
    +27
     28
     29
    -30
    -31
    -32
    +30
  • -
    # File 'lib/axlsx/drawing/pie_series.rb', line 28
    +      
    # File 'lib/axlsx/drawing/pie_series.rb', line 26
     
     def initialize(chart, options={})
       super(chart, options)
    -  self.data = options[:data]  || []
    -  self.labels = options[:labels] || []
    +  self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil?
    +  self.data = ValAxisData.new(options[:data]) unless options[:data].nil?
     end
     
    -
    # File 'lib/axlsx/drawing/pie_series.rb', line 20
    +      
    # File 'lib/axlsx/drawing/pie_series.rb', line 18
     
     def explosion
       @explosion
    @@ -547,7 +548,7 @@ The explosion for this series
           

    - - (Array, SimpleTypedList) labels + - (SimpleTypedList) labels @@ -568,7 +569,7 @@ The labels for this series.

  • - (Array, SimpleTypedList) + (SimpleTypedList) @@ -582,12 +583,12 @@ The labels for this series.
     
     
    +14
     15
    -16
    -17
    +16
  • -
    # File 'lib/axlsx/drawing/pie_series.rb', line 15
    +      
    # File 'lib/axlsx/drawing/pie_series.rb', line 14
     
     def labels
       @labels
    @@ -664,82 +665,22 @@ The document builder instance this objects xml will be added to.
           
     
     
    +37
     38
     39
     40
     41
     42
    -43
    -44
    -45
    -46
    -47
    -48
    -49
    -50
    -51
    -52
    -53
    -54
    -55
    -56
    -57
    -58
    -59
    -60
    -61
    -62
    -63
    -64
    -65
    -66
    -67
    -68
    -69
    -70
    -71
    -72
    -73
    -74
    +43
    -
    # File 'lib/axlsx/drawing/pie_series.rb', line 38
    +      
    # File 'lib/axlsx/drawing/pie_series.rb', line 37
     
     def to_xml(xml)
       super(xml) do  |xml|
         xml.send('c:explosion', :val=>@explosion) unless @explosion.nil?
    -    if !labels.empty?
    -      xml.send('c:cat') {
    -        xml.send('c:strRef') {
    -          xml.send('c:f', Axlsx::cell_range(labels))
    -          xml.send('c:strCache') {
    -            xml.send('c:ptCount', :val=>labels.size)
    -            labels.each_with_index do |cell, index|
    -              v = cell.is_a?(Cell) ? cell.value : cell
    -              xml.send('c:pt', :idx=>index) {
    -                xml.send('c:v', v)
    -              }                          
    -            end
    -          }
    -        }
    -      }
    -    end
    -    xml.send('c:val') {
    -      xml.send('c:numRef') {
    -        xml.send('c:f', Axlsx::cell_range(data))
    -        xml.send('c:numCache') {
    -          xml.send('c:formatCode', 'General')
    -          xml.send('c:ptCount', :val=>data.size)
    -          data.each_with_index do |cell, index|
    -            v = cell.is_a?(Cell) ? cell.value : cell
    -            xml.send('c:pt', :idx=>index) {
    -              xml.send('c:v', v) 
    -            }
    -          end
    -        }                        
    -      }
    -    }
    -    
    +    @labels.to_xml(xml) unless @labels.nil?
    +    @data.to_xml(xml) unless @data.nil?
       end      
     end
     
    @@ -753,7 +694,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/RegexValidator.html b/doc/Axlsx/RegexValidator.html index c3ad45b1..f644c404 100644 --- a/doc/Axlsx/RegexValidator.html +++ b/doc/Axlsx/RegexValidator.html @@ -259,7 +259,7 @@ The value to validate. diff --git a/doc/Axlsx/Relationship.html b/doc/Axlsx/Relationship.html index 486b348c..f9786c69 100644 --- a/doc/Axlsx/Relationship.html +++ b/doc/Axlsx/Relationship.html @@ -545,7 +545,7 @@ the reference id of the object. diff --git a/doc/Axlsx/Relationships.html b/doc/Axlsx/Relationships.html index b1687dcb..95e4f3b3 100644 --- a/doc/Axlsx/Relationships.html +++ b/doc/Axlsx/Relationships.html @@ -203,7 +203,7 @@ Serializes the relationships document.

    Methods inherited from SimpleTypedList

    -

    #<<, #[]=, #delete, #delete_at, #lock, #method_missing, #protected?, #push, #unlock

    +

    #<<, #==, #[]=, #delete, #delete_at, #lock, #method_missing, #protected?, #push, #unlock

    Constructor Details

    @@ -334,7 +334,7 @@ Serializes the relationships document.
    diff --git a/doc/Axlsx/RestrictionValidator.html b/doc/Axlsx/RestrictionValidator.html index 1ea8d71f..dcb9402f 100644 --- a/doc/Axlsx/RestrictionValidator.html +++ b/doc/Axlsx/RestrictionValidator.html @@ -291,7 +291,7 @@ Raised if the value provided is not in the list of choices. diff --git a/doc/Axlsx/Row.html b/doc/Axlsx/Row.html index 2d7802f0..cd95e0ec 100644 --- a/doc/Axlsx/Row.html +++ b/doc/Axlsx/Row.html @@ -762,7 +762,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/Scaling.html b/doc/Axlsx/Scaling.html index 540ac273..341bd7d8 100644 --- a/doc/Axlsx/Scaling.html +++ b/doc/Axlsx/Scaling.html @@ -731,7 +731,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/SerAxis.html b/doc/Axlsx/SerAxis.html index 17fe2a43..e46afa7e 100644 --- a/doc/Axlsx/SerAxis.html +++ b/doc/Axlsx/SerAxis.html @@ -97,7 +97,7 @@

    Overview

    -A SarAxis object defines a series axis +A SerAxis object defines a series axis

    @@ -118,7 +118,7 @@ A SarAxis object defines a series axis
  • - - (Boolean) tickLblSkip + - (Integer) tickLblSkip @@ -134,7 +134,10 @@ A SarAxis object defines a series axis -
    +

    +The number of tick lables to skip between labels. +

    +
  • @@ -158,7 +161,10 @@ A SarAxis object defines a series axis -
    +

    +The number of tickmarks to be skipped before the next one is rendered. +

    +
    @@ -276,7 +282,7 @@ Creates a new SerAxis object —

    -the id of this axis +the id of this axis. Inherited

    @@ -293,7 +299,7 @@ the id of this axis —

    -the id of the perpendicular axis +the id of the perpendicular axis. Inherited

    @@ -331,35 +337,44 @@ a customizable set of options
    • - axPos + axPos. (Symbol) - + —

      +Inherited +

      +
    • - tickLblPos + tickLblPos. (Symbol) - + —

      +Inherited +

      +
    • - crosses + crosses. (Symbol) - + —

      +Inherited +

      +
    • tickLblSkip - (Boolean) + (Integer) @@ -368,7 +383,7 @@ a customizable set of options
    • tickMarkSkip - (Symbol) + (Integer) @@ -385,21 +400,15 @@ a customizable set of options
       
       
      -19
      -20
       21
       22
      -23
      -24
      +23
    -
    # File 'lib/axlsx/drawing/ser_axis.rb', line 19
    +      
    # File 'lib/axlsx/drawing/ser_axis.rb', line 21
     
     def initialize(axId, crossAx, options={})
       super(axId, crossAx, options)
    -  options.each do |o|
    -    self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}="
    -  end
     end
     
    -
    # File 'lib/axlsx/drawing/ser_axis.rb', line 6
    +      
    # File 'lib/axlsx/drawing/ser_axis.rb', line 7
     
     def tickLblSkip
       @tickLblSkip
    @@ -478,7 +490,10 @@ a customizable set of options
       
     

    - +

    +The number of tickmarks to be skipped before the next one is rendered. +

    +
    @@ -504,12 +519,12 @@ a customizable set of options
     
     
    -9
    -10
    -11
    +11 +12 +13
    -
    # File 'lib/axlsx/drawing/ser_axis.rb', line 9
    +      
    # File 'lib/axlsx/drawing/ser_axis.rb', line 11
     
     def tickMarkSkip
       @tickMarkSkip
    @@ -586,16 +601,16 @@ The document builder instance this objects xml will be added to.
           
     
     
    +31
     32
     33
     34
     35
     36
    -37
    -38
    +37
    -
    # File 'lib/axlsx/drawing/ser_axis.rb', line 32
    +      
    # File 'lib/axlsx/drawing/ser_axis.rb', line 31
     
     def to_xml(xml)
       xml.send('c:serAx') {
    @@ -615,7 +630,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/Series.html b/doc/Axlsx/Series.html
    index 668ede03..32106681 100644
    --- a/doc/Axlsx/Series.html
    +++ b/doc/Axlsx/Series.html
    @@ -104,7 +104,8 @@ The recommended way to manage series is to use Chart#add_series
       
     
     

    -A Series defines the title, data and labels for chart data. +A Series defines the common series attributes and is the super class for +all concrete series types.

    @@ -161,7 +162,7 @@ The chart that owns this series.
  • - - (Object) index + - (Integer) index @@ -178,7 +179,7 @@ The chart that owns this series.

    -retrieves the series index in the chart’s series collection. +The index of this series in the chart’s series.

    @@ -488,14 +489,14 @@ The chart that owns this series

    - - (Object) index (readonly) + - (Integer) index (readonly)

    -retrieves the series index in the chart’s series collection +The index of this series in the chart’s series.

    @@ -503,6 +504,19 @@ retrieves the series index in the chart’s series collection
    +

    Returns:

    +
      + +
    • + + + (Integer) + + + +
    • + +
    @@ -539,7 +553,8 @@ retrieves the series index in the chart’s series collection

    -The order of this series in the chart’s series. +The order of this series in the chart’s series. By default the order +is the index of the series.

    @@ -706,17 +721,17 @@ The document builder instance this objects xml will be added to.
     
     
    +60
     61
     62
     63
     64
     65
     66
    -67
    -68
    +67
    -
    # File 'lib/axlsx/drawing/series.rb', line 61
    +      
    # File 'lib/axlsx/drawing/series.rb', line 60
     
     def to_xml(xml)
       xml.send('c:ser') {
    @@ -737,7 +752,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/SeriesTitle.html b/doc/Axlsx/SeriesTitle.html
    index 8c6e2377..46224b97 100644
    --- a/doc/Axlsx/SeriesTitle.html
    +++ b/doc/Axlsx/SeriesTitle.html
    @@ -97,7 +97,8 @@
     

    Overview

    -A series title is a Title with a slightly different serialization +A series title is a Title with a slightly different serialization than +chart titles.

    @@ -280,7 +281,7 @@ The document builder instance this objects xml will be added to.
    diff --git a/doc/Axlsx/SimpleTypedList.html b/doc/Axlsx/SimpleTypedList.html index d28079f3..72ff9c07 100644 --- a/doc/Axlsx/SimpleTypedList.html +++ b/doc/Axlsx/SimpleTypedList.html @@ -107,7 +107,7 @@ methods from Array and supports basic xml serialization.
    @@ -231,6 +231,31 @@ Concat operator.

    + + + +
  • + + + - (Object) ==(v) + + + + + + + + + + + + +

    +override the equality method so that this object can be compared to a +simple array. +

    +
    +
  • @@ -643,7 +668,6 @@ the following methods are not allowed :drop_while :delete_if :clear - :concat
    @@ -677,23 +701,25 @@ method_mission override to pass allowed methods to the list.
     
     
    -127
    -128
    -129
    -130
     131
     132
     133
    -134
    +134 +135 +136 +137 +138 +139
    -
    # File 'lib/axlsx/util/simple_typed_list.rb', line 127
    +      
    # File 'lib/axlsx/util/simple_typed_list.rb', line 131
     
     def method_missing(meth, *args, &block)
    -  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        
    +  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        
       if @list.respond_to? meth
         @list.send(meth, *args, &block)      
       else
    +    puts "method:#{meth.inspect}"
         super
       end
     end
    @@ -990,6 +1016,49 @@ if the value being added is not one fo the allowed types
         
    +
    + +
    +

    + + - (Object) ==(v) + + + +

    +
    +

    +override the equality method so that this object can be compared to a +simple array. if this object’s list is equal to the specifiec array, +we return true. +

    + + +
    +
    +
    + + +
    + + + + +
    +
    +
    +
    +105
    +106
    +107
    +
    +
    # File 'lib/axlsx/util/simple_typed_list.rb', line 105
    +
    +def ==(v)
    +  v == @list
    +end
    +
    +
    @@ -1523,16 +1592,16 @@ The document builder instance this objects xml will be added to.
     
     
    -141
    -142
    -143
    -144
    -145
     146
    -147
    +147 +148 +149 +150 +151 +152
  • -
    # File 'lib/axlsx/util/simple_typed_list.rb', line 141
    +      
    # File 'lib/axlsx/util/simple_typed_list.rb', line 146
     
     def to_xml(xml)
       classname = @allowed_types[0].name.split('::').last
    @@ -1608,7 +1677,7 @@ Unlock the list
     
         
         
    diff --git a/doc/Axlsx/Styles.html b/doc/Axlsx/Styles.html
    index a11d4454..8044712f 100644
    --- a/doc/Axlsx/Styles.html
    +++ b/doc/Axlsx/Styles.html
    @@ -1745,7 +1745,7 @@ Serializes the styles document
     
         
         
    diff --git a/doc/Axlsx/TableStyle.html b/doc/Axlsx/TableStyle.html
    index 0bd012be..5318b1d7 100644
    --- a/doc/Axlsx/TableStyle.html
    +++ b/doc/Axlsx/TableStyle.html
    @@ -289,7 +289,7 @@ Serializes the table style.
       
       
       

    Methods inherited from SimpleTypedList

    -

    #<<, #[]=, #delete, #delete_at, #lock, #method_missing, #protected?, #push, #unlock

    +

    #<<, #==, #[]=, #delete, #delete_at, #lock, #method_missing, #protected?, #push, #unlock

    Constructor Details

    @@ -701,7 +701,7 @@ The document builder instance this objects xml will be added to.
    diff --git a/doc/Axlsx/TableStyleElement.html b/doc/Axlsx/TableStyleElement.html index 4f2ed657..7616bef5 100644 --- a/doc/Axlsx/TableStyleElement.html +++ b/doc/Axlsx/TableStyleElement.html @@ -668,7 +668,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/TableStyles.html b/doc/Axlsx/TableStyles.html index be8a4c84..2458c69b 100644 --- a/doc/Axlsx/TableStyles.html +++ b/doc/Axlsx/TableStyles.html @@ -265,7 +265,7 @@ Serializes the table styles element.

    Methods inherited from SimpleTypedList

    -

    #<<, #[]=, #delete, #delete_at, #lock, #method_missing, #protected?, #push, #unlock

    +

    #<<, #==, #[]=, #delete, #delete_at, #lock, #method_missing, #protected?, #push, #unlock

    Constructor Details

    @@ -590,7 +590,7 @@ The document builder instance this objects xml will be added to.
    diff --git a/doc/Axlsx/Title.html b/doc/Axlsx/Title.html index 9a97f09c..f66f1339 100644 --- a/doc/Axlsx/Title.html +++ b/doc/Axlsx/Title.html @@ -616,7 +616,7 @@ The document builder instance this objects xml will be added to. diff --git a/doc/Axlsx/TwoCellAnchor.html b/doc/Axlsx/TwoCellAnchor.html index fc8e86a3..20e6e8c8 100644 --- a/doc/Axlsx/TwoCellAnchor.html +++ b/doc/Axlsx/TwoCellAnchor.html @@ -277,30 +277,6 @@ A marker that returns the to cell anchor.
  • - - (Marker) end_at(x, y) - - - - - - - - - - - - -

    -This is a short cut method to set the end anchor position. -

    -
    - -
  • - - -
  • - - - (TwoCellAnchor) initialize(drawing, chart_type, options) @@ -317,31 +293,8 @@ This is a short cut method to set the end anchor position.

    -Creates a new TwoCellAnchor object. -

    -
    - -
  • - - -
  • - - - - (Marker) start_at(x, y) - - - - - - - - - - - - -

    -This is a short cut method to set the start anchor position. +Creates a new TwoCellAnchor object and sets up a reference to the from and +to markers in the graphic_frame’s chart.

    @@ -388,7 +341,9 @@ Serializes the two cell anchor.

    -Creates a new TwoCellAnchor object +Creates a new TwoCellAnchor object and sets up a reference to the from and +to markers in the graphic_frame’s chart. That means that you can do +stuff like c = worksheet.add_chart Axlsx::Chart c.start_at 5, 9

    @@ -411,13 +366,20 @@ Creates a new TwoCellAnchor object
  • - chart + chart_type - (Chart) + (Class) + — +

    +This is passed to the graphic frame for instantiation. must be Chart or a +subclass of Chart +

    +
    +
  • @@ -455,7 +417,10 @@ a customizable set of options - + —

    +the col, row to start at +

    +
  • @@ -464,7 +429,10 @@ a customizable set of options - + —

    +the col, row to end at +

    +
  • @@ -477,37 +445,21 @@ a customizable set of options
     
     
    -31
    -32
    -33
     34
     35
     36
     37
     38
    -39
    -40
    -41
    -42
    -43
    -44
    +39
    -
    # File 'lib/axlsx/drawing/two_cell_anchor.rb', line 31
    +      
    # File 'lib/axlsx/drawing/two_cell_anchor.rb', line 34
     
     def initialize(drawing, chart_type, options)
       @drawing = drawing
       drawing.anchors << self      
    -
       @from, @to =  Marker.new, Marker.new(:col => 5, :row=>10)
       @graphic_frame = GraphicFrame.new(self, chart_type, options)
    -
    -  self.start_at(options[:start_at][0], options[:start_at][1]) if options[:start_at].is_a?(Array)
    -  self.end_at(options[:end_at][0], options[:end_at][1]) if options[:end_at].is_a?(Array)
    -  # passing a reference to our start and end markers for convenience
    -  # this lets us access the markers directly from the chart.
    -  @graphic_frame.chart.send(:start_at=, @from)
    -  @graphic_frame.chart.send(:end_at=, @to)
     end
     
    - - - - -
    -
    -
    -
    -65
    -66
    -67
    -68
    -69
    -
    -
    # File 'lib/axlsx/drawing/two_cell_anchor.rb', line 65
    -
    -def end_at(x, y)
    -  @to.col = x
    -  @to.row = y
    -  @to
    -end
    -
    -
    - - -
    -

    - - - (Marker) start_at(x, y) - - - -

    -
    -

    -This is a short cut method to set the start anchor position -

    - - -
    -
    -
    -

    Parameters:

    -
      - -
    • - - x - - - (Integer) - - - - — -

      -The column -

      -
      - -
    • - -
    • - - y - - - (Integer) - - - - — -

      -The row -

      -
      - -
    • - -
    - -

    Returns:

    -
      - -
    • - - - (Marker) - - - -
    • - -
    - -
    - - - - -
    -
    -
    -
    -55
    -56
    -57
    -58
    -59
    -
    -
    # File 'lib/axlsx/drawing/two_cell_anchor.rb', line 55
    -
    -def start_at(x, y)
    -  @from.col = x
    -  @from.row = y
    -  @from
    -end
    -
    -
    -
    - -
    -

    +

    - (String) to_xml(xml) @@ -1065,22 +825,22 @@ The document builder instance this objects xml will be added to.

     
     
    -74
    -75
    -76
    -77
    -78
    -79
    -80
    -81
    -82
    -83
    -84
    -85
    -86
    +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59
    -
    # File 'lib/axlsx/drawing/two_cell_anchor.rb', line 74
    +      
    # File 'lib/axlsx/drawing/two_cell_anchor.rb', line 47
     
     def to_xml(xml)
       #build it for now, break it down later!
    @@ -1106,7 +866,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/ValAxis.html b/doc/Axlsx/ValAxis.html
    index f5101e70..6275d10b 100644
    --- a/doc/Axlsx/ValAxis.html
    +++ b/doc/Axlsx/ValAxis.html
    @@ -135,8 +135,7 @@ the ValAxis class defines a chart value axis.
     
       
         

    -This element specifies whether the value axis crosses the category axis -between categories. +This element specifies how the value axis crosses the category axis.

    @@ -320,7 +319,7 @@ a customizable set of options
  • - crosses + tickLblPos (Symbol) @@ -329,7 +328,7 @@ a customizable set of options
  • - tickLblPos + crosses (Symbol) @@ -365,7 +364,7 @@ a customizable set of options
    # File 'lib/axlsx/drawing/val_axis.rb', line 17
     
     def initialize(axId, crossAx, options={})
    -  @crossBetween = :between
    +  self.crossBetween = :between
       super(axId, crossAx, options)
     end
     
    @@ -392,8 +391,8 @@ a customizable set of options

    -This element specifies whether the value axis crosses the category axis -between categories. must be one of [:between, :midCat] +This element specifies how the value axis crosses the category axis. must +be one of [:between, :midCat]

    @@ -530,7 +529,7 @@ The document builder instance this objects xml will be added to.
    diff --git a/doc/Axlsx/ValAxisData.html b/doc/Axlsx/ValAxisData.html new file mode 100644 index 00000000..25145718 --- /dev/null +++ b/doc/Axlsx/ValAxisData.html @@ -0,0 +1,326 @@ + + + + + + Class: Axlsx::ValAxisData + + — Documentation by YARD 0.7.3 + + + + + + + + + + + + + + + + + + + + + + +

    Class: Axlsx::ValAxisData + + + +

    + +
    + +
    Inherits:
    +
    + CatAxisData + + + show all + +
    + + + + + + + + + +
    Defined in:
    +
    lib/axlsx/drawing/val_axis_data.rb
    + +
    +
    + +

    Overview

    +
    +

    +The ValAxisData class manages the values for a chart value series. +

    + + +
    +
    +
    + + +
    + + + + + + + + + + + + + + + + + +

    Instance Attribute Summary

    + +

    Attributes inherited from SimpleTypedList

    +

    allowed_types, locked_at, serialize_as

    + + + +

    + Instance Method Summary + (collapse) +

    + + + + + + + + + + + + +

    Methods inherited from CatAxisData

    +

    #initialize

    + + + + + + + + +

    Methods inherited from SimpleTypedList

    +

    #<<, #==, #[]=, #delete, #delete_at, #initialize, #lock, #method_missing, #protected?, #push, #unlock

    +
    +

    Constructor Details

    + +

    This class inherits a constructor from Axlsx::CatAxisData

    + +
    +
    +

    Dynamic Method Handling

    +

    + This class handles dynamic methods through the method_missing method + + in the class Axlsx::SimpleTypedList + +

    + +
    + + +
    +

    Instance Method Details

    + + +
    +

    + + - (String) to_xml(xml) + + + +

    +
    +

    +Serializes the value axis data +

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + xml + + + (Nokogiri::XML::Builder) + + + + — +

      +The document builder instance this objects xml will be added to. +

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (String) + + + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +8
    +9
    +10
    +11
    +12
    +13
    +14
    +15
    +16
    +17
    +18
    +19
    +20
    +21
    +22
    +23
    +24
    +
    +
    # File 'lib/axlsx/drawing/val_axis_data.rb', line 8
    +
    +def to_xml(xml)
    +  xml.send('c:val') {
    +    xml.send('c:numRef') {
    +      xml.send('c:f', Axlsx::cell_range(@list))
    +      xml.send('c:numCache') {
    +        xml.send('c:formatCode', 'General')
    +        xml.send('c:ptCount', :val=>size)
    +        each_with_index do |item, index|
    +          v = item.is_a?(Cell) ? item.value : item
    +          xml.send('c:pt', :idx=>index) {
    +            xml.send('c:v', v) 
    +          }
    +        end
    +      }                        
    +    }
    +  }
    +end
    +
    +
    +
    + +
    + +
    + + + + + \ No newline at end of file diff --git a/doc/Axlsx/View3D.html b/doc/Axlsx/View3D.html index 73bfd8bf..cdc5599f 100644 --- a/doc/Axlsx/View3D.html +++ b/doc/Axlsx/View3D.html @@ -494,14 +494,14 @@ a customizable set of options
     
     
    -39
    -40
    -41
    -42
    -43
    +46 +47 +48 +49 +50
  • -
    # File 'lib/axlsx/drawing/view_3D.rb', line 39
    +      
    # File 'lib/axlsx/drawing/view_3D.rb', line 46
     
     def initialize(options={})
       options.each do |o|
    @@ -560,12 +560,12 @@ depth or chart as % of chart width must be between 20% and 2000%
           
     
     
    -22
    -23
    -24
    +29 +30 +31
    -
    # File 'lib/axlsx/drawing/view_3D.rb', line 22
    +      
    # File 'lib/axlsx/drawing/view_3D.rb', line 29
     
     def depthPercent
       @depthPercent
    @@ -617,12 +617,12 @@ height of chart as % of chart must be between 5% and 500%
           
     
     
    -12
    -13
    -14
    +19 +20 +21
    -
    # File 'lib/axlsx/drawing/view_3D.rb', line 12
    +      
    # File 'lib/axlsx/drawing/view_3D.rb', line 19
     
     def hPercent
       @hPercent
    @@ -674,12 +674,12 @@ field of view angle
           
     
     
    -30
    -31
    -32
    +37 +38 +39
    -
    # File 'lib/axlsx/drawing/view_3D.rb', line 30
    +      
    # File 'lib/axlsx/drawing/view_3D.rb', line 37
     
     def perspective
       @perspective
    @@ -731,12 +731,12 @@ Chart axis are at right angles
           
     
     
    -26
    -27
    -28
    +33 +34 +35
    -
    # File 'lib/axlsx/drawing/view_3D.rb', line 26
    +      
    # File 'lib/axlsx/drawing/view_3D.rb', line 33
     
     def rAngAx
       @rAngAx
    @@ -788,12 +788,12 @@ x rotation for the chart must be between -90 and 90
           
     
     
    -7
    -8
    -9
    +14 +15 +16
    -
    # File 'lib/axlsx/drawing/view_3D.rb', line 7
    +      
    # File 'lib/axlsx/drawing/view_3D.rb', line 14
     
     def rotX
       @rotX
    @@ -845,12 +845,12 @@ y rotation for the chart must be between 0 and 360
           
     
     
    -17
    -18
    -19
    +24 +25 +26
    -
    # File 'lib/axlsx/drawing/view_3D.rb', line 17
    +      
    # File 'lib/axlsx/drawing/view_3D.rb', line 24
     
     def rotY
       @rotY
    @@ -927,19 +927,19 @@ The document builder instance this objects xml will be added to.
           
     
     
    -61
    -62
    -63
    -64
    -65
    -66
     67
     68
     69
    -70
    +70 +71 +72 +73 +74 +75 +76
    -
    # File 'lib/axlsx/drawing/view_3D.rb', line 61
    +      
    # File 'lib/axlsx/drawing/view_3D.rb', line 67
     
     def to_xml(xml)
       xml.send('c:view3D') {
    @@ -962,7 +962,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/Axlsx/Workbook.html b/doc/Axlsx/Workbook.html
    index 134092c7..37e81c09 100644
    --- a/doc/Axlsx/Workbook.html
    +++ b/doc/Axlsx/Workbook.html
    @@ -1338,7 +1338,7 @@ Serializes the workbook document
     
         
         
    diff --git a/doc/Axlsx/Worksheet.html b/doc/Axlsx/Worksheet.html
    index f3131f16..93e90793 100644
    --- a/doc/Axlsx/Worksheet.html
    +++ b/doc/Axlsx/Worksheet.html
    @@ -1287,8 +1287,20 @@ The workbook that owns this worksheet
       
     

    -

    -Adds a chart to this worksheets drawing. + +

    + Note: +

    +each chart type also specifies additional options +

    +
    +
    + +

    +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.

    @@ -1365,6 +1377,24 @@ a customizable set of options +
  • + show_legend + (Boolean) + + + + +
  • + +
  • + style + (Integer) + + + + +
  • + @@ -1382,20 +1412,35 @@ a customizable set of options +

    See Also:

    + +
     
     
    -108
    -109
    -110
    -111
    -112
    +116 +117 +118 +119 +120
    -
    # File 'lib/axlsx/workbook/worksheet/worksheet.rb', line 108
    +      
    # File 'lib/axlsx/workbook/worksheet/worksheet.rb', line 116
     
     def add_chart(chart_type, options={})
       chart = drawing.add_chart(chart_type, options)
    @@ -1615,19 +1660,19 @@ hash of auto_fit_data
           
     
     
    -182
    -183
    -184
    -185
    -186
    -187
    -188
    -189
     190
    -191
    +191 +192 +193 +194 +195 +196 +197 +198 +199
    -
    # File 'lib/axlsx/workbook/worksheet/worksheet.rb', line 182
    +      
    # File 'lib/axlsx/workbook/worksheet/worksheet.rb', line 190
     
     def auto_width(col)
       mdw = 6.0 # maximum digit with is always 6.0 in testable fonts so instead of beating RMagick every time, I am hardcoding it here.
    @@ -1683,14 +1728,6 @@ Serializes the worksheet document
           
     
     
    -116
    -117
    -118
    -119
    -120
    -121
    -122
    -123
     124
     125
     126
    @@ -1703,10 +1740,18 @@ Serializes the worksheet document
     133
     134
     135
    -136
    +136 +137 +138 +139 +140 +141 +142 +143 +144
    -
    # File 'lib/axlsx/workbook/worksheet/worksheet.rb', line 116
    +      
    # File 'lib/axlsx/workbook/worksheet/worksheet.rb', line 124
     
     def to_xml
       builder = Nokogiri::XML::Builder.new(:encoding => ENCODING) do |xml|
    @@ -1802,14 +1847,6 @@ of Cell objects
           
     
     
    -154
    -155
    -156
    -157
    -158
    -159
    -160
    -161
     162
     163
     164
    @@ -1820,10 +1857,18 @@ of Cell objects
     169
     170
     171
    -172
    +172 +173 +174 +175 +176 +177 +178 +179 +180
    -
    # File 'lib/axlsx/workbook/worksheet/worksheet.rb', line 154
    +      
    # File 'lib/axlsx/workbook/worksheet/worksheet.rb', line 162
     
     def update_auto_fit_data(cells)
       styles = self.workbook.styles
    @@ -1855,7 +1900,7 @@ of Cell objects
     
         
         
    diff --git a/doc/Axlsx/Xf.html b/doc/Axlsx/Xf.html
    index 17c94f7f..f92867c7 100644
    --- a/doc/Axlsx/Xf.html
    +++ b/doc/Axlsx/Xf.html
    @@ -1672,7 +1672,7 @@ The document builder instance this objects xml will be added to.
     
         
         
    diff --git a/doc/_index.html b/doc/_index.html
    index 6f891d0a..dc411c2f 100644
    --- a/doc/_index.html
    +++ b/doc/_index.html
    @@ -150,6 +150,13 @@
                     
                   
                 
    +              
  • + CatAxisData + + (Axlsx) + +
  • +
  • Cell @@ -543,6 +550,13 @@
  • +
  • + ValAxisData + + (Axlsx) + +
  • +
  • View3D @@ -602,7 +616,7 @@ diff --git a/doc/class_list.html b/doc/class_list.html index d2d0c201..768281a5 100644 --- a/doc/class_list.html +++ b/doc/class_list.html @@ -39,7 +39,7 @@ diff --git a/doc/file.README.html b/doc/file.README.html index e4129686..312220af 100644 --- a/doc/file.README.html +++ b/doc/file.README.html @@ -99,7 +99,7 @@ It enables the you to generate 100% valid xlsx files that include customised sty require 'axlsx'
  • -

    A Simple Workbooka

    +

    A Simple Workbook

      p = Axlsx::Package.new
       p.workbook.add_worksheet do |sheet|
    @@ -205,10 +205,18 @@ It enables the you to generate 100% valid xlsx files that include customised sty
     

    Changelog

      -
    • October.22.11: 1.0.7 release +
    • October.?.13: 1.0.7 release preparation
        -
      • Updated serialization write test to verify write permissions and warn if it cannot run the test
      • +
      • Updated serialization write test to verify write permissions and warn if it cannot run the test due to permission restrcitions.
      • +
      • updated rake to include build, genoc and deploy tasks.
      • +
      • rebuilt documentation.
      • +
      • moved version constant to its own file
      • +
      • fixed bug in SerAxis that was requiring tickLblSkip and tickMarkSkip to be boolean. Should be unsigned int.
      • +
      • Review and improve docs
      • +
      • rebuild of anchor positioning to remove some spagetti code. Chart now supports a start_at and end_at method that accept an arrar for col/row positioning. See example6 for an example. You can still pass :start_at and :end_at options to worksheet.add_chart.
      • +
      • Added support for 3D options when creating a new chart. This lets you set the persective, rotation and other 3D attributes when using worksheet.add_chart
      • +
      • Refactored cat and val axis data to keep series serialization a bit more DRY
    @@ -216,14 +224,6 @@ It enables the you to generate 100% valid xlsx files that include customised sty

    Please see the CHANGELOG document for past release information.

    -

    On Deck

    - -
      -
    • Verification with ruby 1.9.3
    • -
    • Active Record support via package::serialize_ar so you can dump an AR result into a worksheet in one go.
    • -
    - -

    Copyright

    Axlsx © 2011 by Randy Morgan. Axlsx is @@ -231,7 +231,7 @@ licensed under the MIT license. Please see the

    diff --git a/doc/index.html b/doc/index.html index e4129686..312220af 100644 --- a/doc/index.html +++ b/doc/index.html @@ -99,7 +99,7 @@ It enables the you to generate 100% valid xlsx files that include customised sty require 'axlsx'
    -

    A Simple Workbooka

    +

    A Simple Workbook

      p = Axlsx::Package.new
       p.workbook.add_worksheet do |sheet|
    @@ -205,10 +205,18 @@ It enables the you to generate 100% valid xlsx files that include customised sty
     

    Changelog

      -
    • October.22.11: 1.0.7 release +
    • October.?.13: 1.0.7 release preparation
        -
      • Updated serialization write test to verify write permissions and warn if it cannot run the test
      • +
      • Updated serialization write test to verify write permissions and warn if it cannot run the test due to permission restrcitions.
      • +
      • updated rake to include build, genoc and deploy tasks.
      • +
      • rebuilt documentation.
      • +
      • moved version constant to its own file
      • +
      • fixed bug in SerAxis that was requiring tickLblSkip and tickMarkSkip to be boolean. Should be unsigned int.
      • +
      • Review and improve docs
      • +
      • rebuild of anchor positioning to remove some spagetti code. Chart now supports a start_at and end_at method that accept an arrar for col/row positioning. See example6 for an example. You can still pass :start_at and :end_at options to worksheet.add_chart.
      • +
      • Added support for 3D options when creating a new chart. This lets you set the persective, rotation and other 3D attributes when using worksheet.add_chart
      • +
      • Refactored cat and val axis data to keep series serialization a bit more DRY
    @@ -216,14 +224,6 @@ It enables the you to generate 100% valid xlsx files that include customised sty

    Please see the CHANGELOG document for past release information.

    -

    On Deck

    - -
      -
    • Verification with ruby 1.9.3
    • -
    • Active Record support via package::serialize_ar so you can dump an AR result into a worksheet in one go.
    • -
    - -

    Copyright

    Axlsx © 2011 by Randy Morgan. Axlsx is @@ -231,7 +231,7 @@ licensed under the MIT license. Please see the

    diff --git a/doc/method_list.html b/doc/method_list.html index 0e0fa86c..8b35aedf 100644 --- a/doc/method_list.html +++ b/doc/method_list.html @@ -49,15 +49,15 @@
  • - #AppVersion + #== - Axlsx::App + Axlsx::SimpleTypedList
  • - #Application + #AppVersion Axlsx::App @@ -65,7 +65,7 @@
  • - #Characters + #Application Axlsx::App @@ -73,7 +73,7 @@
  • - #CharactersWithSpaces + #Characters Axlsx::App @@ -81,7 +81,7 @@
  • - #Company + #CharactersWithSpaces Axlsx::App @@ -89,9 +89,9 @@
  • - #ContentType + #Company - Axlsx::Override + Axlsx::App
  • @@ -105,6 +105,14 @@
  • + #ContentType + + Axlsx::Override + +
  • + + +
  • #DocSecurity Axlsx::App @@ -112,7 +120,7 @@
  • -
  • +
  • #Extension Axlsx::Default @@ -120,7 +128,7 @@
  • -
  • +
  • #HiddenSlides Axlsx::App @@ -128,7 +136,7 @@
  • -
  • +
  • #HyperLinkBase Axlsx::App @@ -136,7 +144,7 @@
  • -
  • +
  • #HyperlinksChanged Axlsx::App @@ -144,7 +152,7 @@
  • -
  • +
  • #Lines Axlsx::App @@ -152,7 +160,7 @@
  • -
  • +
  • #LinksUpToDate Axlsx::App @@ -160,7 +168,7 @@
  • -
  • +
  • #MMClips Axlsx::App @@ -168,7 +176,7 @@
  • -
  • +
  • #Manager Axlsx::App @@ -176,7 +184,7 @@
  • -
  • +
  • #Notes Axlsx::App @@ -184,7 +192,7 @@
  • -
  • +
  • #Pages Axlsx::App @@ -192,7 +200,7 @@
  • -
  • +
  • #Paragraphs Axlsx::App @@ -200,7 +208,7 @@
  • -
  • +
  • #PartName Axlsx::Override @@ -208,7 +216,7 @@
  • -
  • +
  • #PresentationFormat Axlsx::App @@ -216,7 +224,7 @@
  • -
  • +
  • #ScaleCrop Axlsx::App @@ -224,7 +232,7 @@
  • -
  • +
  • #ShareDoc Axlsx::App @@ -232,7 +240,7 @@
  • -
  • +
  • #Slides Axlsx::App @@ -240,7 +248,7 @@
  • -
  • +
  • #Target Axlsx::Relationship @@ -248,7 +256,7 @@
  • -
  • +
  • #Template Axlsx::App @@ -256,7 +264,7 @@
  • -
  • +
  • #TotalTime Axlsx::App @@ -264,7 +272,7 @@
  • -
  • +
  • #Type Axlsx::Relationship @@ -272,7 +280,7 @@
  • -
  • +
  • #Words Axlsx::App @@ -280,7 +288,7 @@
  • -
  • +
  • #[]= Axlsx::SimpleTypedList @@ -288,7 +296,7 @@
  • -
  • +
  • #add_cell Axlsx::Row @@ -296,7 +304,7 @@
  • -
  • +
  • #add_chart Axlsx::Worksheet @@ -304,7 +312,7 @@
  • -
  • +
  • #add_chart Axlsx::Drawing @@ -312,7 +320,7 @@
  • -
  • +
  • #add_row Axlsx::Worksheet @@ -320,7 +328,7 @@
  • -
  • +
  • #add_series Axlsx::Chart @@ -328,7 +336,7 @@
  • -
  • +
  • #add_style Axlsx::Styles @@ -336,7 +344,7 @@
  • -
  • +
  • #add_worksheet Axlsx::Workbook @@ -344,7 +352,7 @@
  • -
  • +
  • #alignment Axlsx::Xf @@ -352,7 +360,7 @@
  • -
  • +
  • #allowed_types Axlsx::SimpleTypedList @@ -360,7 +368,7 @@
  • -
  • +
  • #anchor Axlsx::GraphicFrame @@ -368,7 +376,7 @@
  • -
  • +
  • #anchors Axlsx::Drawing @@ -376,7 +384,7 @@
  • -
  • +
  • #applyAlignment Axlsx::Xf @@ -384,7 +392,7 @@
  • -
  • +
  • #applyBorder Axlsx::Xf @@ -392,7 +400,7 @@
  • -
  • +
  • #applyFill Axlsx::Xf @@ -400,7 +408,7 @@
  • -
  • +
  • #applyFont Axlsx::Xf @@ -408,7 +416,7 @@
  • -
  • +
  • #applyNumberFormat Axlsx::Xf @@ -416,7 +424,7 @@
  • -
  • +
  • #applyProtection Axlsx::Xf @@ -424,7 +432,7 @@
  • -
  • +
  • #auto Axlsx::CatAxis @@ -432,7 +440,7 @@
  • -
  • +
  • #auto Axlsx::Color @@ -440,7 +448,7 @@
  • -
  • +
  • #auto_fit_data Axlsx::Worksheet @@ -448,7 +456,7 @@
  • -
  • +
  • #auto_width Axlsx::Worksheet @@ -456,7 +464,7 @@
  • -
  • +
  • #axId Axlsx::Axis @@ -464,7 +472,7 @@
  • -
  • +
  • #axPos Axlsx::Axis @@ -472,7 +480,7 @@
  • -
  • +
  • #b Axlsx::Font @@ -480,7 +488,7 @@
  • -
  • +
  • #barDir Axlsx::Bar3DChart @@ -488,7 +496,7 @@
  • -
  • +
  • #base_content_types Axlsx::Package @@ -496,7 +504,7 @@
  • -
  • +
  • #bgColor Axlsx::PatternFill @@ -504,7 +512,7 @@
  • -
  • +
  • #borderId Axlsx::Xf @@ -512,7 +520,7 @@
  • -
  • +
  • #borders Axlsx::Styles @@ -520,7 +528,7 @@
  • -
  • +
  • #bottom Axlsx::GradientFill @@ -528,7 +536,7 @@
  • -
  • +
  • #builtinId Axlsx::CellStyle @@ -536,7 +544,7 @@
  • -
  • +
  • #cast_value Axlsx::Cell @@ -544,23 +552,23 @@
  • -
  • - #catAxis +
  • + #catAxis - Axlsx::Line3DChart + Axlsx::Bar3DChart
  • -
  • - #catAxis +
  • + #catAxis - Axlsx::Bar3DChart + Axlsx::Line3DChart
  • -
  • +
  • #cell Axlsx::Title @@ -568,7 +576,7 @@
  • -
  • +
  • #cellStyleXfs Axlsx::Styles @@ -576,7 +584,7 @@
  • -
  • +
  • #cellStyles Axlsx::Styles @@ -584,7 +592,7 @@
  • -
  • +
  • #cellXfs Axlsx::Styles @@ -592,7 +600,7 @@
  • -
  • +
  • cell_range Axlsx @@ -600,7 +608,7 @@
  • -
  • +
  • #cell_type_from_value Axlsx::Cell @@ -608,7 +616,7 @@
  • -
  • +
  • #cells Axlsx::Row @@ -616,7 +624,7 @@
  • -
  • +
  • #charset Axlsx::Font @@ -624,7 +632,7 @@
  • -
  • +
  • #chart Axlsx::Series @@ -632,7 +640,7 @@
  • -
  • +
  • #chart Axlsx::GraphicFrame @@ -640,14 +648,6 @@
  • -
  • - #charts - - Axlsx::Drawing - -
  • - -
  • #charts @@ -657,15 +657,15 @@
  • - #col + #charts - Axlsx::Marker + Axlsx::Drawing
  • - #colOff + #col Axlsx::Marker @@ -673,17 +673,17 @@
  • - #col_ref + #colOff - Axlsx::Cell + Axlsx::Marker
  • - #color + #col_ref - Axlsx::Font + Axlsx::Cell
  • @@ -697,6 +697,14 @@
  • + #color + + Axlsx::Font + +
  • + + +
  • #color Axlsx::BorderPr @@ -704,7 +712,7 @@
  • -
  • +
  • #condense Axlsx::Font @@ -712,7 +720,7 @@
  • -
  • +
  • #content_types Axlsx::Package @@ -720,7 +728,7 @@
  • -
  • +
  • #coord Axlsx::Marker @@ -728,7 +736,7 @@
  • -
  • +
  • #creator Axlsx::Core @@ -736,7 +744,7 @@
  • -
  • +
  • #crossAx Axlsx::Axis @@ -744,7 +752,7 @@
  • -
  • +
  • #crossBetween Axlsx::ValAxis @@ -752,7 +760,7 @@
  • -
  • +
  • #crosses Axlsx::Axis @@ -760,7 +768,7 @@
  • -
  • +
  • #customBuiltin Axlsx::CellStyle @@ -768,23 +776,23 @@
  • -
  • - #data +
  • + #data - Axlsx::BarSeries + Axlsx::PieSeries
  • -
  • - #data +
  • + #data - Axlsx::PieSeries + Axlsx::BarSeries
  • -
  • +
  • #data Axlsx::LineSeries @@ -792,7 +800,7 @@
  • -
  • +
  • date1904 Axlsx::Workbook @@ -800,7 +808,7 @@
  • -
  • +
  • #date1904 Axlsx::Workbook @@ -808,7 +816,7 @@
  • -
  • +
  • date1904= Axlsx::Workbook @@ -816,7 +824,7 @@
  • -
  • +
  • #defaultPivotStyle Axlsx::TableStyles @@ -824,7 +832,7 @@
  • -
  • +
  • #defaultTableStyle Axlsx::TableStyles @@ -832,7 +840,7 @@
  • -
  • +
  • #degree Axlsx::GradientFill @@ -840,7 +848,7 @@
  • -
  • +
  • #delete Axlsx::SimpleTypedList @@ -848,7 +856,7 @@
  • -
  • +
  • #delete_at Axlsx::SimpleTypedList @@ -856,7 +864,7 @@
  • -
  • +
  • #depthPercent Axlsx::View3D @@ -864,7 +872,7 @@
  • -
  • +
  • #diagonalDown Axlsx::Border @@ -872,7 +880,7 @@
  • -
  • +
  • #diagonalUp Axlsx::Border @@ -880,7 +888,7 @@
  • -
  • +
  • #drawing Axlsx::Worksheet @@ -888,7 +896,7 @@
  • -
  • +
  • #drawing Axlsx::TwoCellAnchor @@ -896,7 +904,7 @@
  • -
  • +
  • #drawings Axlsx::Workbook @@ -904,7 +912,7 @@
  • -
  • +
  • #dxfId Axlsx::TableStyleElement @@ -912,7 +920,7 @@
  • -
  • +
  • #dxfs Axlsx::Styles @@ -920,7 +928,7 @@
  • -
  • +
  • #end_at Axlsx::Chart @@ -928,14 +936,6 @@
  • -
  • - #end_at - - Axlsx::TwoCellAnchor - -
  • - -
  • #explosion @@ -1025,17 +1025,17 @@
  • - #from + #from - Axlsx::TwoCellAnchor + Axlsx::Chart
  • - #gapDepth + #from - Axlsx::Bar3DChart + Axlsx::TwoCellAnchor
  • @@ -1049,7 +1049,7 @@
  • - #gapWidth + #gapDepth Axlsx::Bar3DChart @@ -1057,9 +1057,9 @@
  • - #graphic_frame + #gapWidth - Axlsx::TwoCellAnchor + Axlsx::Bar3DChart
  • @@ -1073,9 +1073,9 @@
  • - #grouping + #graphic_frame - Axlsx::Bar3DChart + Axlsx::TwoCellAnchor
  • @@ -1089,6 +1089,14 @@
  • + #grouping + + Axlsx::Bar3DChart + +
  • + + +
  • #hPercent Axlsx::View3D @@ -1096,7 +1104,7 @@
  • -
  • +
  • #hidden Axlsx::CellProtection @@ -1104,7 +1112,7 @@
  • -
  • +
  • #hidden Axlsx::CellStyle @@ -1112,7 +1120,7 @@
  • -
  • +
  • #horizontal Axlsx::CellAlignment @@ -1120,7 +1128,7 @@
  • -
  • +
  • #i Axlsx::Font @@ -1128,7 +1136,7 @@
  • -
  • +
  • #iLevel Axlsx::CellStyle @@ -1136,7 +1144,7 @@
  • -
  • +
  • #indent Axlsx::CellAlignment @@ -1144,7 +1152,7 @@
  • -
  • +
  • #index Axlsx::TwoCellAnchor @@ -1152,18 +1160,10 @@
  • -
  • - #index - - Axlsx::Cell - -
  • - -
  • - #index + #index - Axlsx::Row + Axlsx::Series
  • @@ -1193,14 +1193,22 @@
  • - #index + #index - Axlsx::Series + Axlsx::Row
  • + #index + + Axlsx::Cell + +
  • + + +
  • #initalize Axlsx::App @@ -1208,106 +1216,114 @@
  • +
  • + #initialize + + Axlsx::SerAxis + +
  • + +
  • - #initialize + #initialize - Axlsx::Package + Axlsx::Fill
  • - #initialize + #initialize - Axlsx::Title + Axlsx::TableStyles
  • - #initialize + #initialize - Axlsx::ValAxis + Axlsx::SimpleTypedList
  • - #initialize + #initialize - Axlsx::TwoCellAnchor + Axlsx::Relationship
  • - #initialize + #initialize - Axlsx::Core + Axlsx::CellStyle
  • - #initialize + #initialize - Axlsx::PieSeries + Axlsx::Bar3DChart
  • - #initialize + #initialize - Axlsx::BorderPr + Axlsx::Marker
  • - #initialize + #initialize - Axlsx::LineSeries + Axlsx::View3D
  • - #initialize + #initialize - Axlsx::Fill + Axlsx::Core
  • - #initialize + #initialize - Axlsx::Cell + Axlsx::TableStyle
  • - #initialize + #initialize - Axlsx::Scaling + Axlsx::Axis
  • - #initialize + #initialize - Axlsx::SimpleTypedList + Axlsx::GradientStop
  • - #initialize + #initialize - Axlsx::Drawing + Axlsx::Pie3DChart
  • @@ -1321,161 +1337,161 @@
  • - #initialize + #initialize - Axlsx::Styles + Axlsx::Xf
  • - #initialize + #initialize - Axlsx::Row + Axlsx::BarSeries
  • - #initialize + #initialize - Axlsx::NumFmt + Axlsx::GradientFill
  • - #initialize + #initialize - Axlsx::Border + Axlsx::Package
  • - #initialize + #initialize - Axlsx::Workbook + Axlsx::TableStyleElement
  • - #initialize + #initialize - Axlsx::Line3DChart + Axlsx::Drawing
  • - #initialize + #initialize - Axlsx::TableStyle + Axlsx::Series
  • - #initialize + #initialize - Axlsx::PatternFill + Axlsx::TwoCellAnchor
  • - #initialize + #initialize - Axlsx::GraphicFrame + Axlsx::Chart
  • - #initialize + #initialize - Axlsx::Xf + Axlsx::Default
  • - #initialize + #initialize - Axlsx::GradientStop + Axlsx::CatAxis
  • - #initialize + #initialize - Axlsx::Override + Axlsx::Color
  • - #initialize + #initialize - Axlsx::TableStyles + Axlsx::Border
  • - #initialize + #initialize - Axlsx::Marker + Axlsx::PatternFill
  • - #initialize + #initialize - Axlsx::ContentType + Axlsx::CatAxisData
  • - #initialize + #initialize - Axlsx::GradientFill + Axlsx::Relationships
  • - #initialize + #initialize - Axlsx::Color + Axlsx::Row
  • - #initialize + #initialize - Axlsx::CellStyle + Axlsx::Scaling
  • - #initialize + #initialize - Axlsx::Chart + Axlsx::Workbook
  • - #initialize + #initialize - Axlsx::Font + Axlsx::NumFmt
  • @@ -1489,105 +1505,105 @@
  • - #initialize + #initialize - Axlsx::Pie3DChart + Axlsx::Title
  • - #initialize + #initialize - Axlsx::Series + Axlsx::Worksheet
  • - #initialize + #initialize - Axlsx::View3D + Axlsx::GraphicFrame
  • - #initialize + #initialize - Axlsx::SerAxis + Axlsx::Font
  • - #initialize + #initialize - Axlsx::Relationship + Axlsx::Styles
  • - #initialize + #initialize - Axlsx::Worksheet + Axlsx::ValAxis
  • - #initialize + #initialize - Axlsx::Bar3DChart + Axlsx::PieSeries
  • - #initialize + #initialize - Axlsx::Default + Axlsx::Cell
  • - #initialize + #initialize - Axlsx::CatAxis + Axlsx::LineSeries
  • - #initialize + #initialize - Axlsx::Relationships + Axlsx::Override
  • - #initialize + #initialize - Axlsx::BarSeries + Axlsx::BorderPr
  • - #initialize + #initialize - Axlsx::TableStyleElement + Axlsx::ContentType
  • - #initialize + #initialize - Axlsx::Axis + Axlsx::Line3DChart
  • @@ -1609,17 +1625,17 @@
  • - #labels + #labels - Axlsx::PieSeries + Axlsx::BarSeries
  • - #labels + #labels - Axlsx::BarSeries + Axlsx::PieSeries
  • @@ -1713,25 +1729,25 @@
  • - #name + #name - Axlsx::Font + Axlsx::TableStyle
  • - #name + #name - Axlsx::Worksheet + Axlsx::Font
  • - #name + #name - Axlsx::TableStyle + Axlsx::Worksheet
  • @@ -1929,25 +1945,25 @@
  • - #rId + #rId - Axlsx::Worksheet + Axlsx::Drawing
  • - #rId + #rId - Axlsx::Drawing + Axlsx::GraphicFrame
  • - #rId + #rId - Axlsx::GraphicFrame + Axlsx::Worksheet
  • @@ -1977,9 +1993,9 @@
  • - #relationships + #relationships - Axlsx::Workbook + Axlsx::Worksheet
  • @@ -1993,9 +2009,9 @@
  • - #relationships + #relationships - Axlsx::Worksheet + Axlsx::Workbook
  • @@ -2017,17 +2033,17 @@
  • - #rels_pn + #rels_pn - Axlsx::Worksheet + Axlsx::Drawing
  • - #rels_pn + #rels_pn - Axlsx::Drawing + Axlsx::Worksheet
  • @@ -2193,14 +2209,6 @@
  • - #start_at - - Axlsx::TwoCellAnchor - -
  • - - -
  • #start_at Axlsx::Chart @@ -2208,7 +2216,7 @@
  • -
  • +
  • #stop Axlsx::GradientFill @@ -2216,7 +2224,7 @@
  • -
  • +
  • #strike Axlsx::Font @@ -2224,14 +2232,6 @@
  • -
  • - #style - - Axlsx::Chart - -
  • - -
  • #style @@ -2249,6 +2249,14 @@
  • + #style + + Axlsx::Chart + +
  • + + +
  • #styles Axlsx::Workbook @@ -2256,7 +2264,7 @@
  • -
  • +
  • #sz Axlsx::Font @@ -2264,7 +2272,7 @@
  • -
  • +
  • #table Axlsx::TableStyle @@ -2272,7 +2280,7 @@
  • -
  • +
  • #tableStyles Axlsx::Styles @@ -2280,7 +2288,7 @@
  • -
  • +
  • #text Axlsx::Title @@ -2288,7 +2296,7 @@
  • -
  • +
  • #textRotation Axlsx::CellAlignment @@ -2296,7 +2304,7 @@
  • -
  • +
  • #tickLblPos Axlsx::Axis @@ -2304,442 +2312,466 @@
  • +
  • + #tickLblSkip + + Axlsx::SerAxis + +
  • + + +
  • + #tickMarkSkip + + Axlsx::SerAxis + +
  • + + +
  • + #tint + + Axlsx::Color + +
  • + +
  • - #tickLblSkip + #title - Axlsx::SerAxis + Axlsx::Chart
  • - #tickMarkSkip + #title - Axlsx::SerAxis + Axlsx::Series
  • - #tint + #to - Axlsx::Color + Axlsx::Chart
  • - #title + #to - Axlsx::Chart + Axlsx::TwoCellAnchor
  • - #title + #to_xml - Axlsx::Series + Axlsx::SimpleTypedList
  • - #to + #to_xml - Axlsx::TwoCellAnchor + Axlsx::Drawing
  • - #to_xml + #to_xml - Axlsx::Xf + Axlsx::Relationship
  • - #to_xml + #to_xml - Axlsx::Line3DChart + Axlsx::CellStyle
  • - #to_xml + #to_xml - Axlsx::Styles + Axlsx::View3D
  • - #to_xml + #to_xml - Axlsx::Relationship + Axlsx::Bar3DChart
  • - #to_xml + #to_xml - Axlsx::Workbook + Axlsx::Fill
  • - #to_xml + #to_xml - Axlsx::GraphicFrame + Axlsx::Default
  • - #to_xml + #to_xml - Axlsx::Cell + Axlsx::App
  • - #to_xml + #to_xml - Axlsx::Override + Axlsx::Core
  • - #to_xml + #to_xml - Axlsx::Color + Axlsx::Row
  • - #to_xml + #to_xml - Axlsx::GradientFill + Axlsx::Axis
  • - #to_xml + #to_xml - Axlsx::Font + Axlsx::BorderPr
  • - #to_xml + #to_xml - Axlsx::View3D + Axlsx::Relationships
  • - #to_xml + #to_xml - Axlsx::GradientStop + Axlsx::Series
  • - #to_xml + #to_xml - Axlsx::CellAlignment + Axlsx::Override
  • - #to_xml + #to_xml - Axlsx::TableStyleElement + Axlsx::PatternFill
  • - #to_xml + #to_xml - Axlsx::BorderPr + Axlsx::TableStyle
  • - #to_xml + #to_xml - Axlsx::Bar3DChart + Axlsx::GraphicFrame
  • - #to_xml + #to_xml - Axlsx::SimpleTypedList + Axlsx::Font
  • - #to_xml + #to_xml - Axlsx::Row + Axlsx::BarSeries
  • - #to_xml + #to_xml - Axlsx::CatAxis + Axlsx::Worksheet
  • - #to_xml + #to_xml - Axlsx::Fill + Axlsx::Pie3DChart
  • - #to_xml + #to_xml - Axlsx::CellProtection + Axlsx::SeriesTitle
  • - #to_xml + #to_xml - Axlsx::Chart + Axlsx::TableStyles
  • - #to_xml + #to_xml - Axlsx::Relationships + Axlsx::ContentType
  • - #to_xml + #to_xml - Axlsx::Marker + Axlsx::ValAxisData
  • - #to_xml + #to_xml - Axlsx::Worksheet + Axlsx::GradientFill
  • - #to_xml + #to_xml - Axlsx::Title + Axlsx::Line3DChart
  • - #to_xml + #to_xml - Axlsx::PatternFill + Axlsx::LineSeries
  • - #to_xml + #to_xml - Axlsx::TableStyles + Axlsx::ValAxis
  • - #to_xml + #to_xml - Axlsx::Axis + Axlsx::Chart
  • - #to_xml + #to_xml - Axlsx::NumFmt + Axlsx::TwoCellAnchor
  • - #to_xml + #to_xml - Axlsx::Series + Axlsx::Workbook
  • - #to_xml + #to_xml - Axlsx::SerAxis + Axlsx::CellAlignment
  • - #to_xml + #to_xml - Axlsx::Pie3DChart + Axlsx::Scaling
  • - #to_xml + #to_xml - Axlsx::Drawing + Axlsx::Title
  • - #to_xml + #to_xml - Axlsx::App + Axlsx::Cell
  • - #to_xml + #to_xml - Axlsx::Border + Axlsx::CatAxisData
  • - #to_xml + #to_xml - Axlsx::Scaling + Axlsx::Marker
  • - #to_xml + #to_xml - Axlsx::TableStyle + Axlsx::GradientStop
  • - #to_xml + #to_xml - Axlsx::ValAxis + Axlsx::CellProtection
  • - #to_xml + #to_xml - Axlsx::Default + Axlsx::SerAxis
  • - #to_xml + #to_xml - Axlsx::LineSeries + Axlsx::Styles
  • - #to_xml + #to_xml - Axlsx::CellStyle + Axlsx::PieSeries
  • - #to_xml + #to_xml - Axlsx::SeriesTitle + Axlsx::CatAxis
  • - #to_xml + #to_xml - Axlsx::BarSeries + Axlsx::Xf
  • - #to_xml + #to_xml - Axlsx::TwoCellAnchor + Axlsx::NumFmt
  • - #to_xml + #to_xml - Axlsx::ContentType + Axlsx::Color
  • - #to_xml + #to_xml - Axlsx::Core + Axlsx::TableStyleElement
  • - #to_xml + #to_xml - Axlsx::PieSeries + Axlsx::Border
  • @@ -2761,17 +2793,17 @@
  • - #type + #type - Axlsx::Cell + Axlsx::TableStyleElement
  • - #type + #type - Axlsx::TableStyleElement + Axlsx::Cell
  • @@ -2809,9 +2841,9 @@
  • - validate + #validate - Axlsx::DataTypeValidator + Axlsx::Package
  • @@ -2833,9 +2865,9 @@
  • - #validate + validate - Axlsx::Package + Axlsx::DataTypeValidator
  • @@ -2969,33 +3001,33 @@
  • - #workbook + #workbook - Axlsx::Package + Axlsx::Worksheet
  • - #workbook + #workbook - Axlsx::Worksheet + Axlsx::Package
  • - #worksheet + #worksheet - Axlsx::Drawing + Axlsx::Row
  • - #worksheet + #worksheet - Axlsx::Row + Axlsx::Drawing
  • @@ -3017,17 +3049,17 @@
  • - #xfId + #xfId - Axlsx::CellStyle + Axlsx::Xf
  • - #xfId + #xfId - Axlsx::Xf + Axlsx::CellStyle
  • diff --git a/doc/top-level-namespace.html b/doc/top-level-namespace.html index 8b0754bc..da01b08a 100644 --- a/doc/top-level-namespace.html +++ b/doc/top-level-namespace.html @@ -94,7 +94,7 @@ diff --git a/examples/example.rb b/examples/example.rb index fd889556..cb405fe2 100644 --- a/examples/example.rb +++ b/examples/example.rb @@ -59,6 +59,7 @@ p.serialize("example5.xlsx") #Validation + p = Axlsx::Package.new p.workbook.add_worksheet do |sheet| sheet.add_row ["First", "Second", "Third"] @@ -75,7 +76,9 @@ p.workbook.add_worksheet do |sheet| sheet.add_row ["First", 1, 5, 7, 9] sheet.add_row ["Second", 5, 2, 14, 9] - sheet.add_chart(Axlsx::Line3DChart, :start_at => [0,2], :end_at => [10, 15], :title=>"example 6: Line Chart") do |chart| + sheet.add_chart(Axlsx::Line3DChart, :title=>"example 6: Line Chart") do |chart| + chart.start_at 0, 2 + chart.end_at 10, 15 chart.add_series :data=>sheet.rows.first.cells[(1..-1)], :title=> sheet.rows.first.cells.first chart.add_series :data=>sheet.rows.last.cells[(1..-1)], :title=> sheet.rows.last.cells.first end diff --git a/lib/axlsx/drawing/axis.rb b/lib/axlsx/drawing/axis.rb index facc2a67..7e48801a 100644 --- a/lib/axlsx/drawing/axis.rb +++ b/lib/axlsx/drawing/axis.rb @@ -1,9 +1,8 @@ module Axlsx - # the access class defines common properties and values for chart axis + # the access class defines common properties and values for a chart axis. class Axis - - # the id of the axis + # the id of the axis. # @return [Integer] attr_reader :axId @@ -12,6 +11,7 @@ module Axlsx attr_reader :crossAx # The scaling of the axis + # @see Scaling # @return [Scaling] attr_reader :scaling @@ -25,8 +25,8 @@ module Axlsx # @return [Symbol] attr_accessor :tickLblPos - # The number format format code for this axis + # default :General # @return [String] attr_accessor :format_code @@ -41,15 +41,16 @@ module Axlsx # @option options [Symbol] axPos # @option options [Symbol] crosses # @option options [Symbol] tickLblPos + # @raise [ArgumentError] If axId or crossAx are not unsigned integers def initialize(axId, crossAx, options={}) Axlsx::validate_unsigned_int(axId) Axlsx::validate_unsigned_int(crossAx) @axId = axId @crossAx = crossAx + @scaling = Scaling.new(:orientation=>:minMax) self.axPos = :l self.tickLblPos = :nextTo - @scaling = Scaling.new(:orientation=>:minMax) - @formatCode = "" + self.format_code = "General" self.crosses = :autoZero options.each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" diff --git a/lib/axlsx/drawing/bar_3D_chart.rb b/lib/axlsx/drawing/bar_3D_chart.rb index 1d7e2bba..3d7f6296 100644 --- a/lib/axlsx/drawing/bar_3D_chart.rb +++ b/lib/axlsx/drawing/bar_3D_chart.rb @@ -1,43 +1,17 @@ module Axlsx # The Bar3DChart is a three dimentional barchart (who would have guessed?) that you can add to your worksheet. - # @example Creating a chart - # # This example creates two charts in a single sheet. - # # The first uses data directly fed to the sheet, while the second references cells withing the worksheet for data. - # - # require "rubygems" # if that is your preferred way to manage gems! - # require "axlsx" - # - # p = Axlsx::Package.new - # ws = p.workbook.add_worksheet - # ws.add_row :values => ["This is a chart with no data in the sheet"] - # - # chart = ws.add_chart(Axlsx::Bar3DChart, :start_at=> [0,1], :end_at=>[0,6], :title=>"Most Popular Pets") - # chart.add_series :data => [1, 9, 10], :labels => ["Slimy Reptiles", "Fuzzy Bunnies", "Rottweiler"] - # - # ws.add_row :values => ["This chart uses the data below"] - # title_row = ws.add_row :values => ["Least Popular Pets"] - # label_row = ws.add_row :values => ["", "Dry Skinned Reptiles", "Bald Cats", "Violent Parrots"] - # data_row = ws.add_row :values => ["Votes", 6, 4, 1] - # - # chart = ws.add_chart(Axlsx::Pie3DChart, :start_at => [0,11], :end_at =>[0,16], :title => title_row.cells.last) - # chart.add_series :data => data_row.cells[(1..-1)], :labels => label_row.cells - # - # f = File.open('example_pie_3d_chart.xlsx', 'w') - # p.serialize(f) - # # @see Worksheet#add_chart - # @see Worksheet#add_row # @see Chart#add_series - # @see Series # @see Package#serialize + # @see README for an example class Bar3DChart < Chart # the category axis # @return [CatAxis] attr_reader :catAxis - # the category axis + # the valueaxis # @return [ValAxis] attr_reader :valAxis @@ -60,7 +34,7 @@ module Axlsx attr_accessor :grouping # The shabe of the bars or columns - # must be one of [:percentStacked, :clustered, :standard, :stacked] + # must be one of [:cone, :coneToMax, :box, :cylinder, :pyramid, :pyramidToMax] # @return [Symbol] attr_accessor :shape @@ -76,6 +50,14 @@ module Axlsx # @option options [String] gapWidth # @option options [String] gapDepth # @option options [Symbol] shape + # @option options [Integer] rotX + # @option options [String] hPercent + # @option options [Integer] rotY + # @option options [String] depthPercent + # @option options [Boolean] rAngAx + # @option options [Integer] perspective + # @see Chart + # @see View3D def initialize(frame, options={}) @barDir = :bar @grouping = :clustered @@ -83,9 +65,9 @@ module Axlsx @valAxId = rand(8 ** 8) @catAxis = CatAxis.new(@catAxId, @valAxId) @valAxis = ValAxis.new(@valAxId, @catAxId) - @view3D = View3D.new(:rAngAx=>1) super(frame, options) @series_type = BarSeries + @view3D = View3D.new({:rAngAx=>1}.merge(options)) end def barDir=(v) diff --git a/lib/axlsx/drawing/bar_series.rb b/lib/axlsx/drawing/bar_series.rb index 0f46af15..5e10eb0e 100644 --- a/lib/axlsx/drawing/bar_series.rb +++ b/lib/axlsx/drawing/bar_series.rb @@ -28,8 +28,8 @@ module Axlsx def initialize(chart, options={}) @shape = :box super(chart, options) - self.data = options[:data] || [] - self.labels = options[:labels] || [] + self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil? + self.data = ValAxisData.new(options[:data]) unless options[:data].nil? end def shape=(v) @@ -42,37 +42,8 @@ module Axlsx # @return [String] def to_xml(xml) super(xml) do |xml| - if !labels.empty? - xml.send('c:cat') { - xml.send('c:strRef') { - xml.send('c:f', Axlsx::cell_range(labels)) - xml.send('c:strCache') { - xml.send('c:ptCount', :val=>labels.size) - labels.each_with_index do |cell, index| - v = cell.is_a?(Cell) ? cell.value : cell - xml.send('c:pt', :idx=>index) { - xml.send('c:v', v) - } - end - } - } - } - end - xml.send('c:val') { - xml.send('c:numRef') { - xml.send('c:f', Axlsx::cell_range(data)) - xml.send('c:numCache') { - xml.send('c:formatCode', 'General') - xml.send('c:ptCount', :val=>data.size) - data.each_with_index do |cell, index| - v = cell.is_a?(Cell) ? cell.value : cell - xml.send('c:pt', :idx=>index) { - xml.send('c:v', v) - } - end - } - } - } + @labels.to_xml(xml) unless @labels.nil? + @data.to_xml(xml) unless @data.nil? xml.send('c:shape', :val=>@shape) end end @@ -82,10 +53,10 @@ module Axlsx # assigns the data for this series - def data=(v) DataTypeValidator.validate "Series.data", [Array, SimpleTypedList], v; @data = v; end + def data=(v) DataTypeValidator.validate "Series.data", [SimpleTypedList], v; @data = v; end # assigns the labels for this series - def labels=(v) DataTypeValidator.validate "Series.labels", [Array, SimpleTypedList], v; @labels = v; end + def labels=(v) DataTypeValidator.validate "Series.labels", [SimpleTypedList], v; @labels = v; end end diff --git a/lib/axlsx/drawing/cat_axis.rb b/lib/axlsx/drawing/cat_axis.rb index f2458ffc..083eac68 100644 --- a/lib/axlsx/drawing/cat_axis.rb +++ b/lib/axlsx/drawing/cat_axis.rb @@ -1,6 +1,7 @@ module Axlsx #A CatAxis object defines a chart category axis class CatAxis < Axis + # 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. # @return [Boolean] attr_accessor :auto @@ -18,23 +19,20 @@ module Axlsx # regex for validating label offset LBL_OFFSET_REGEX = /0*(([0-9])|([1-9][0-9])|([1-9][0-9][0-9])|1000)%/ - # Creates a new CatAxis object - # @param [Integer] axId the id of this axis - # @param [Integer] crossAx the id of the perpendicular axis - # @option options [Symbol] axPos - # @option options [Symbol] tickLblPos - # @option options [Symbol] crosses + # Creates a new CatAxis object + # @param [Integer] axId the id of this axis. Inherited + # @param [Integer] crossAx the id of the perpendicular axis. Inherited + # @option options [Symbol] axPos. Inherited + # @option options [Symbol] tickLblPos. Inherited + # @option options [Symbol] crosses. Inherited # @option options [Boolean] auto # @option options [Symbol] lblAlgn # @option options [Integer] lblOffset def initialize(axId, crossAx, options={}) - super(axId, crossAx, options) self.auto = true self.lblAlgn = :ctr self.lblOffset = "100%" - options.each do |o| - self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" - end + super(axId, crossAx, options) end def auto=(v) Axlsx::validate_boolean(v); @auto = v; end diff --git a/lib/axlsx/drawing/cat_axis_data.rb b/lib/axlsx/drawing/cat_axis_data.rb new file mode 100644 index 00000000..83dfa56e --- /dev/null +++ b/lib/axlsx/drawing/cat_axis_data.rb @@ -0,0 +1,34 @@ +module Axlsx + # The CatAxisData class serializes the category axis data for a chart + class CatAxisData < SimpleTypedList + + # Create a new CatAxisData object + # @param [Array, SimpleTypedList] data the data for this category axis. This can be a simple array or a simple typed list of cells. + def initialize(data=[]) + super Object + @list.concat data if data.is_a?(Array) + end + + # Serializes the category axis data + # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. + # @return [String] + def to_xml(xml) + xml.send('c:cat') { + xml.send('c:strRef') { + xml.send('c:f', Axlsx::cell_range(@list)) + xml.send('c:strCache') { + xml.send('c:ptCount', :val=>size) + each_with_index do |item, index| + v = item.is_a?(Cell) ? item.value : item + xml.send('c:pt', :idx=>index) { + xml.send('c:v', v) + } + end + } + } + } + end + + end + +end diff --git a/lib/axlsx/drawing/chart.rb b/lib/axlsx/drawing/chart.rb index 315d9499..bf4a1bff 100644 --- a/lib/axlsx/drawing/chart.rb +++ b/lib/axlsx/drawing/chart.rb @@ -2,19 +2,12 @@ module Axlsx # A Chart is the superclass for specific charts # @note Worksheet#add_chart is the recommended way to create charts for your worksheets. + # @see README for examples class Chart - # The title object for the chart. - # @return [Title] - attr_accessor :title - - # The style for the chart. - # see ECMA Part 1 §21.2.2.196 - # @return [Integer] - attr_accessor :style # The 3D view properties for the chart - attr_accessor :view3D + attr_reader :view3D # A reference to the graphic frame that owns this chart # @return [GraphicFrame] @@ -24,7 +17,7 @@ module Axlsx # @return [SimpleTypedList] attr_reader :series - # The type of series to use for this chart + # The type of series to use for this chart. # @return [Series] attr_reader :series_type @@ -39,13 +32,14 @@ module Axlsx #TODO data labels! #attr_accessor :dLabls - # The starting marker for this chart - # @return [Marker] - attr_reader :start_at + # The title object for the chart. + # @return [Title] + attr_accessor :title - # The ending marker for this chart - # @return [Marker] - attr_reader :end_at + # The style for the chart. + # see ECMA Part 1 §21.2.2.196 + # @return [Integer] + attr_accessor :style # Show the legend in the chart # @return [Boolean] @@ -65,6 +59,8 @@ module Axlsx options.each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end + start_at *options[:start_at] if options[:start_at] + end_at *options[:end_at] if options[:start_at] yield self if block_given? end @@ -76,8 +72,6 @@ module Axlsx "#{CHART_PN % (index+1)}" end - def view3D=(v) DataTypeValidator.validate "#{self.class}.view3D", View3D, v; @view3D = v; end - def title=(v) v = Title.new(v) if v.is_a?(String) || v.is_a?(Cell) DataTypeValidator.validate "#{self.class}.title", Title, v @@ -88,6 +82,19 @@ module Axlsx def style=(v) DataTypeValidator.validate "Chart.style", Integer, v, lambda { |v| v >= 1 && v <= 48 }; @style = v; end + # backwards compatibility to allow chart.to and chart.from access to anchor markers + # @note This will be disconinued in version 2.0.0. Please use the end_at method + def to + @graphic_frame.anchor.to + end + + # backwards compatibility to allow chart.to and chart.from access to anchor markers + # @note This will be disconinued in version 2.0.0. please use the start_at method + # + def from + @graphic_frame.anchor.from + end + # Adds a new series to the chart's series collection. # @return [Series] # @see Series @@ -122,10 +129,30 @@ module Axlsx builder.to_xml end + # This is a short cut method to set the start anchor position + # If you need finer granularity in positioning use + # graphic_frame.anchor.from.colOff / rowOff + # @param [Integer] x The column + # @param [Integer] y The row + # @return [Marker] + def start_at(x, y) + @graphic_frame.anchor.from.col = x + @graphic_frame.anchor.from.row = y + end + + # This is a short cut method to set the end anchor position + # If you need finer granularity in positioning use + # graphic_frame.anchor.to.colOff / rowOff + # @param [Integer] x The column + # @param [Integer] y The row + # @return [Marker] + def end_at(x, y) + @graphic_frame.anchor.to.col = x + @graphic_frame.anchor.to.row = y + end + private - - def start_at=(v) DataTypeValidator.validate "#{self.class}.start_at", Marker, v; @start_at = v; end - def end_at=(v) DataTypeValidator.validate "#{self.class}.end_at", Marker, v; @end_at = v; end + def view3D=(v) DataTypeValidator.validate "#{self.class}.view3D", View3D, v; @view3D = v; end end end diff --git a/lib/axlsx/drawing/drawing.rb b/lib/axlsx/drawing/drawing.rb index 83902143..385cd592 100644 --- a/lib/axlsx/drawing/drawing.rb +++ b/lib/axlsx/drawing/drawing.rb @@ -6,35 +6,39 @@ module Axlsx require 'axlsx/drawing/bar_series.rb' require 'axlsx/drawing/line_series.rb' + require 'axlsx/drawing/scaling.rb' require 'axlsx/drawing/axis.rb' require 'axlsx/drawing/ser_axis.rb' require 'axlsx/drawing/cat_axis.rb' require 'axlsx/drawing/val_axis.rb' - require 'axlsx/drawing/view_3D.rb' - require 'axlsx/drawing/scaling.rb' - require 'axlsx/drawing/graphic_frame.rb' + require 'axlsx/drawing/cat_axis_data.rb' + require 'axlsx/drawing/val_axis_data.rb' + require 'axlsx/drawing/marker.rb' require 'axlsx/drawing/two_cell_anchor.rb' + require 'axlsx/drawing/graphic_frame.rb' + require 'axlsx/drawing/view_3D.rb' require 'axlsx/drawing/chart.rb' require 'axlsx/drawing/pie_3D_chart.rb' require 'axlsx/drawing/bar_3D_chart.rb' require 'axlsx/drawing/line_3D_chart.rb' - # A Drawing is a canvas for charts. Each worksheet has a single drawing that can specify multiple anchors which reference charts. - # @note The recommended way to manage drawings is to use the Worksheet.add_chart method, specifying the chart class, start and end marker locations. + # A Drawing is a canvas for charts. Each worksheet has a single drawing that manages anchors. + # The anchors reference the charts via graphical frames. This is not a trivial relationship so please do follow the advice in the note. + # @note The recommended way to manage drawings is to use the Worksheet.add_chart method. # @see Worksheet#add_chart - # @see TwoCellAnchor # @see Chart + # see README for an example of how to create a chart. class Drawing # The worksheet that owns the drawing # @return [Worksheet] attr_reader :worksheet - # A collection of anchors for this drawing + # only TwoCellAnchors are supported in this version # @return [SimpleTypedList] attr_reader :anchors @@ -72,12 +76,10 @@ module Axlsx end - # Adds a chart to the drawing. - # @note The recommended way to manage charts is to use Worksheet.add_chart. - # @param [Chart] chart_type The class of the chart to be added to the drawing - # @param [Hash] options + # Adds a chart to the drawing. + # @note The recommended way to manage charts is to use Worksheet.add_chart. Please refer to that method for documentation. + # @see Worksheet#add_chart def add_chart(chart_type, options={}) - DataTypeValidator.validate "Drawing.chart_type", Chart, chart_type TwoCellAnchor.new(self, chart_type, options) @anchors.last.graphic_frame.chart end diff --git a/lib/axlsx/drawing/graphic_frame.rb b/lib/axlsx/drawing/graphic_frame.rb index 3fe71976..5e09fb8a 100644 --- a/lib/axlsx/drawing/graphic_frame.rb +++ b/lib/axlsx/drawing/graphic_frame.rb @@ -22,6 +22,7 @@ module Axlsx # @param [TwoCellAnchor] anchor # @param [Class] chart_type def initialize(anchor, chart_type, options) + DataTypeValidator.validate "Drawing.chart_type", Chart, chart_type @anchor = anchor @chart = chart_type.new(self, options) end diff --git a/lib/axlsx/drawing/line_3D_chart.rb b/lib/axlsx/drawing/line_3D_chart.rb index 39500f75..6fb34afb 100644 --- a/lib/axlsx/drawing/line_3D_chart.rb +++ b/lib/axlsx/drawing/line_3D_chart.rb @@ -46,8 +46,18 @@ module Axlsx # Creates a new line chart object # @param [GraphicFrame] frame The workbook that owns this chart. + # @option options [Cell, String] title + # @option options [Boolean] show_legend # @option options [Symbol] grouping # @option options [String] gapDepth + # @option options [Integer] rotX + # @option options [String] hPercent + # @option options [Integer] rotY + # @option options [String] depthPercent + # @option options [Boolean] rAngAx + # @option options [Integer] perspective + # @see Chart + # @see View3D def initialize(frame, options={}) @grouping = :standard @catAxId = rand(8 ** 8) @@ -56,9 +66,9 @@ module Axlsx @catAxis = CatAxis.new(@catAxId, @valAxId) @valAxis = ValAxis.new(@valAxId, @catAxId) @serAxis = SerAxis.new(@serAxId, @valAxId) - @view3D = View3D.new(:perspective=>30) super(frame, options) @series_type = LineSeries + @view3D = View3D.new({:perspective=>30}.merge(options)) end def grouping=(v) diff --git a/lib/axlsx/drawing/line_series.rb b/lib/axlsx/drawing/line_series.rb index db509d38..eea1e0ee 100644 --- a/lib/axlsx/drawing/line_series.rb +++ b/lib/axlsx/drawing/line_series.rb @@ -6,11 +6,11 @@ module Axlsx class LineSeries < Series # The data for this series. - # @return [Array, SimpleTypedList] + # @return [ValAxisData] attr_reader :data # The labels for this series. - # @return [Array, SimpleTypedList] + # @return [CatAxisData] attr_reader :labels # Creates a new series @@ -19,58 +19,28 @@ module Axlsx # @param [Chart] chart def initialize(chart, options={}) super(chart, options) - self.data = options[:data] || [] - self.labels = options[:labels] || [] + self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil? + self.data = ValAxisData.new(options[:data]) unless options[:data].nil? end # Serializes the series # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. # @return [String] + # TODO create series_cat and series_val classes as this serialization is duplicated def to_xml(xml) super(xml) do |xml| - if !labels.empty? - xml.send('c:cat') { - xml.send('c:strRef') { - xml.send('c:f', Axlsx::cell_range(labels)) - xml.send('c:strCache') { - xml.send('c:ptCount', :val=>labels.size) - labels.each_with_index do |cell, index| - v = cell.is_a?(Cell) ? cell.value : cell - xml.send('c:pt', :idx=>index) { - xml.send('c:v', v) - } - end - } - } - } - end - xml.send('c:val') { - xml.send('c:numRef') { - xml.send('c:f', Axlsx::cell_range(data)) - xml.send('c:numCache') { - xml.send('c:formatCode', 'General') - xml.send('c:ptCount', :val=>data.size) - data.each_with_index do |cell, index| - v = cell.is_a?(Cell) ? cell.value : cell - xml.send('c:pt', :idx=>index) { - xml.send('c:v', v) - } - end - } - } - } + @labels.to_xml(xml) unless @labels.nil? + @data.to_xml(xml) unless @data.nil? end end - - private + private # assigns the data for this series - def data=(v) DataTypeValidator.validate "Series.data", [Array, SimpleTypedList], v; @data = v; end + def data=(v) DataTypeValidator.validate "Series.data", [SimpleTypedList], v; @data = v; end # assigns the labels for this series - def labels=(v) DataTypeValidator.validate "Series.labels", [Array, SimpleTypedList], v; @labels = v; end + def labels=(v) DataTypeValidator.validate "Series.labels", [SimpleTypedList], v; @labels = v; end end - end diff --git a/lib/axlsx/drawing/pie_3D_chart.rb b/lib/axlsx/drawing/pie_3D_chart.rb index cf835bfd..dacba313 100644 --- a/lib/axlsx/drawing/pie_3D_chart.rb +++ b/lib/axlsx/drawing/pie_3D_chart.rb @@ -2,47 +2,30 @@ module Axlsx # The Pie3DChart is a three dimentional piechart (who would have guessed?) that you can add to your worksheet. - # @example Creating a chart - # # This example creates two charts in a single sheet. - # # The first uses data directly fed to the sheet, while the second references cells withing the worksheet for data. - # - # require "rubygems" # if that is your preferred way to manage gems! - # require "axlsx" - # - # p = Axlsx::Package.new - # ws = p.workbook.add_worksheet - # ws.add_row :values => ["This is a chart with no data in the sheet"] - # - # chart = ws.add_chart(Axlsx::Pie3DChart, :start_at=> [0,1], :end_at=>[0,6], :title=>"Most Popular Pets") - # chart.add_series :data => [1, 9, 10], :labels => ["Slimy Reptiles", "Fuzzy Bunnies", "Rottweiler"] - # - # ws.add_row :values => ["This chart uses the data below"] - # title_row = ws.add_row :values => ["Least Popular Pets"] - # label_row = ws.add_row :values => ["", "Dry Skinned Reptiles", "Bald Cats", "Violent Parrots"] - # data_row = ws.add_row :values => ["Votes", 6, 4, 1] - # - # chart = ws.add_chart(Axlsx::Pie3DChart, :start_at => [0,11], :end_at =>[0,16], :title => title_row.cells.last) - # chart.add_series :data => data_row.cells[(1..-1)], :labels => label_row.cells - # - # f = File.open('example_pie_3d_chart.xlsx', 'w') - # p.serialize(f) - # # @see Worksheet#add_chart - # @see Worksheet#add_row # @see Chart#add_series - # @see Series - # @see Package#serialize + # @see README for an example class Pie3DChart < Chart - # Creates a new pie chart object - # @param [Workbook] workbook The workbook that owns this chart. + # @param [GraphicFrame] frame The workbook that owns this chart. # @option options [Cell, String] title - def initialize(workbook, options={}) - # this charts series type - super(workbook, options) + # @option options [Boolean] show_legend + # @option options [Symbol] grouping + # @option options [String] gapDepth + # @option options [Integer] rotX + # @option options [String] hPercent + # @option options [Integer] rotY + # @option options [String] depthPercent + # @option options [Boolean] rAngAx + # @option options [Integer] perspective + # @see Chart + # @see View3D + def initialize(frame, options={}) + super(frame, options) @series_type = PieSeries - @view3D = View3D.new(:rotX => 30, :perspective => 30) + @view3D = View3D.new({:rotX=>30, :perspective=>30}.merge(options)) + end # Serializes the pie chart diff --git a/lib/axlsx/drawing/pie_series.rb b/lib/axlsx/drawing/pie_series.rb index 98b61728..1f20058d 100644 --- a/lib/axlsx/drawing/pie_series.rb +++ b/lib/axlsx/drawing/pie_series.rb @@ -1,22 +1,20 @@ module Axlsx - # A PieSeries defines the title, data and labels for pie charts + # A PieSeries defines the data and labels and explosion for pie charts series. # @note The recommended way to manage series is to use Chart#add_series # @see Worksheet#add_chart # @see Chart#add_series class PieSeries < Series # The data for this series. - # @return [Array, SimpleTypedList] + # @return [SimpleTypedList] attr_reader :data - # The labels for this series. - # @return [Array, SimpleTypedList] + # @return [SimpleTypedList] attr_reader :labels - # The explosion for this series - # @return [Array, SimpleTypedList] + # @return [Integert] attr_accessor :explosion # Creates a new series @@ -27,61 +25,29 @@ module Axlsx # @param [Chart] chart def initialize(chart, options={}) super(chart, options) - self.data = options[:data] || [] - self.labels = options[:labels] || [] + self.labels = CatAxisData.new(options[:labels]) unless options[:labels].nil? + self.data = ValAxisData.new(options[:data]) unless options[:data].nil? end def explosion=(v) Axlsx::validate_unsigned_int(v); @explosion = v; end + # Serializes the series # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. # @return [String] def to_xml(xml) super(xml) do |xml| xml.send('c:explosion', :val=>@explosion) unless @explosion.nil? - if !labels.empty? - xml.send('c:cat') { - xml.send('c:strRef') { - xml.send('c:f', Axlsx::cell_range(labels)) - xml.send('c:strCache') { - xml.send('c:ptCount', :val=>labels.size) - labels.each_with_index do |cell, index| - v = cell.is_a?(Cell) ? cell.value : cell - xml.send('c:pt', :idx=>index) { - xml.send('c:v', v) - } - end - } - } - } - end - xml.send('c:val') { - xml.send('c:numRef') { - xml.send('c:f', Axlsx::cell_range(data)) - xml.send('c:numCache') { - xml.send('c:formatCode', 'General') - xml.send('c:ptCount', :val=>data.size) - data.each_with_index do |cell, index| - v = cell.is_a?(Cell) ? cell.value : cell - xml.send('c:pt', :idx=>index) { - xml.send('c:v', v) - } - end - } - } - } - + @labels.to_xml(xml) unless @labels.nil? + @data.to_xml(xml) unless @data.nil? end end - - private - # assigns the data for this series - def data=(v) DataTypeValidator.validate "Series.data", [Array, SimpleTypedList], v; @data = v; end + def data=(v) DataTypeValidator.validate "Series.data", [SimpleTypedList], v; @data = v; end # assigns the labels for this series - def labels=(v) DataTypeValidator.validate "Series.labels", [Array, SimpleTypedList], v; @labels = v; end + def labels=(v) DataTypeValidator.validate "Series.labels", [SimpleTypedList], v; @labels = v; end end diff --git a/lib/axlsx/drawing/ser_axis.rb b/lib/axlsx/drawing/ser_axis.rb index 091a7d64..a086b23c 100644 --- a/lib/axlsx/drawing/ser_axis.rb +++ b/lib/axlsx/drawing/ser_axis.rb @@ -1,30 +1,29 @@ module Axlsx - #A SarAxis object defines a series axis + #A SerAxis object defines a series axis class SerAxis < Axis - # @return [Boolean] + # The number of tick lables to skip between labels + # @return [Integer] attr_accessor :tickLblSkip + # The number of tickmarks to be skipped before the next one is rendered. # @return [Boolean] attr_accessor :tickMarkSkip # Creates a new SerAxis object - # @param [Integer] axId the id of this axis - # @param [Integer] crossAx the id of the perpendicular axis - # @option options [Symbol] axPos - # @option options [Symbol] tickLblPos - # @option options [Symbol] crosses - # @option options [Boolean] tickLblSkip - # @option options [Symbol] tickMarkSkip + # @param [Integer] axId the id of this axis. Inherited + # @param [Integer] crossAx the id of the perpendicular axis. Inherited + # @option options [Symbol] axPos. Inherited + # @option options [Symbol] tickLblPos. Inherited + # @option options [Symbol] crosses. Inherited + # @option options [Integer] tickLblSkip + # @option options [Integer] tickMarkSkip def initialize(axId, crossAx, options={}) super(axId, crossAx, options) - options.each do |o| - self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" - end end - def tickLblSkip=(v) Axlsx::validate_boolean(v); @tickLblSkip = v; end - def tickMarkSkip=(v) Axlsx::validate_boolean(v); @tickMarkSkip = v; end + def tickLblSkip=(v) Axlsx::validate_unsigned_int(v); @tickLblSkip = v; end + def tickMarkSkip=(v) Axlsx::validate_unsigned_int(v); @tickMarkSkip = v; end # Serializes the series axis # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. diff --git a/lib/axlsx/drawing/series.rb b/lib/axlsx/drawing/series.rb index 51957acc..cb5d6a8d 100644 --- a/lib/axlsx/drawing/series.rb +++ b/lib/axlsx/drawing/series.rb @@ -1,5 +1,5 @@ module Axlsx - # A Series defines the title, data and labels for chart data. + # A Series defines the common series attributes and is the super class for all concrete series types. # @note The recommended way to manage series is to use Chart#add_series # @see Worksheet#add_chart # @see Chart#add_series @@ -13,7 +13,7 @@ module Axlsx # @return [Integer] attr_reader :index - # The order of this series in the chart's series. + # The order of this series in the chart's series. By default the order is the index of the series. # @return [Integer] attr_accessor :order @@ -33,7 +33,6 @@ module Axlsx end end - # retrieves the series index in the chart's series collection def index @chart.series.index(self) end diff --git a/lib/axlsx/drawing/series_title.rb b/lib/axlsx/drawing/series_title.rb index 32b5b102..bfb1b56f 100644 --- a/lib/axlsx/drawing/series_title.rb +++ b/lib/axlsx/drawing/series_title.rb @@ -1,5 +1,5 @@ module Axlsx - # A series title is a Title with a slightly different serialization + # A series title is a Title with a slightly different serialization than chart titles. class SeriesTitle < Title # Serializes the series title diff --git a/lib/axlsx/drawing/two_cell_anchor.rb b/lib/axlsx/drawing/two_cell_anchor.rb index aa9c04aa..62491b8c 100644 --- a/lib/axlsx/drawing/two_cell_anchor.rb +++ b/lib/axlsx/drawing/two_cell_anchor.rb @@ -23,51 +23,24 @@ module Axlsx # @return [Integer] attr_reader :index - # Creates a new TwoCellAnchor object + # Creates a new TwoCellAnchor object and sets up a reference to the from and to markers in the + # graphic_frame's chart. That means that you can do stuff like + # c = worksheet.add_chart Axlsx::Chart + # c.start_at 5, 9 # @param [Drawing] drawing - # @param [Chart] chart - # @option options [Array] start_at - # @option options [Array] end_at + # @param [Class] chart_type This is passed to the graphic frame for instantiation. must be Chart or a subclass of Chart + # @option options [Array] start_at the col, row to start at + # @option options [Array] end_at the col, row to end at def initialize(drawing, chart_type, options) @drawing = drawing drawing.anchors << self - @from, @to = Marker.new, Marker.new(:col => 5, :row=>10) @graphic_frame = GraphicFrame.new(self, chart_type, options) - - self.start_at(options[:start_at][0], options[:start_at][1]) if options[:start_at].is_a?(Array) - self.end_at(options[:end_at][0], options[:end_at][1]) if options[:end_at].is_a?(Array) - # passing a reference to our start and end markers for convenience - # this lets us access the markers directly from the chart. - @graphic_frame.chart.send(:start_at=, @from) - @graphic_frame.chart.send(:end_at=, @to) end def index @drawing.anchors.index(self) end - - - # This is a short cut method to set the start anchor position - # @param [Integer] x The column - # @param [Integer] y The row - # @return [Marker] - def start_at(x, y) - @from.col = x - @from.row = y - @from - end - - # This is a short cut method to set the end anchor position - # @param [Integer] x The column - # @param [Integer] y The row - # @return [Marker] - def end_at(x, y) - @to.col = x - @to.row = y - @to - end - # Serializes the two cell anchor # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. # @return [String] @@ -84,5 +57,8 @@ module Axlsx xml.send('xdr:clientData') } end + + private + end end diff --git a/lib/axlsx/drawing/val_axis.rb b/lib/axlsx/drawing/val_axis.rb index fae6adec..10a070f6 100644 --- a/lib/axlsx/drawing/val_axis.rb +++ b/lib/axlsx/drawing/val_axis.rb @@ -2,7 +2,7 @@ module Axlsx # the ValAxis class defines a chart value axis. class ValAxis < Axis - # This element specifies whether the value axis crosses the category axis between categories. + # This element specifies how the value axis crosses the category axis. # must be one of [:between, :midCat] # @return [Symbol] attr_accessor :crossBetween @@ -11,17 +11,17 @@ module Axlsx # @param [Integer] axId the id of this axis # @param [Integer] crossAx the id of the perpendicular axis # @option options [Symbol] axPos - # @option options [Symbol] crosses # @option options [Symbol] tickLblPos + # @option options [Symbol] crosses # @option options [Symbol] crossesBetween def initialize(axId, crossAx, options={}) - @crossBetween = :between + self.crossBetween = :between super(axId, crossAx, options) end def crossBetween=(v) RestrictionValidator.validate "ValAxis.crossBetween", [:between, :midCat], v; @crossBetween = v; end - # Serializes the value axis + # Serializes the value axis # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. # @return [String] def to_xml(xml) diff --git a/lib/axlsx/drawing/val_axis_data.rb b/lib/axlsx/drawing/val_axis_data.rb new file mode 100644 index 00000000..6a24a1ef --- /dev/null +++ b/lib/axlsx/drawing/val_axis_data.rb @@ -0,0 +1,28 @@ +module Axlsx + # The ValAxisData class manages the values for a chart value series. + class ValAxisData < CatAxisData + + # Serializes the value axis data + # @param [Nokogiri::XML::Builder] xml The document builder instance this objects xml will be added to. + # @return [String] + def to_xml(xml) + xml.send('c:val') { + xml.send('c:numRef') { + xml.send('c:f', Axlsx::cell_range(@list)) + xml.send('c:numCache') { + xml.send('c:formatCode', 'General') + xml.send('c:ptCount', :val=>size) + each_with_index do |item, index| + v = item.is_a?(Cell) ? item.value : item + xml.send('c:pt', :idx=>index) { + xml.send('c:v', v) + } + end + } + } + } + end + + end + +end diff --git a/lib/axlsx/drawing/view_3D.rb b/lib/axlsx/drawing/view_3D.rb index 36a869cf..1065d778 100644 --- a/lib/axlsx/drawing/view_3D.rb +++ b/lib/axlsx/drawing/view_3D.rb @@ -1,6 +1,13 @@ module Axlsx # 3D attributes for a chart. class View3D + + # Validation for hPercent + H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/ + + # validation for depthPercent + DEPTH_PERCENT_REGEX = /0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)%/ + # x rotation for the chart # must be between -90 and 90 # @return [Integer] @@ -41,18 +48,17 @@ module Axlsx self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end end - - # Validation for hPercent - H_PERCENT_REGEX = /0*(([5-9])|([1-9][0-9])|([1-4][0-9][0-9])|500)%/ - - # validation for depthPercent - DEPTH_PERCENT_REGEX = /0*(([2-9][0-9])|([1-9][0-9][0-9])|(1[0-9][0-9][0-9])|2000)%/ def rotX=(v) DataTypeValidator.validate "#{self.class}.rotX", [Integer, Fixnum], v, lambda {|v| v >= -90 && v <= 90 }; @rotX = v; end + def hPercent=(v) RegexValidator.validate "#{self.class}.rotX", H_PERCENT_REGEX, v; @hPercent = v; end + def rotY=(v) DataTypeValidator.validate "#{self.class}.rotY", [Integer, Fixnum], v, lambda {|v| v >= 0 && v <= 360 }; @rotY = v; end + def depthPercent=(v) RegexValidator.validate "#{self.class}.depthPercent", DEPTH_PERCENT_REGEX, v; @depthPercent = v; end + def rAngAx=(v) Axlsx::validate_boolean(v); @rAngAx = v; end + def perspective=(v) DataTypeValidator.validate "#{self.class}.perspective", [Integer, Fixnum], v, lambda {|v| v >= 0 && v <= 240 }; @perspective = v; end # Serializes the view3D properties diff --git a/lib/axlsx/util/simple_typed_list.rb b/lib/axlsx/util/simple_typed_list.rb index 7bb656cd..53b7b994 100644 --- a/lib/axlsx/util/simple_typed_list.rb +++ b/lib/axlsx/util/simple_typed_list.rb @@ -100,6 +100,11 @@ module Axlsx index < @locked_at end + # override the equality method so that this object can be compared to a simple array. + # if this object's list is equal to the specifiec array, we return true. + def ==(v) + v == @list + end # method_mission override to pass allowed methods to the list. # @note # the following methods are not allowed @@ -123,12 +128,12 @@ module Axlsx # :drop_while # :delete_if # :clear - # :concat def method_missing(meth, *args, &block) - 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 + 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 if @list.respond_to? meth @list.send(meth, *args, &block) else + puts "method:#{meth.inspect}" super end end diff --git a/lib/axlsx/workbook/worksheet/worksheet.rb b/lib/axlsx/workbook/worksheet/worksheet.rb index 4cc9d783..c82dbde9 100644 --- a/lib/axlsx/workbook/worksheet/worksheet.rb +++ b/lib/axlsx/workbook/worksheet/worksheet.rb @@ -100,11 +100,19 @@ module Axlsx @rows.last end - # Adds a chart to this worksheets drawing. + # 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. # @param [Class] chart_type # @option options [Array] start_at # @option options [Array] end_at # @option options [Cell, String] title + # @option options [Boolean] show_legend + # @option options [Integer] style + # @note each chart type also specifies additional options + # @see Chart + # @see Pie3DChart + # @see Bar3DChart + # @see Line3DChart + # @see README for examples def add_chart(chart_type, options={}) chart = drawing.add_chart(chart_type, options) yield chart if block_given? diff --git a/test/drawing/tc_axis.rb b/test/drawing/tc_axis.rb index 6b08d842..426bf4ad 100644 --- a/test/drawing/tc_axis.rb +++ b/test/drawing/tc_axis.rb @@ -14,6 +14,7 @@ class TestAxis < Test::Unit::TestCase assert_equal(@axis.tickLblPos, :nextTo, "tick label position default incorrect") assert_equal(@axis.crosses, :autoZero, "tick label position default incorrect") assert(@axis.scaling.is_a?(Axlsx::Scaling) && @axis.scaling.orientation == :minMax, "scaling default incorrect") + assert_raise(ArgumentError) { Axlsx::Axis.new -1234, 'abcd' } end def test_axis_position diff --git a/test/drawing/tc_cat_axis_data.rb b/test/drawing/tc_cat_axis_data.rb new file mode 100644 index 00000000..e8a71fb1 --- /dev/null +++ b/test/drawing/tc_cat_axis_data.rb @@ -0,0 +1,18 @@ +require 'test/unit' +require 'axlsx.rb' + +class TestCatAxisData < Test::Unit::TestCase + + def setup + p = Axlsx::Package.new + @ws = p.workbook.add_worksheet + chart = @ws.drawing.add_chart Axlsx::Bar3DChart + @series = chart.add_series :labels=>["zero", "one", "two"] + end + + def test_initialize + assert(@series.labels.is_a?Axlsx::SimpleTypedList) + assert_equal(@series.labels, ["zero", "one", "two"]) + end + +end diff --git a/test/drawing/tc_chart.rb b/test/drawing/tc_chart.rb index 586df2c5..f303fab9 100644 --- a/test/drawing/tc_chart.rb +++ b/test/drawing/tc_chart.rb @@ -34,6 +34,18 @@ class TestChart < Test::Unit::TestCase assert_equal(@chart.style, 2) end + def test_start_at + @chart.start_at 15,25 + assert_equal(@chart.graphic_frame.anchor.from.col, 15) + assert_equal(@chart.graphic_frame.anchor.from.row, 25) + + end + + def end_at + @chart.end_at 25, 90 + assert_equal(@chart.graphic_frame.anchor.from.col, 25) + assert_equal(@chart.graphic_frame.anchor.to.row, 90) + end def test_add_series s = @chart.add_series :data=>[0,1,2,3], :labels => ["one", 1, "anything"], :title=>"bob" diff --git a/test/drawing/tc_line_series.rb b/test/drawing/tc_line_series.rb new file mode 100644 index 00000000..602e7770 --- /dev/null +++ b/test/drawing/tc_line_series.rb @@ -0,0 +1,27 @@ +require 'test/unit' +require 'axlsx.rb' + +class TestLineSeries < Test::Unit::TestCase + + def setup + p = Axlsx::Package.new + @ws = p.workbook.add_worksheet :name=>"hmmm" + chart = @ws.drawing.add_chart Axlsx::Line3DChart, :title => "fishery" + @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob" + end + + def test_initialize + assert_equal(@series.title.text, "bob", "series title has been applied") + assert_equal(@series.data, [0,1,2], "data option applied") + assert_equal(@series.labels, ["zero", "one","two"], "labels option applied") + end + + def test_data + assert_equal(@series.data, [0,1,2]) + end + + def test_labels + assert_equal(@series.labels, ["zero", "one", "two"]) + end + +end diff --git a/test/drawing/tc_line_series.tc b/test/drawing/tc_line_series.tc deleted file mode 100644 index 54cbc256..00000000 --- a/test/drawing/tc_line_series.tc +++ /dev/null @@ -1,34 +0,0 @@ -require 'test/unit' -require 'axlsx.rb' - -class TestLineSeries < Test::Unit::TestCase - - def setup - p = Axlsx::Package.new - @ws = p.workbook.add_worksheet :name=>"hmmm" - chart = @ws.drawing.add_chart Axlsx::Line3DChart, :title => "fishery" - @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob" - end - - def test_initialize - assert_equal(@series.title.text, "bob", "series title has been applied") - assert_equal(@series.data, [0,1,2], "data option applied") - assert_equal(@series.labels, ["zero", "one","two"], "labels option applied") - assert_equal(@series.shape, :box, "series shape has been applied") - end - - def test_data - assert_equal(@series.data, [0,1,2]) - end - - def test_labels - assert_equal(@series.labels, ["zero", "one", "two"]) - end - - def test_shape - assert_raise(ArgumentError, "require valid shape") { @series.shape = :teardropt } - assert_nothing_raised("allow valid shape") { @series.shape = :cone } - assert(@series.shape == :cone) - end - -end diff --git a/test/drawing/tc_ser_axis.rb b/test/drawing/tc_ser_axis.rb index 1882e1f1..3d744907 100644 --- a/test/drawing/tc_ser_axis.rb +++ b/test/drawing/tc_ser_axis.rb @@ -8,16 +8,24 @@ class TestSerAxis < Test::Unit::TestCase def teardown end + def test_options + a = Axlsx::SerAxis.new 12345, 54321, :tickLblSkip => 9, :tickMarkSkip => 7 + assert_equal(a.tickLblSkip, 9) + assert_equal(a.tickMarkSkip, 7) + end + + def test_tickLblSkip - assert_raise(ArgumentError, "requires valid tickLblSkip") { @axis.tickLblSkip = :my_eyes } - assert_nothing_raised("accepts valid tickLblSkip") { @axis.tickLblSkip = false } - assert_equal(@axis.tickLblSkip, false) + assert_raise(ArgumentError, "requires valid tickLblSkip") { @axis.tickLblSkip = -1 } + assert_nothing_raised("accepts valid tickLblSkip") { @axis.tickLblSkip = 1 } + assert_equal(@axis.tickLblSkip, 1) end + def test_tickMarkSkip assert_raise(ArgumentError, "requires valid tickMarkSkip") { @axis.tickMarkSkip = :my_eyes } - assert_nothing_raised("accepts valid tickMarkSkip") { @axis.tickMarkSkip = false } - assert_equal(@axis.tickMarkSkip, false) + assert_nothing_raised("accepts valid tickMarkSkip") { @axis.tickMarkSkip = 2 } + assert_equal(@axis.tickMarkSkip, 2) end end diff --git a/test/drawing/tc_two_cell_anchor.rb b/test/drawing/tc_two_cell_anchor.rb index 1c6e6882..2d87b6a7 100644 --- a/test/drawing/tc_two_cell_anchor.rb +++ b/test/drawing/tc_two_cell_anchor.rb @@ -2,13 +2,14 @@ require 'test/unit' require 'axlsx.rb' class TestTwoCellAnchor < Test::Unit::TestCase + def setup - @p = Axlsx::Package.new - ws = @p.workbook.add_worksheet - @row = ws.add_row ["one", 1, Time.now] - @title = Axlsx::Title.new - @chart = ws.add_chart Axlsx::Bar3DChart - @anchor = @chart.graphic_frame.anchor + p = Axlsx::Package.new + @ws = p.workbook.add_worksheet + row = @ws.add_row ["one", 1, Time.now] + title = Axlsx::Title.new + chart = @ws.add_chart Axlsx::Bar3DChart + @anchor = chart.graphic_frame.anchor end def teardown @@ -20,18 +21,18 @@ class TestTwoCellAnchor < Test::Unit::TestCase assert(@anchor.to.col == 5) assert(@anchor.to.row == 10) end + - def test_start_at - @anchor.start_at 5, 10 - assert(@anchor.from.col == 5) - assert(@anchor.from.row == 10) - end - - def test_end_at - @anchor.end_at 10, 15 - assert(@anchor.to.col == 10) - assert(@anchor.to.row == 15) + def test_options + assert_raise(ArgumentError, 'invalid start_at') { @ws.add_chart Axlsx::Chart, :start_at=>[1] } + assert_raise(ArgumentError, 'invalid end_at') { @ws.add_chart Axlsx::Chart, :start_at=>[1,2], :end_at => ["a", 4] } + # this is actually raised in the graphic frame + assert_raise(ArgumentError, 'invalid Chart') { @ws.add_chart Axlsx::TwoCellAnchor } + a = @ws.add_chart Axlsx::Chart, :start_at => [15, 35], :end_at => [90, 45] + assert_equal(a.graphic_frame.anchor.from.col, 15) + assert_equal(a.graphic_frame.anchor.from.row, 35) + assert_equal(a.graphic_frame.anchor.to.col, 90) + assert_equal(a.graphic_frame.anchor.to.row, 45) end - end diff --git a/test/drawing/tc_val_axis.rb b/test/drawing/tc_val_axis.rb index 2dcdd416..4bd8b883 100644 --- a/test/drawing/tc_val_axis.rb +++ b/test/drawing/tc_val_axis.rb @@ -12,6 +12,11 @@ class TestValAxis < Test::Unit::TestCase assert_equal(@axis.crossBetween, :between, "axis crossBetween default incorrect") end + def test_options + a = Axlsx::ValAxis.new 2345, 4321, :crossBetween => :midCat + assert_equal(a.crossBetween, :midCat) + end + def test_crossBetween assert_raise(ArgumentError, "requires valid crossBetween") { @axis.crossBetween = :my_eyes } assert_nothing_raised("accepts valid crossBetween") { @axis.crossBetween = :midCat } diff --git a/test/drawing/tc_val_axis_data.rb b/test/drawing/tc_val_axis_data.rb new file mode 100644 index 00000000..cb39176d --- /dev/null +++ b/test/drawing/tc_val_axis_data.rb @@ -0,0 +1,18 @@ +require 'test/unit' +require 'axlsx.rb' + +class TestValAxisData < Test::Unit::TestCase + + def setup + p = Axlsx::Package.new + @ws = p.workbook.add_worksheet + chart = @ws.drawing.add_chart Axlsx::Line3DChart + @series = chart.add_series :data=>[0,1,2] + end + + def test_initialize + assert(@series.data.is_a?Axlsx::SimpleTypedList) + assert_equal(@series.data, [0,1,2]) + end + +end diff --git a/test/drawing/tc_view_3D.rb b/test/drawing/tc_view_3D.rb index 909550b5..40d8982f 100644 --- a/test/drawing/tc_view_3D.rb +++ b/test/drawing/tc_view_3D.rb @@ -8,7 +8,16 @@ class TestView3D < Test::Unit::TestCase def teardown end - + + def test_options + v = Axlsx::View3D.new :rotX => 10, :rotY => 5, :hPercent => "30%", :depthPercent => "45%", :rAngAx => false, :perspective => 10 + assert_equal(v.rotX, 10) + assert_equal(v.rotY, 5) + assert_equal(v.hPercent, "30%") + assert_equal(v.depthPercent, "45%") + assert_equal(v.rAngAx, false) + assert_equal(v.perspective, 10) + end def test_rotX assert_raise(ArgumentError) {@view.rotX = "bob"} -- cgit v1.2.3