From c305823800b9362a405d7fc24e90186235629bcf Mon Sep 17 00:00:00 2001 From: Markus Bengts Date: Thu, 9 Jun 2011 00:37:57 +0300 Subject: [PATCH 1/3] bug fix: charts with 3 labels on the x-axis should use google's default step --- lib/gchart.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gchart.rb b/lib/gchart.rb index deef5e4..b4b3d29 100644 --- a/lib/gchart.rb +++ b/lib/gchart.rb @@ -493,7 +493,7 @@ def set_axis_range 'chxr=' + set.enum_for(:each_with_index).map do |axis_range, index| next nil if axis_range.nil? # ignore this axis min, max, step = axis_range - if axis_range.size > 3 || step && max && step > max # this is a full series + if axis_range.size >= 3 || step && max && step > max # this is a full series max = axis_range.compact.max step = nil end From 8e250a639a7910c56d31cdf92a630dd45d624a27 Mon Sep 17 00:00:00 2001 From: Markus Bengts Date: Thu, 9 Jun 2011 13:56:00 +0300 Subject: [PATCH 2/3] a test for evenly spaced labels --- spec/gchart_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/gchart_spec.rb b/spec/gchart_spec.rb index d549c50..b9ded26 100644 --- a/spec/gchart_spec.rb +++ b/spec/gchart_spec.rb @@ -125,7 +125,11 @@ Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan')).should be_true Gchart.line(:axis_labels => [['Jan','July','Jan','July','Jan'], ['0','100'], ['A','B','C'], ['2005','2006','2007']]).include?(Gchart.jstize('chxl=0:|Jan|July|Jan|July|Jan|1:|0|100|2:|A|B|C|3:|2005|2006|2007')).should be_true end - + + it "should have evenly spaced labels by default" do + Gchart.line(:data => [[nil, 500, 425], [425, 600, nil]], :axis_with_labels => ['x'], :axis_labels => [[1, 2, 3]]).should include('chxr=0,0,500|1,425,600') + end + def labeled_line(options = {}) Gchart.line({:data => @data, :axis_with_labels => 'x,y'}.merge(options)) end From 4e74035a62fb0772a775a51626f2bf7a4931b14f Mon Sep 17 00:00:00 2001 From: Joel AZEMAR Date: Fri, 17 Jun 2011 22:34:48 +0800 Subject: [PATCH 3/3] Add Example to record file PNG in filesystem to README --- README.markdown | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.markdown b/README.markdown index d8a0507..46f5cd8 100644 --- a/README.markdown +++ b/README.markdown @@ -284,6 +284,23 @@ Google-o-meter A Google-o-meter has a few restrictions. It may only use a solid filled background and it may only have one label. +Record Chart PNG file in filesystem Sample : +-------------------------------------------- + +Multi Lines Chart Sample : + + chart = Gchart.new( :type => 'line', + :title => "example title", + :data => [[17, 17, 11, 8, 2],[10, 20, 15, 5, 7],[2, 3, 7, 9, 12]], + :line_colors => 'e0440e,e62ae5,287eec', + :legend => ['courbe 1','courbe 2','courbe 3'], + :axis_with_labels => ['x', 'y'], + :axis_range => [[0,100,20], [0,20,5]], + :filename => "tmp/chart.png") + + # Record file in filesystem + chart.file + try yourself -------------