com.googlecode.gchart.client
Class GChart.SymbolType

java.lang.Object
  extended by com.googlecode.gchart.client.GChart.SymbolType
Enclosing class:
GChart

public static class GChart.SymbolType
extends java.lang.Object

Specifies the type of symbol used by a curve. GChart includes "box" symbols (suitable for line charts), horizontal and vertical bars that extend to axis limits or a specified baseline (suitable for bar and area charts), and pie slices (suitable for pie charts) in these symbol types. Thus, choosing a curve's symbol type has a bigger impact on the kind of chart you create than in other charting APIs you may have used.

One advantage of this symbol type based approach: you can place multiple pies, lines and/or bars on a single chart simply by creating multiple curves whose associated symbols have appropriately different symbol types.

Note that, for line, area, or pie charts, the exact look of the non-rectangular aspects (connecting lines, filled-in areas, etc.) of these symbols in the chart is largely governed by the host Symbol's fillSpacing and fillThickness properties.

For instance, with the default fillThickness of 0 for the BOX_CENTER symbol, curves display only explicitly specified data points, without any connecting lines between them. But, if you set fillThickness to 1, GChart interpolates a series of 1 pixel by 1 pixel rectangles between successive data points, at a density inversely proportional to the symbol's fillSpacing setting.

You must select each curve's symbol type from the predefined set of supported types listed in the "Field Summary" section below. The default symbol type is BOX_CENTER.

See Also:
getSymbol, setSymbolType, setFillSpacing, setFillThickness, Symbol

Field Summary
static GChart.SymbolType BOX_CENTER
          Use rectangles horizontally and vertically centered on each point of the curve
static GChart.SymbolType BOX_EAST
          Use rectangles just to the right of, and vertically centered on, each point of the curve
static GChart.SymbolType BOX_NORTH
          Use rectangles just above, and horizontally centered on, each point of the curve
static GChart.SymbolType BOX_NORTHEAST
          Use rectangles just above, and to the right of, each point of the curve
static GChart.SymbolType BOX_NORTHWEST
          Use rectangles just above and to the left of, each point of the curve
static GChart.SymbolType BOX_SOUTH
          Use rectangles just below, and horizontally centered on, each point of the curve
static GChart.SymbolType BOX_SOUTHEAST
          Use rectangles just below, and to the right of, each point of the curve
static GChart.SymbolType BOX_SOUTHWEST
          Use rectangles just below, and to the left of, each point of the curve
static GChart.SymbolType BOX_WEST
          Use rectangles just to the left of, and vertically centered on, each point of the curve
static GChart.SymbolType HBAR_BASELINE_CENTER
          Use horizontal bars that extend from the x,y position associated with each point, to the x position defined by the host Symbol's baseline property, and that are vertically centered on the data point.
static GChart.SymbolType HBAR_BASELINE_NORTH
          Use horizontal bars that extend from the x,y position associated with each point, to the x position defined by the host Symbol's baseline property, and whose bottom edge passes through the data point.
static GChart.SymbolType HBAR_BASELINE_SOUTH
          Use horizontal bars that extend from the x,y position associated with each point, to the x position defined by the host Symbol's baseline property, and whose top edge passes through the data point.
static GChart.SymbolType HBAR_EAST
          Use horizontal bars that extend from the right y-axis to each point on the curve, and that are vertically centered on the point.
static GChart.SymbolType HBAR_NEXT
          Draws a horizontal bar from each point to the x coordinate of the next point.
static GChart.SymbolType HBAR_NORTHEAST
          Use horizontal bars that extend from the right y-axis to each point on the curve, and that are vertically just above the point.
static GChart.SymbolType HBAR_NORTHWEST
          Use horizontal bars that extend from the left y-axis to each point on the curve, and that are vertically just above point.
static GChart.SymbolType HBAR_PREV
          Draws a horizontal bar from each point to the x coordinate of the previous point.
