diff options
| author | Randy Morgan <[email protected]> | 2012-05-03 20:27:42 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-05-03 20:27:42 +0900 |
| commit | 865ac88ef8325899c2c2c025a6994e02447b699b (patch) | |
| tree | 59897179f8a7a0c396124c01349a21af3f5482d6 /examples | |
| parent | 37d57ceeb5f5b64e1738df224b534ee3cb583943 (diff) | |
| download | caxlsx-865ac88ef8325899c2c2c025a6994e02447b699b.tar.gz caxlsx-865ac88ef8325899c2c2c025a6994e02447b699b.zip | |
examples cleanup
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/chart_colors.rb | 2 | ||||
| -rw-r--r-- | examples/extractive.rb | 28 |
2 files changed, 21 insertions, 9 deletions
diff --git a/examples/chart_colors.rb b/examples/chart_colors.rb index 5c1109f7..1287c2e9 100644 --- a/examples/chart_colors.rb +++ b/examples/chart_colors.rb @@ -16,7 +16,6 @@ wb.add_worksheet(:name => "Bar Chart") do |sheet| chart.add_series :data => sheet["A3:C3"], :labels => sheet["A2:C2"], :colors => ['FF0000', '00FF00', '0000FF'], :color => "000000" chart.valAxis.label_rotation = -45 chart.catAxis.label_rotation = 45 - puts chart.to_xml_string end end @@ -27,7 +26,6 @@ wb.add_worksheet(:name => "Hard Bar Chart") do |sheet| chart.add_series :data => [1,3,5], :labels => ['a', 'b', 'c'], :colors => ['FF0000', '00FF00', '0000FF'] chart.valAxis.label_rotation = -45 chart.catAxis.label_rotation = 45 - puts chart.to_xml_string end end diff --git a/examples/extractive.rb b/examples/extractive.rb index 71aa3863..433b95e2 100644 --- a/examples/extractive.rb +++ b/examples/extractive.rb @@ -1,3 +1,8 @@ +#!/usr/bin/env ruby -w -s +# -*- coding: utf-8 -*- + +$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" +require 'axlsx' data = [ ['oil-bbl',9591.411671,8860.714604,8237.936509,7700.523067,7231.831842,6819.307902,6453.297235,6126.251755,5832.182748,5566.276532,5324.618706,5103.992757,4901.730597,4715.600022,4543.718862,4384.488699,4236.543136,4098.707009,3969.963937,3849.430276,3736.33405,3629.997786,3529.824424,3435.28568,3345.912388,3261.286414,3181.033882,3104.819438,3032.341401,2963.327615,2897.531915,2834.731083,2774.722219,2717.320479,2662.357097,2609.677666,2559.140642,2510.616021,2463.984182,2419.134871,2375.966292,2334.384311,2294.301748,2255.637735,2218.317165,2182.270173,2147.431696,2113.741056,2081.141602,2049.580377,2019.007821,1989.377502,1960.645871,1932.772042,1905.71759,1879.446367,1853.924338,1829.119424,1805.001366,1781.541597,1758.713122,1736.490414,1714.849315,1693.766943,1673.22161,1653.192744,1633.660817,1614.607284,1596.014514,1577.865741,1560.145009,1542.837121,1525.927597,1509.402632,1493.249056,1477.454298,1462.006352,1446.893746,1432.105512,1417.631159,1403.460647,1389.584361,1375.993094,1362.678018,1349.630672,1336.842938,1324.307026,1312.015455,1299.961043,1288.136885,1276.536347,1265.153047,1253.980847,1243.013838,1232.246332,1221.672852,1211.288119,1201.087047,1191.064732,1181.216443,1171.537618,1162.023853,1152.670896,1143.474642,1134.431125,1125.536513,1116.787101,1108.179309,1099.709672,1091.37484,1083.171571,1075.096725,1067.147265,1059.320247,1051.612821,1044.022223,1036.545778,1029.180889,1021.92504,1014.775789], @@ -5,23 +10,32 @@ data = [ ['oil-bbl',9591.411671,8860.714604,8237.936509,7700.523067,7231.831842, ['water-bbl',940.97,836.557,748.477,673.308,608.52,552.205,502.892,459.432,420.912,386.597,355.889,328.299,303.419,280.908,260.478,241.887,224.925,209.415,195.2,182.147,170.14,159.074,148.861,139.419,130.68,122.579,115.061,108.076,101.579,95.53,89.892,84.633,79.722,75.134,70.842,66.826,63.065,59.54,56.234,53.132,50.219,47.482,44.91,42.491,40.215,38.072,36.053,34.152,32.359,30.668,29.074,27.568,26.147,24.805,23.537,22.339,21.206,20.134,19.121,18.162,17.254,16.395,15.581,14.81,14.079,13.387,12.731,12.109,11.519,10.959,10.428,9.924,9.446,8.991,8.56,8.151,7.762,7.393,7.042,6.708,6.391,6.089,5.803,5.53,5.271,5.025,4.79,4.567,4.355,4.153,3.96,3.777,3.603,3.437,3.279,3.128,2.985,2.848,2.718,2.594,2.476,2.364,2.256,2.154,2.057,1.964,1.875,1.79,1.71,1.633,1.56,1.49,1.423,1.36,1.299,1.241,1.186,1.133,1.083,1.034] ] -#!/usr/bin/env ruby -w -s -# -*- coding: utf-8 -*- -$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" -require 'axlsx' - p = Axlsx::Package.new wb = p.workbook wb.add_worksheet(:name => 'volumes') do |ws| - chart = ws.add_chart(Axlsx::Line3DChart, :perspective => 0, :hPercent => 100, :rotX => 0, :rotY => 0, :start_at => [0,4], :end_at => [12, 50], :title => 'Monthly forcast for Type Curve Gas secondary - gross ngl') + # perspective, rotX and rotY flatten the 3D chart + # hPercent sets the chart height to 100% + chart = ws.add_chart(Axlsx::Line3DChart, :perspective => 0, :hPercent => 100, :rotX => 0, :rotY => 0, :start_at => "A4", :end_at => 'M44', :title => 'Monthly forcast for Type Curve Gas secondary - gross ngl') + + # Set up log based scaling and appropriate min/max values for Y axis chart.valAxis.scaling.logBase = 10 chart.valAxis.scaling.min = 0.1 chart.valAxis.scaling.max = 10000000.0 + + # No poing in showing the series axis labels as the chart is flattened! + chart.serAxis.delete = true + + # Knock the catAxis labels down to the forced min. chart.catAxis.crosses = :min + # set up cat labels / markes to show every 12th item + chart.catAxis.tickLblSkip = 12 + chart.catAxis.tickMarkSkip = 12 + + #rgb colors for our data series colors = ['00FF00', 'FF0000', '0000FF'] data.each_with_index do |value, index| ws.add_row value - chart.add_series :data => ws.rows.last.cells[(1..value.size-1)], :labels => (1..value.size-1).map{ |i| i }, :title => ws.rows.last.cells.first, :color => colors[index] + chart.add_series :data => ws.rows.last.cells[(1..value.size-1)], :labels => (0..value.size).map{ |i| i }, :title => ws.rows.last.cells.first, :color => colors[index] end end |
