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