static GChart.SymbolType HBAR_SOUTHEAST
          Use horizontal bars that extend from the right y-axis to each point on the curve, and that are vertically just below the point.
static GChart.SymbolType HBAR_SOUTHWEST
          Use horizontal bars that extend from the left y-axis to each point on the curve, and that are vertically just below the point.
static GChart.SymbolType HBAR_WEST
          Use horizontal bars that extend from the left y-axis to each point on the curve, and that are vertically centered on the point.
static GChart.SymbolType PIE_SLICE_HATCHED_SHADING
          Draws a pie slice whose area is shaded using both vertical and horizontal bars, which produces a "cross-hatched" pattern.
static GChart.SymbolType PIE_SLICE_HORIZONTAL_SHADING
          Draws a pie slice whose area is shaded using horizontal bars.
static GChart.SymbolType PIE_SLICE_OPTIMAL_SHADING
          Draw a pie slice whose area is shaded using either vertical bars or horizontal bars--whichever renders the slice more efficiently.
static GChart.SymbolType PIE_SLICE_VERTICAL_SHADING
          Draws a pie slice whose area is shaded using vertical bars.
static GChart.SymbolType VBAR_BASELINE_CENTER
          Use vertical bars that extend from the x,y position associated with each point, to the y position defined by the host Symbol's baseline property, and that are horizontally centered on the data point.
static GChart.SymbolType VBAR_BASELINE_EAST
          Use vertical bars that extend from the x,y position associated with each point, to the y position defined by the host Symbol's baseline property, and whose left edge passes through the data point.
static GChart.SymbolType VBAR_BASELINE_WEST
          Use vertical bars that extend from the x,y position associated with each point, to the y position defined by the host Symbol's baseline property, and whose right edge passes through the data point.
static GChart.SymbolType VBAR_NEXT
          Draws a vertical bar from each point to the y coordinate of the next point.
static GChart.SymbolType VBAR_NORTH
          Use vertical bars that extend from the top of the chart to each point on the curve, and are horizontally centered on the point.
static GChart.SymbolType VBAR_NORTHEAST
          Use vertical bars that extend from the top of the chart to each point on the curve, and are horizontally to the right of the point.
static GChart.SymbolType VBAR_NORTHWEST
          Use vertical bars that extend from the top of the chart to each point on the curve, and are horizontally to the left of the point.
static GChart.SymbolType VBAR_PREV
          Draws a vertical bar from each point to the y coordinate of the previous point.
static GChart.SymbolType VBAR_SOUTH
          Use vertical bars that extend from the x-axis to each point on the curve, and that are horizontally centered on the point.
static GChart.SymbolType VBAR_SOUTHEAST
          Use vertical bars that extend from the x-axis to each point on the curve, and that are horizontally to the right of the point.
static GChart.SymbolType VBAR_SOUTHWEST
          Use vertical bars that extend from the x-axis to each point on the curve, and that are horizontally to the left of the point.
static GChart.SymbolType XGRIDLINE
          Represents a single x-axis grid-line.
static GChart.SymbolType Y2GRIDLINE
          Represents a single y2-axis grid-line.
static GChart.SymbolType YGRIDLINE
          Represents a single y-axis grid-line.
 
Method Summary
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOX_CENTER

public static GChart.SymbolType BOX_CENTER
Use rectangles horizontally and vertically centered on each point of the curve


BOX_EAST

public static GChart.SymbolType BOX_EAST
Use rectangles just to the right of, and vertically centered on, each point of the curve


BOX_NORTH

public static GChart.SymbolType BOX_NORTH
Use rectangles just above, and horizontally centered on, each point of the curve


BOX_NORTHEAST

public static GChart.SymbolType BOX_NORTHEAST
Use rectangles just above, and to the right of, each point of the curve


BOX_NORTHWEST

public static GChart.SymbolType BOX_NORTHWEST
Use rectangles just above and to the left of, each point of the curve


BOX_SOUTH

public static GChart.SymbolType BOX_SOUTH
Use rectangles just below, and horizontally centered on, each point of the curve


