For downloads, demos, and more visit the
Client-side GChart Home Page

com.googlecode.gchart.client
Interface GChartCanvasLite


public interface GChartCanvasLite

Defines the features of a canvas (vector graphics) widget that (once you teach GChart how to create such widgets via the setCanvasFactory method) GChart can exploit to render your charts more quickly and with higher resolution.

Names, method signatures, and javadoc comments for this interface are mostly copied from, and a proper subset of, the GWT incubator's GWTCanvas widget. Specifically, for simplicity, features of GWTCanvas that GChart can't exploit, such as gradients and transformations, have been omitted, and only ordinary CSS and RGBA color strings (not the special GWTCanvas Color type) are supported.

The original GWTCanvas code is copyright Google, Inc. under the terms of the Apache 2.0 license.

Tip: To easily bolt-on GWTCanvas to render your charts more quickly and with higher resolution, just add the gwt-incubator.jar to your build path, and copy the boilerplate code in the setCanvasFactory method's javadocs into the module that contains your application's EntryPoint class. If you decide instead to use a different GWT cross-browser vector graphics widget, you can still use that boilerplate as a starting point for your own, custom, interfacing code.

GChart requires that the background color of the canvas element as a whole be transparent (no background color). This is needed because, to facilitate single-curve updating, GChart stitches together the canvas based rendering of a chart from a series of smaller, overlaid, canvas widgets. Since transparent backgrounds are the default for GWTCanvas, and likely for other GWT vector graphics widgets, you are not expected to have to do anything special to meet this requirement.

See Also:
GChartCanvasFactory, setCanvasFactory, setFillSpacing, setFillThickness

Method Summary
 void arc(double x, double y, double radius, double startAngle, double endAngle, boolean antiClockwise)
          Draws an arc.
 void beginPath()
          Erases the current path and prepares it for a new path.
 void clear()
          Clears the entire canvas.
 void closePath()
          Closes the current path.
 void fill()
          Fills the current path according to the current fillstyle.
 void lineTo(double x, double y)
          Adds a line from the last point in the current path to the point defined by x and y.
 void moveTo(double x, double y)
          Makes the last point in the current path be (x,y).
 void resize(int width, int height)
          Resizes the canvas.
 void setFillStyle(java.lang.String canvasFillStyle)
          Set the current Fill Style to the specified color.
 void setLineWidth(double width)
          Sets the current context's linewidth.
 void setStrokeStyle(java.lang.String canvasStrokeStyle)
          Set the current Stroke Style to the specified color.
 void stroke()
          Strokes the current path according to the current stroke style.
 

Method Detail

arc

void arc(double x,
         double y,
         double radius,
         double startAngle,
         double endAngle,
         boolean antiClockwise)
Draws an arc. If the context has a non-empty path, then the method must add a straight line from the last point in the path to the start point of the arc.

Parameters:
x - center X coordinate
y - center Y coordinate
radius - radius of drawn arc
startAngle - angle measured from positive X axis to start of arc CW
endAngle - angle measured from positive X axis to end of arc CW
antiClockwise - direction that the arc line is drawn

beginPath

void beginPath()
Erases the current path and prepares it for a new path.


clear

void clear()
Clears the entire canvas.


closePath

void closePath()
Closes the current path. "Closing" simply means that a line is drawn from the last element in the path back to the first.


fill

void fill()
Fills the current path according to the current fillstyle.


lineTo

void lineTo(double x,
            double y)
Adds a line from the last point in the current path to the point defined by x and y.

Parameters:
x - x coord of point
y - y coord of point

moveTo

void moveTo(double x,
            double y)
Makes the last point in the current path be (x,y).

Parameters:
x - x coord of point
y - y coord of point

resize

void resize(int width,
            int height)
Resizes the canvas.

Parameters:
width - width of canvas drawing area in pixels
height - height of canvas drawing area in pixels

setFillStyle

void setFillStyle(java.lang.String canvasFillStyle)
Set the current Fill Style to the specified color.

Whenever GChart uses canvas to fill-in a symbol's interior (e.g. the interior part, excluding the border, of a solid-fill pie slice), it passes the symbol's canvas fill style string (which is specified via Symbol.setBackgroundColor) to this method. It then uses the fill method of this interface to fill in the symbol's interior with this color.

Your method should be able to handle any color specification string likely to be passed into Symbol.setBackgroundColor, see that method for full details for the kinds of strings that are supported.

Parameters:
canvasFillStyle - the fill style specification string. You may assume that GChart will pass you either a standard CSS color specification string, or an RGBA extension of this standard CSS format, such as rgba(255,255,255,0.5).
See Also:
setBackgroundColor, fill

setLineWidth

void setLineWidth(double width)
Sets the current context's linewidth. Line width is the thickness of a stroked line.

GChart will obtain the width's passed into this method from those specified by the Symbol.setBorderWidth method (which defines the widths of stroked borders around any canvas-rendered line, area, or pie-slice chart elements) and from the Symbol.setFillThickness method (which defines the thickness of a line chart's connecting lines).

Parameters:
width - the width of the stroked line, in pixels
See Also:
setBorderWidth, setFillThickness

setStrokeStyle

void setStrokeStyle(java.lang.String canvasStrokeStyle)
Set the current Stroke Style to the specified color.

GChart will obtain the color strings passed into this method from those specified by the Symbol.setBorderColor method. You can assume that these strings will be either in standard CSS or the extended RGBA format, see Symbol.setBorderColor for full details. These colors will become the colors of the stroked borders around any canvas-rendered line, area, or pie-slice chart elements.

Parameters:
canvasStrokeStyle - the stroke style specification string. You may assume that, during rendering, GChart will pass you either a standard CSS color specification string, or an RGBA extension of this standard CSS format such as rgba(255,255,255,0.5) for semi-transparent white.
See Also:
setBorderColor, stroke

stroke

void stroke()
Strokes the current path according to the current stroke style.


For downloads, demos, and more visit the
Client-side GChart Home Page

Copyright © 2007,2008 John C. Gunther. All Rights Reserved. Portions from GWTCanvas, Copyright © Google, Inc.