Browse files

separate labels and legends for pies

  • Loading branch information...
1 parent fdbbff6 commit 6217011c86bb668a807c80cf6abf3fe693417526 @aderyabin aderyabin committed May 5, 2011
Showing with 10 additions and 10 deletions.
  1. +1 −1 lib/gchart.rb
  2. +9 −9 spec/gchart_spec.rb
View
2 lib/gchart.rb
@@ -397,7 +397,7 @@ def fill_for(type=nil, color='', angle=nil)
# or
# Gchart.line(:legend => ['first label', 'last label'])
def set_legend
- if type.to_s =~ /pie|pie_3d|meter/
+ if type.to_s =~ /meter/
@labels = legend
return set_labels
end
View
18 spec/gchart_spec.rb
@@ -180,10 +180,9 @@ def labeled_bar(options = {})
end
it 'should generate different labels and legend' do
- Gchart.line(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3'))
- Gchart.line(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chl=one|two|three'))
+ Gchart.pie(:legend => %w(1 2 3), :labels=>%w(one two three)).should(include('chdl=1|2|3') && include('chl=one|two|three'))
end
-
+
end
describe "generating different type of charts" do
@@ -520,12 +519,6 @@ def labeled_bar(options = {})
Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).include?('cht=p3').should be_true
end
- it "should be able to set labels by using the legend or labesl accessor" do
- Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data).should include("chl=#{@jstized_legend}")
- Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}")
- Gchart.pie_3d(:title => @title, :labels => @legend, :data => @data).should == Gchart.pie_3d(:title => @title, :legend => @legend, :data => @data)
- end
-
end
describe "a google-o-meter" do
@@ -546,6 +539,13 @@ def labeled_bar(options = {})
Gchart.meter(:bg => {:color => 'efefef', :type => 'solid'}).include?("chf=bg,s,efefef").should be_true
end
+ it "should be able to set labels by using the legend or labesl accessor" do
+ Gchart.meter(:title => @title, :labels => @legend, :data => @data).should include("chl=#{@jstized_legend}")
+ Gchart.meter(:title => @title, :labels => @legend, :data => @data).should == Gchart.meter(:title => @title, :legend => @legend, :data => @data)
+ end
+
+
+
end
describe "a map chart" do

0 comments on commit 6217011

Please sign in to comment.