BOX_SOUTHEAST

public static GChart.SymbolType BOX_SOUTHEAST
Use rectangles just below, and to the right of, each point of the curve


BOX_SOUTHWEST

public static GChart.SymbolType BOX_SOUTHWEST
Use rectangles just below, and to the left of, each point of the curve


BOX_WEST

public static GChart.SymbolType BOX_WEST
Use rectangles just to the left of, and vertically centered on, each point of the curve


HBAR_BASELINE_CENTER

public static GChart.SymbolType HBAR_BASELINE_CENTER
Use horizontal bars that extend from the x,y position associated with each point, to the x position defined by the host Symbol's baseline property, and that are vertically centered on the data point.

See Also:
setBaseline, HBAR_BASELINE_CENTER, HBAR_BASELINE_SOUTH, HBAR_BASELINE_NORTH, VBAR_BASELINE_CENTER, VBAR_BASELINE_EAST, VBAR_BASELINE_WEST, Symbol

HBAR_BASELINE_NORTH

public static GChart.SymbolType HBAR_BASELINE_NORTH
Use horizontal bars that extend from the x,y position associated with each point, to the x position defined by the host Symbol's baseline property, and whose bottom edge passes through the data point.

See Also:
setBaseline, HBAR_BASELINE_CENTER, HBAR_BASELINE_SOUTH, HBAR_BASELINE_NORTH, VBAR_BASELINE_CENTER, VBAR_BASELINE_EAST, VBAR_BASELINE_WEST, Symbol

HBAR_BASELINE_SOUTH

public static GChart.SymbolType HBAR_BASELINE_SOUTH
Use horizontal bars that extend from the x,y position associated with each point, to the x position defined by the host Symbol's baseline property, and whose top edge passes through the data point.

See Also:
setBaseline, HBAR_BASELINE_CENTER, HBAR_BASELINE_SOUTH, HBAR_BASELINE_NORTH, VBAR_BASELINE_CENTER, VBAR_BASELINE_EAST, VBAR_BASELINE_WEST

HBAR_EAST

public static GChart.SymbolType HBAR_EAST
Use horizontal bars that extend from the right y-axis to each point on the curve, and that are vertically centered on the point.


HBAR_NEXT

public static GChart.SymbolType HBAR_NEXT
Draws a horizontal bar from each point to the x coordinate of the next point.

See Also:
HBAR_PREV, HBAR_PREV, HBAR_NEXT, setFillThickness, setFillSpacing

HBAR_NORTHEAST

public static GChart.SymbolType HBAR_NORTHEAST
Use horizontal bars that extend from the right y-axis to each point on the curve, and that are vertically just above the point.


HBAR_NORTHWEST

public static GChart.SymbolType HBAR_NORTHWEST
Use horizontal bars that extend from the left y-axis to each point on the curve, and that are vertically just above point.


HBAR_PREV

public static GChart.SymbolType HBAR_PREV
Draws a horizontal bar from each point to the x coordinate of the previous point.

As of version 2.0, GChart's fill and thickness properties, paired with the BOX_CENTER SymbolType, can be used to draw lines at arbitrary angles between points, and this will usually be the preferred approach for line charts. However, this symbol and companion symbols like VBAR_PREV, allow you to generate high quality vertical and horizontal lines much more efficiently (in fact, using only a single HTML element). Thus, they can be handy in special applications, such as organizational charts, where all the lines that you need to draw are either vertical or horizontal anyway.

See Also:
HBAR_PREV, HBAR_PREV, HBAR_NEXT, setFillThickness, setFillSpacing

HBAR_SOUTHEAST

public static GChart.SymbolType HBAR_SOUTHEAST
Use horizontal bars that extend from the right y-axis to each point on the curve, and that are vertically just below the point.


HBAR_SOUTHWEST

public static GChart.SymbolType HBAR_SOUTHWEST
Use horizontal bars that extend from the left y-axis to each point on the curve, and that are vertically just below the point.


HBAR_WEST

public static GChart.SymbolType HBAR_WEST
Use horizontal bars that extend from the left y-axis to each point on the curve, and that are vertically centered on the point.


PIE_SLICE_HORIZONTAL_SHADING

public static GChart.SymbolType PIE_SLICE_HORIZONTAL_SHADING
Draws a pie slice whose area is shaded using horizontal bars.

The vertical distance between corresponding edges of successive bars is governed by the symbol's fill spacing property; the height of each bar is defined by the symbol's fill thickness property; the border and background of each shading bar are defined by the symbol's border color, border width, border style, and background color properties.

The radius of the pie slice (length of the non-arc sides of the slice) is chosen such that a circle with this radius circumscribes the host Symbol's width/height determined rectangle. The slice pivot point is defined by each point's x,y position, and the orientation and size of the slice by the corresponding properties (see links below) of the host Symbol.

See Also:
setFillSpacing, setFillThickness, setBorderColor, setBorderWidth, setBackgroundColor, setPieSliceOrientation, setPieSliceSize, setX, setY, PIE_SLICE_VERTICAL_SHADING, PIE_SLICE_HATCHED_SHADING, PIE_SLICE_OPTIMAL_SHADING, Symbol

PIE_SLICE_VERTICAL_SHADING

public static GChart.SymbolType PIE_SLICE_VERTICAL_SHADING
Draws a pie slice whose area is shaded using vertical bars.

The horizontal distance between corresponding edges of successive bars is governed by the symbol's fill spacing property; the width of each bar is defined by the symbol's fill thickness property; the border and background of each shading bar are defined by the symbol's border color, border width, and background color properties.

The radius of the pie slice (length of the non-arc sides of the slice) is chosen such that a circle with this radius circumscribes the host Symbol's width/height determined rectangle. The slice pivot point is defined by each point's x,y position, and the orientation and size of the slice by the corresponding properties (see links below) of the host Symbol.

See Also:
setFillSpacing, setFillThickness, setBorderColor, setBorderWidth, setBackgroundColor, setPieSliceOrientation, setPieSliceSize, setX, setY, PIE_SLICE_HORIZONTAL_SHADING, PIE_SLICE_HATCHED_SHADING, PIE_SLICE_OPTIMAL_SHADING, Symbol

PIE_SLICE_HATCHED_SHADING

public static GChart.SymbolType PIE_SLICE_HATCHED_SHADING
Draws a pie slice whose area is shaded using both vertical and horizontal bars, which produces a "cross-hatched" pattern.

The distance between corresponding edges of successive bars is governed by the symbol's fill spacing property; the thickness of each bar is defined by the symbol's fill thickness property; the border and background of each shading bar are defined by the symbol's border color, border width, border style, and background color properties.

The radius of the pie slice (length of the non-arc sides of the slice) is chosen such that a circle with this radius circumscribes the host Symbol's width/height determined rectangle. The slice pivot point (i.e. pie center) is defined by each point's x,y position, and the orientation and size of the slice by the corresponding properties (see links below) of the host Symbol.

See Also:
setFillSpacing, setFillThickness, setBorderColor, setBorderWidth, setBackgroundColor, setPieSliceOrientation, setPieSliceSize, setX, setY, PIE_SLICE_VERTICAL_SHADING, PIE_SLICE_HORIZONTAL_SHADING, PIE_SLICE_OPTIMAL_SHADING, Symbol

PIE_SLICE_OPTIMAL_SHADING

public static GChart.SymbolType PIE_SLICE_OPTIMAL_SHADING
Draw a pie slice whose area is shaded using either vertical bars or horizontal bars--whichever renders the slice more efficiently. Specifically, pie slices that are wider than they are tall use horizontal shading and pie slices that are taller than they are wide use vertical shading. These choices minimize the the number of shading bars (and thus memory and time) required to render the pie slice.

