http://www.modelm.org/modelms/rubygdtest <---Here is our proof of concept
Here is the gory details to get this going on FreeBSD 5. something or
other...
install gd from ports
install ruby-gd from ports
install gdchart (0.0.9! not 0.0.5) from sourceforge and build it
(http://sourceforge.jp/projects/ruby-gdchart/)
no port anymore for gdchart, it died after 4.X.
we had to hax0r the location of some header files, gd.h and font*.h.. gds.h
in the following files:
gdc.h, gifencode.c...
we built it until the errors went away...
after that, we wrote a ruby script (pie_sample.rb) that looked like this:
#!/usr/local/bin/ruby
# Ruby/GD test with Active Record
# Ron Sweeney and Brian Barto ( http://www.gr-ruby.org/ )
# Is Ruby/GD dead ?
require ''GDChart''
require ''rubygems''
require ''active_record''
ActiveRecord::Base.establish_connection(:adapter => "mysql", :host
=>
"localhost
", :database => "modelm", :username =>
"flounder", :password =>
"***********")
class Modelm < ActiveRecord::Base
end
print "Content-Type: image/png"
print "\n\n"
#setup the chart
gdc = GDChartPie.new
gdc.title = "Model M Keyboards around the world (ruby/gd test)..."
gdc.EdgeColor = 0x000000
gdc.Color = [ 0xFF3322, 0xFF9933, 0xFFEE33, 0x33FFFF ]
gdc.BGColor = 0x000000
gdc.explode = [ 40, 20, 10, 30]
gdc.angle_3d = 90
gdc.depth_3d = 40
gdc.perspective = 5
gdc.image_type = GDChart::PNG
#Gets us some values via Active Record
us = Modelm.count "location = ''United States''"
canadia = Modelm.count "location = ''Canada''"
brazil = Modelm.count "location = ''Brazil''"
philli = Modelm.count "location = ''Philippines''"
#Put the data on the chart
data = [us, canadia, brazil, philli]
label = ["United States", "Canada", "Brazil",
"Philippines"]
gdc.out_graph(600, 600, $stdout, GDChartPie::PIE3D, data.length, label,
data)
Then, we referenced it from within rails as a script that rendered an image,
a PNG in this instance like so...
<img src="http://www.modelm.org/cgi-bin/pie_sample.rb">
On 11/3/05, Hugh Sasse <hgs-C9usXPTk/FFaa/9Udqfwiw@public.gmane.org>
wrote:>
> On Thu, 3 Nov 2005, Nick Brutyn wrote:
>
> > hey,
> >
> > i want to make a png or jpg file in ruby (depending on a parameter)
> >
> http://www.whytheluckystiff.net/bumpspark/
>
> and at the bottom is the ping stuff. You can probably use a
> conversion program to go from PNG to jpg.
>
> Hugh
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
Ron Sweeney
http://www.gr-ruby.org
http://www.modelm.org
http://www.clubpacswestmi.net/sweeney/
http://www.clubpacswestmi.net
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails