[wxruby-users] chart extension for wxRuby?

Alex Fenton
Sun, 20 Apr 2008 14:10:05 -0000

Andreas Warberg wrote:
> Alex Fenton wrote:
>
>> require ''scruffy''
>> require ''wx''
>>
>> class Chart < Wx::Window
>>
>>
...
> This won''t run. I get ''in `render'': wrong number
of arguments (2 for 1)
> (ArgumentError)'' when I copy your example verbatim.
>
I think you''ve misunderstood the purpose of the example. It was just to
show a set up where a scruffy graph would render using a wxRuby DC
(device context) rather than to an SVG object.

What remains for someone with motivation to do is to convert or
translate the calls that scruffy makes to an svg object inside the
library (eg svg.line, svg.circle) into the equivalent DC calls
(dc.draw_line, dc.draw_circle). The relevant parts of scruffy to look at
are in the components and layers directory.

Probably it would be easiest to create a bridge class that translates
svg calls as dc calls. Then you could use the the Scruffy library
unmodified.

I did enough to persuade myself that this was likely a viable approach,
but have no particular interest in pursuing at the
moment.
> I would like to render a graph directly to the screen - is this possibly
> using scruffy / wxruby?
No, not directly without you or someone else doing some work.

The other approach would be to wrap a C++ wxWidgets component that
renders SVG (such as wxArt2D) in Ruby. This is probably harder.

alex

alex