The distance between corresponding edges of successive bars is governed by the symbol's fill spacing property; the thickness of each bar is defined by the symbol's fill thickness property; the border and background of each shading bar are defined by the symbol's border color, border width, and background color properties. The pie slice radius is always determined by the formula:

   sqrt(symbolWidth^2+symbolHeight^2)/2.0
   

Here symbolWidth and symbolHeight are the pie slice symbol's width and height, in pixels.

Note that this formula implies that the pie slice radius is the one associated with the circle that circumscribes the symbol, that is, the smallest circle that is big enough to completely contain the symbol's width/height defined bounding rectangle. Equivalently, the length of the pie slice radius equals the half the length of the diagonal across the symbol's bounding rectangle.

To assure an integral number of shading bars and thus improve the visual look of the pie chart, GChart automatically rounds the radius to the nearest multiple of the specified fillSpacing. For example, if the radius computed from the above formula were 96 pixels and the fillSpacing were 10 pixels, GChart would actually use a radius of 100 pixels.

Tip: To produce a pie slice with a radius, r, set the symbol's height to 0, and its width to 2*r (or visa-versa). To specify the radius in pixels, use the symbol's setWidth and setHeight methods; to specify the radius in "model units" (which scale up or down with the chart dimensions) use setModelWidth and setModelHeight instead.

The slice pivot point (i.e. pie center) is defined by each point's x,y position, and the orientation and size of the slice by the setPieSliceOrientation and setPieSliceSize methods of the host Symbol.

Creating a pie chart from such pie slices requires that you define a separate curve for each slice, as illustrated in the code below:

package com.googlecode.gchart.gcharttestapp.client;
import com.googlecode.gchart.client.GChart;
/** A simple three slice pie chart  */
public class GChartExample09 extends GChart {
   GChartExample09() {
     this.setChartSize(400, 200);
     setChartTitle("<h3>Three Slice Pie Chart</h3>");
     // Configure the plot region/axes appropriately:
     getXAxis().setAxisVisible(false);
     getXAxis().setAxisMin(-1);
     getXAxis().setAxisMax(1);
     getXAxis().setTickCount(0);
     getYAxis().setAxisVisible(false);
     getYAxis().setAxisMin(-1);
     getYAxis().setAxisMax(1);
     getYAxis().setTickCount(0);
     // add first slice
     addCurve();
     getCurve().addPoint(0,0); // centers pie in -1..1 x,y range 
     getCurve().getSymbol().setSymbolType(SymbolType.PIE_SLICE_OPTIMAL_SHADING);
     getCurve().getSymbol().setModelWidth(1); 
     getCurve().getSymbol().setModelHeight(0);
     getCurve().getSymbol().setPieSliceSize(0.70);
     // add second slice
     addCurve();
     getCurve().addPoint(0,0); 
     getCurve().getSymbol().setSymbolType(SymbolType.PIE_SLICE_OPTIMAL_SHADING);
     getCurve().getSymbol().setModelWidth(1);
     getCurve().getSymbol().setModelHeight(0);
     getCurve().getSymbol().setPieSliceSize(0.10);

    // add third slice
     addCurve();
     getCurve().addPoint(0,0);
     getCurve().getSymbol().setSymbolType(SymbolType.PIE_SLICE_OPTIMAL_SHADING);
     getCurve().getSymbol().setModelWidth(1);
     getCurve().getSymbol().setModelHeight(0);
     getCurve().getSymbol().setPieSliceSize(0.20);
 
     
     update();
   }
   
}

Which produces this:

Note how, because PIE_SLICE_OPTIMAL_SHADING was used, vertical or horizontal shading is automatically selected so as to minimize the number of shading bars in each slice.

See Also:
Symbol, setFillSpacing, setFillThickness, setBorderColor, setBorderWidth, setBackgroundColor, setPieSliceOrientation, setPieSliceSize, setWidth, setHeight, setModelWidth, setModelHeight, setX, setY, PIE_SLICE_VERTICAL_SHADING, PIE_SLICE_HORIZONTAL_SHADING, PIE_SLICE_HATCHED_SHADING

