[wxruby-users] chart extension for wxRuby?

Sven Suska
Mon, 18 Feb 2008 13:14:32 -0000

Am Donnerstag,  2008-Januar-31 20:41:58 schrieb Alex
Fenton:
> So in about 20 mins I was able to replace
> enough of the svg-based drawing code with dc-based code to get it to
> draw the chart background, title, frame, axis and labels in a Wx::Window
> (see below for the app code)
>
> It''s a fairly mechanical job of replacing calls to svg.text with
> dc.draw_text, svg.line with dc.draw_line etc in scruffy/components and
> scruffy/layers. I''m sure the individual chart types would need a
little
> more work, but each is still only a couple of calls to the same basic
> methods. I would recommend looking into it.
>

I had a look at it, but it still looks too complex for me.
Can anybody provide some concrete code pieces?

Any help appreciated.

Sven

> __
> require ''scruffy''
> require ''wx''
>
> class Chart < Wx::Window
>   attr_reader :graph
>   def initialize(*args)
>     super
>     evt_paint :on_paint
>     @graph = Scruffy::Graph.new(:title => "Monthly Profits")
>     graph.add(:line, ''John'', [100, -20, 30, 60])
>     graph.add(:line, ''Sara'', [120, 50, -80, 20])
>   end
>
>   def on_paint
>     paint do | dc |
>       graph.render(dc, :width => size.width, :height => size.height)
>     end
>   end
> end
>
>
> Wx::App.run do
>   frame = Wx::Frame.new(nil, :title => ''chart demo'')
>   chart = Chart.new(frame)
>   frame.show
> end
>
>
>