Skip to content
This repository has been archived by the owner on Jan 2, 2018. It is now read-only.

bug fix (?) for googlecharts #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------

Expand Down
2 changes: 1 addition & 1 deletion lib/gchart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion spec/gchart_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down