Re: Displaying gruff graphs



[Note: parts of this message were removed to make it a legal post.]

I finally got this working with wx by hard-coding the file path. The graphs
(pie) is displayed, but now I have a small glitch, of course.
The frame is a about 1/4 of what it needs to be, and so I have to resize it
with the mouse.
Perhaps I need to make the frame where the graph is displayed a bit larger.
Is there anyway to make the size of the frame "dynamic" based on the size of
the image to be displayed?
In the mean time I will look in the wx documentation.

Thank you

Victor

On 3/31/08, Victor Reyes <victor.reyes@xxxxxxxxx> wrote:

Mark, thank you for your answer and time.

Alex, this is exactly what I am looking for. I am trying to do two things
at
the same time: Learning Ruby well and second learning to use gruff so I
can
use it at work.
I copied your sample code where I incorporated the sample gruff code that
I
got from the web. When I run it, a wx frame flashes quickly and end. Some
errors are displayed on the screen.
Would you mind if I send you directly my piece of code? It is very very
simple. It only adds about five (5) lines to your sample code.

Thank you for your help.

Victor

PS: The following are the errors:
C:\$user\vmr\Ruby>ruby rdg00.rb
c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.1/lib/gruff/base.rb:465:in
`write':
no encode delegate for this image format `C:/DOCUME~1/REYESV~1
:ImageMagickError)
from c:/ruby/lib/ruby/gems/1.8/gems/gruff-0.3.1
/lib/gruff/base.rb:465:in
`write'
from rdg00.rb:25:in `on_paint'
from c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.5-i386-mswin32
/lib/wx/classes/evthandler.rb:123:in
`call'
from c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.5-i386-mswin32
/lib/wx/classes/evthandler.rb:123:in
`acquire_handler'
from c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.5-i386-mswin32
/lib/wx/classes/window.rb:44:in
`call'
from c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.5-i386-mswin32
/lib/wx/classes/window.rb:44:in
`evt_paint'
from c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.5-i386-mswin32
/lib/wx/classes/app.rb:16:in
`call'
from c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.5-i386-mswin32
/lib/wx/classes/app.rb:16:in
`process_event'
from c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.5-i386-mswin32
/lib/wx/classes/app.rb:16:in
`main_loop'
from c:/ruby/lib/ruby/gems/1.8/gems/wxruby-1.9.5-i386-mswin32
/lib/wx/classes/app.rb:16:in
`run'
from rdg00.rb:34


On 3/31/08, Alex Fenton <aff28@xxxxxxxxxxxxxxxxxx> wrote:


Victor Reyes wrote:

Once a graph is written to disk, g.write("filename.png"), how can it
be
displayed in Ruby?
I would like to re-create the graph and re-displayed often enough to
give
the appearance of "real time"


It's not clear whether you meant via a browser or in a desktop app. If
you want to show it on the desktop, you'll need some sort of GUI toolkit
to display a window then draw the bitmap in it.

You have a lot of choices: wxRuby, FXRuby, QT/Ruby, Tk, Ruby/GTK etc
etc. They vary widely in suitability for different platforms, ease of
installation, features, aesthetics.

I use wxRuby b/c it's easy to install (gem install wxruby) and looks
good on all the big platforms. A simple 25-line example that would
regularly redraw an updated graph is below:

hth
alex
__
require 'wx'
require 'tempfile'

# A frame that draws a regularly updated graph from Gruff every X
millisecs
class GruffFrame < Wx::Frame
def initialize(refresh_delay = 5000)
super(nil, :title => 'Gruff')
Wx::Timer.every(refresh_delay) { refresh }
evt_paint :on_paint
end

# Writes the gruff graph to a file then reads it back to draw it
def on_paint
# Set up your graph here
graph = Gruff::Lines.new # ....
# Write to a tempfile and read back
tmp = Tempfile.new('gruff')
graph.write(tmp.path)
bmp = Wx::Bitmap.new(tmp.path, Wx::BITMAP_TYPE_PNG)
# Draw it on the Frame
paint do | dc |
dc.draw_bitmap(bmp, 0, 0, false)
end
end
end

Wx::App.run { GruffFrame.new.show }




.



Relevant Pages

  • Re: Color management
    ... I spend most of my days in Photoshop editing his or my pictures. ... Support complex font curves that enable the users to use Professional ... Can print CAD graph with super length, the longest is 50 meters, ... Auto-Creat Title Frame ...
    (comp.sys.mac.advocacy)
  • Synchronizing captured and rendered frames
    ... Decompressor -> Video Renderer ... What I am trying to do is display a AVI file stream in 2 preview windows at ... be synchronized frame for frame. ... That is, if I pause the filter graph, both ...
    (microsoft.public.multimedia.directx.dshow.programming)
  • Re: Message Pump for a Graph with a NullRenderer?
    ... of the FillBuffer loop slowing down. ... The time stamps are an indication of what time span the video frame ... graph, reindexed to start from 0 in your case as you are derived from ... With the souce filter + sub graph design, I still cannot see how u can ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Continuous Preview with multiple start/stop capture to the sam
    ... I don't extract the text from any filter in the graph. ... video to an MPEG2 file and to have a timestamp for each frame that correlates ... The SAMI file exists to allow a user to step frame by frame through the ... The subtitles are generated by the neurological recording system. ...
    (microsoft.public.win32.programmer.directx.video)
  • Re: Horizontal ScrollBar+ PictureBox + Flickering (how to stop flickering?)
    ... to true has no effect - namely, 'scrolling the graph' still ... The reason the Autoredraw method works is because your entire "clearing and drawing code" runs in a closed loop for each specific "frame", and the VB Autoredraw method will not actually display the new frame until that "closed loop" code has finished. ...
    (microsoft.public.vb.general.discussion)