[wxruby-users] chart extension for wxRuby?
Alex Fenton
alex at pressure.to
Thu Jan 31 02:06:36 EST 2008
Ellis, Peter wrote:
> Does anyone know of a chart making extension written with wxRuby? I
> know there are a few Ruby gems out there to make charts (as SVG or an
> image), but they seem to have a lot of overhead associated with them.
> The ones I've found that seem most interesting (Gruff, Scruffy, gnuplot)
> require a big bulky graphics/image processing library to be installed.
> Seems like wxRuby has all the pieces one would need to make a nice chart
> API or custom chart widget,
Yes, all the pieces should be there. There are several charting
libraries written in C++ for wxWidgets which might offer a good starting
point [1]
Basically, you use a DC (DeviceContext) to draw lines, polygons,
ellipses, text etc. DC can draw images from files and do textured fills.
Wx::Grid would be an excellent component for editing and viewing the
source data points.
The target canvas can be either the screen (using Window#paint to create
a PaintDC), or a bitmap (using Bitmap#draw to create a MemoryDC). The
same actual drawing code is used regardless of the target. Once the
drawing's been done on a bitmap, call Bitmap.save_file to save the image
to a variety of formats, including BMP, PNG, TIF or JPG.
For higher-quality output there's also GraphicsContext, which can be
created by calling GraphicsDC.create(dc) from any other DC. This will
give anti-aliased edges and also offers gradient fills but is otherwise
very similar.
> although probably without the SVG, which is fine for my purposes.
>
There's an SVG-writer as an optional contrib-module in the main
wxWidgets tree, which allows DC drawing code to be output as SVG. This
isn't currently porrted to wxRuby, but if there's interest we could have
a look at adding it.
In my day job I do a lot of charting in Excel and SPSS so I'd be
interested to hear how it goes if you decide to pursue this.
cheers
alex
[1]
http://wxcode.sourceforge.net/complist.php?compperpage=1000&viewmode=full&browseby=category§ion=graphics&page=1
More information about the wxruby-users
mailing list