GWTCanvas alternatives

77 views
Skip to first unread message

AThinerCoin

unread,
Aug 22, 2011, 4:23:45 PM8/22/11
to Google Web Toolkit
I'm trying to create a chart using GWT. The chart has a grid and x
and y axis labels and at least one line indicating status over time.
The example code I got from a co-worker uses two classes the
com.google.gwt.widgetideas.graphics.client package: GWTCanvas and
Color.

The documentation about GWTCanvas says to use Canvas instead, but
Canvas has a very limited number of methods. How do I replicate these
methods?
- clear()
- setFillStyle(Color color)
- fillRect(double startX, double startY, double width, double height)
- setLineWidth(double width)
- setStrokeStyle(Color color)
- beginPath()
- moveTo(double x, double y)
- lineTo(double x, double y)
- stoke()

Any help is appreciated. Thanks!
-Laura

Seth Hollyman

unread,
Aug 22, 2011, 7:05:07 PM8/22/11
to google-we...@googlegroups.com
Generally you grab a Context2d object from the canvas, and most of the methods you identified are exposed there.

See:


StrongSteve

unread,
Aug 23, 2011, 5:13:24 AM8/23/11
to Google Web Toolkit
Take a look at [1] for a quick start.

[1] http://www.giantflyingsaucer.com/blog/?p=2338

Nano Elefant

unread,
Aug 23, 2011, 11:11:36 AM8/23/11
to Google Web Toolkit
gwt-g2d may help you: http://code.google.com/p/gwt-g2d/

AThinerCoin

unread,
Aug 29, 2011, 10:38:47 PM8/29/11
to google-we...@googlegroups.com
Context2d was exactly what I needed.  Thanks for all the help!
Reply all
Reply to author
Forward
0 new messages