VBAR_BASELINE_CENTER

public static GChart.SymbolType VBAR_BASELINE_CENTER
Use vertical bars that extend from the x,y position associated with each point, to the y position defined by the host Symbol's baseline property, and that are horizontally centered on the data point.

See Also:
Symbol, setBaseline, HBAR_BASELINE_CENTER, HBAR_BASELINE_SOUTH, HBAR_BASELINE_NORTH, VBAR_BASELINE_CENTER, VBAR_BASELINE_EAST, VBAR_BASELINE_WEST

VBAR_BASELINE_WEST

public static GChart.SymbolType VBAR_BASELINE_WEST
Use vertical bars that extend from the x,y position associated with each point, to the y position defined by the host Symbol's baseline property, and whose right edge passes through the data point.

See Also:
Symbol, setBaseline, HBAR_BASELINE_CENTER, HBAR_BASELINE_SOUTH, HBAR_BASELINE_NORTH, VBAR_BASELINE_CENTER, VBAR_BASELINE_EAST, VBAR_BASELINE_WEST

VBAR_BASELINE_EAST

public static GChart.SymbolType VBAR_BASELINE_EAST
Use vertical bars that extend from the x,y position associated with each point, to the y position defined by the host Symbol's baseline property, and whose left edge passes through the data point.

See Also:
setBaseline, HBAR_BASELINE_CENTER, HBAR_BASELINE_SOUTH, HBAR_BASELINE_NORTH, VBAR_BASELINE_CENTER, VBAR_BASELINE_EAST, VBAR_BASELINE_WEST

VBAR_NEXT

public static GChart.SymbolType VBAR_NEXT
Draws a vertical bar from each point to the y coordinate of the next point.

See Also:
HBAR_PREV, HBAR_NEXT, HBAR_PREV, setFillThickness, setFillSpacing

VBAR_NORTH

public static GChart.SymbolType VBAR_NORTH
Use vertical bars that extend from the top of the chart to each point on the curve, and are horizontally centered on the point.


VBAR_NORTHEAST

public static GChart.SymbolType VBAR_NORTHEAST
Use vertical bars that extend from the top of the chart to each point on the curve, and are horizontally to the right of the point.


VBAR_NORTHWEST

public static GChart.SymbolType VBAR_NORTHWEST
Use vertical bars that extend from the top of the chart to each point on the curve, and are horizontally to the left of the point.


VBAR_PREV

public static GChart.SymbolType VBAR_PREV
Draws a vertical bar from each point to the y coordinate of the previous point.

See Also:
HBAR_PREV, HBAR_NEXT, HBAR_NEXT, setFillThickness, setFillSpacing

VBAR_SOUTH

public static GChart.SymbolType VBAR_SOUTH
Use vertical bars that extend from the x-axis to each point on the curve, and that are horizontally centered on the point.


VBAR_SOUTHEAST

public static GChart.SymbolType VBAR_SOUTHEAST
Use vertical bars that extend from the x-axis to each point on the curve, and that are horizontally to the right of the point.


VBAR_SOUTHWEST

public static GChart.SymbolType VBAR_SOUTHWEST
Use vertical bars that extend from the x-axis to each point on the curve, and that are horizontally to the left of the point.


XGRIDLINE

public static GChart.SymbolType XGRIDLINE
Represents a single x-axis grid-line. You can use this symbol to draw a single vertical bar across the chart.


Y2GRIDLINE

public static GChart.SymbolType Y2GRIDLINE
Represents a single y2-axis grid-line. You can use this symbol to draw a single horizontal bar across the chart, for example, to display an upper bound or control limit.


YGRIDLINE

public static GChart.SymbolType YGRIDLINE
Represents a single y-axis grid-line. You can use this symbol to draw a single horizontal bar across the chart, for example, to display an upper bound or control limit.



Copyright © 2007 John C. Gunther. All Rights Reserved.