|
For downloads, demos, and more
visit the Client-side GChart Home Page |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.googlecode.gchart.client.GChart.Axis
public abstract class GChart.Axis
Represents an axis of the chart, for example, the x, y, or y2 axis. An axis consists of the axis itself, along with its tick marks, tick labels and gridlines.
XAxis,
YAxis,
Y2Axis,
getXAxis,
getYAxis,
getY2Axis| Constructor Summary | |
|---|---|
GChart.Axis()
|
|
| Method Summary | |
|---|---|
void |
addTick(double tickPosition)
Adds a tick on this axis at the specified position. |
void |
addTick(double tickPosition,
java.lang.String tickLabel)
Adds a tick at the specified position with the specified label on this axis. |
void |
addTick(double tickPosition,
java.lang.String tickLabel,
int widthUpperBound,
int heightUpperBound)
Adds a tick at the specified position with the specified label on this axis, whose width and height are within the specified upper-bounds. |
void |
addTick(double tickPosition,
com.google.gwt.user.client.ui.Widget tickWidget)
Adds a Widget-defined tick label at the specified position. |
void |
addTick(double tickPosition,
com.google.gwt.user.client.ui.Widget tickWidget,
int widthUpperBound,
int heightUpperBound)
Adds a widget-defined tick label at the specified position, whose width and height are within the specified upper-bounds. |
void |
clearTicks()
Removes all ticks from this axis. |
java.lang.String |
formatNumberAsTickLabel(double value)
Applies this axis' tick label format to format a given value. |
com.google.gwt.user.client.ui.Widget |
getAxisLabel()
Returns the previously specified label of this axis. |
double |
getAxisMax()
Returns the maximum value displayed on this axis. |
double |
getAxisMin()
Returns the minimum value displayed on this axis. |
boolean |
getAxisVisible()
Is axis line visible on the chart? Note that this property only determines the visibility of the axis line itself. |
abstract double |
getDataMax()
Returns the maximum data value associated with values represented on this axis. |
abstract double |
getDataMin()
Returns the minimum data value associated with values represented on this axis. |
boolean |
getHasGridlines()
Returns the gridline setting previously made with setHasGridlines. |
int |
getTickCount()
Returns the number of ticks on this axis. |
java.lang.String |
getTickLabelFontColor()
Returns the color of the font used to display the text of the tick labels on this axis. |
int |
getTickLabelFontSize()
Returns the font size, in pixels, used for tick labels on this axis. |
java.lang.String |
getTickLabelFontStyle()
Returns the font-style of the font used to render tick labels on this axis (typically either "italic" or "normal") |
java.lang.String |
getTickLabelFontWeight()
Returns the CSS font-weight specification to be used by this axis' tick labels. |
java.lang.String |
getTickLabelFormat()
Returns the tick label numeric format string for this axis. |
int |
getTickLabelThickness()
Returns the thickness of the band adjacent to this axis that GChart will allocate to hold this axis' tick labels. |
int |
getTickLength()
Returns the length of ticks for this axis. |
int |
getTicksPerGridline()
Returns the ratio of the number of ticks to the number of ticks that have an associated gridline. |
int |
getTicksPerLabel()
Returns the ratio of the number of ticks to the number of labeled ticks. |
int |
getTickThickness()
Returns the thickness of ticks for this axis. |
void |
setAxisLabel(java.lang.String html)
Convenience method equivalent to setAxisLabel(new HTML(html)) |
void |
setAxisLabel(com.google.gwt.user.client.ui.Widget axisLabel)
Specifies the label of this axis. |
void |
setAxisMax(double max)
Specifies the maximum value visible on this axis. |
void |
setAxisMin(double min)
Specifies the minimum value of this axis. |
void |
setAxisVisible(boolean axisVisible)
Defines if this axis is visible. |
void |
setHasGridlines(boolean hasGridlines)
Specifies if this axis should have gridlines. |
void |
setTickCount(int tickCount)
Sets the number of ticks to be placed on this axis. |
void |
setTickLabelFontColor(java.lang.String cssColor)
Specifies the color of the font used to render tick labels for this axis. |
void |
setTickLabelFontSize(int tickLabelFontSize)
Sets the tick label font size for tick labels on this axis, in pixels. |
void |
setTickLabelFontStyle(java.lang.String cssStyle)
Specifies the CSS font-style of this axis' tick labels. |
void |
setTickLabelFontWeight(java.lang.String cssWeight)
Specifies the weight of the font used in this axis' tick labels. |
void |
setTickLabelFormat(java.lang.String format)
Specifies a format string to be used in converting the numeric values associated with each tick on this axis into tick labels. |
void |
setTickLabelThickness(int tickLabelThickness)
Specifies the thickness of the region adjacent to this axis that GChart will reserve for purposes of holding this axis' tick labels. |
abstract void |
setTickLength(int tickLength)
Sets this axes' tick length. |
void |
setTicksPerGridline(int ticksPerGridline)
Specifies the ratio of the number of tick marks on the axis, to the number of gridlines on the axis. |
void |
setTicksPerLabel(int ticksPerLabel)
Specifies the ratio of the number of tick marks on the axis, to the number of labeled tick marks on the axis. |
abstract void |
setTickThickness(int tickThickness)
Sets this axes' tick thickness. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GChart.Axis()
| Method Detail |
|---|
public void addTick(double tickPosition)
The label associated with this tick will be generated by applying the format specified via setTickLabelFormat to the specified position.
This is a convenience method equivalent to
addTick(tickPosition, null, GChart.NAI,
GChart.NAI). See addTick(tickPosition,tickLabel,widthUpperBound,heightUpperBound)
for details.
tickPosition - the position, in model units,
along this axis at which this tick is displayed.
For example, if the axis range goes from 0 to 100,
a tick at position 50 would appear in the middle of
the axis.clearTicks,
addTick(double,String),
addTick(double,String,int,int),
addTick(double,Widget,int,int),
setTickCount,
setTickLabelFormat,
setTickLabelFontStyle,
setTickLabelFontColor,
setTickLabelFontWeight,
setTickLabelFontSize
public void addTick(double tickPosition,
java.lang.String tickLabel,
int widthUpperBound,
int heightUpperBound)
Note that explicitly adding a single tick via this method will eliminate any auto-generated ticks associated with the setTickCount method.
Use this method to specify unusually spaced tick marks with labels that do not directly reflect the position (for example, for a logarithmic axis, or for a bar chart with special keyword-type labels, or a time axis that places date and time on two separate lines).
tickPosition - the position, in model units, along
this axis at which the tick is displayed.
For example, if the axis range goes from 0 to 1,
a tick at position 0.5 would appear in the middle of
the axis.tickLabel - the label for this tick. HTML is
supported in tick labels, but it must be prefixed by
<html>. See the setAnnotationText method for more information.widthUpperBound - an upper bound on the width of
the text or HTML, in pixels. Use GChart.NAI to
get GChart to estimate this width for you. See the
setAnnotationText method for more information.heightUpperBound - an upper bound on the height of
the text or HTML, in pixels. Use GChart.NAI to
get GChart to estimate this height for you. See the
setAnnotationText method for more information.clearTicks,
addTick(double),
addTick(double,String),
addTick(double,Widget,int,int),
setTickCount,
setTickLabelFormat,
setTickLabelFontSize,
setTickLabelFontStyle,
setTickLabelFontColor,
setTickLabelFontWeight,
setAnnotationText,
setAnnotationWidget
public void addTick(double tickPosition,
java.lang.String tickLabel)
This is a convenience method equivalent to
addTick(tickPosition, tickLabel, GChart.NAI,
GChart.NAI). Most applications can usually just
use this convenience method. See addTick(tickPosition,tickLabel,
widthUpperBound,heightUpperBound) for the fine print.
tickPosition - the position, in model units, along
this axis at which the tick is displayed.tickLabel - the plain text or
(<html>-prefixed) HTML defining the tick's
label.addTick(double,String,int,int),
addTick(double,Widget)
public void addTick(double tickPosition,
com.google.gwt.user.client.ui.Widget tickWidget,
int widthUpperBound,
int heightUpperBound)
This method is similar to addTick(double,String,int,int) except that it uses a widget, rather than a string, to define the tick's label. Although the string-based method is faster on first chart rendering, and uses less memory, the widget-based method allows you to change the label independently of the chart--potentially bypassing (or speeding up) expensive chart updates later on.
You might use a widget-based tick label to pop up a dialog that allows the user to edit the parameters defining the axis (min, max, etc.) whenever they click on one of the tick labels on that axis, to define hovertext that appears when the user mouses over a tick label, to use images for your tick labels, etc.
tickPosition - the position, in model units, along
this axis at which the tick is displayed.
For example, if the axis range goes from 0 to 1,
a tick at position 0.5 would appear in the middle of
the axis.tickWidget - the label for this tick, as defined
by any GWT Widget.widthUpperBound - an upper bound on the width of
the widget, in pixels. If this and the next
parameter are omitted, GChart will use
DEFAULT_WIDGET_WIDTH_UPPERBOUND.heightUpperBound - an upper bound on the height of
the widget, in pixels. If this and the previous
parameter are omitted, GChart will use
DEFAULT_WIDGET_HEIGHT_UPPERBOUNDaddTick(double,Widget),
addTick(double,String,int,int),
setAnnotationWidget,
DEFAULT_WIDGET_WIDTH_UPPERBOUND,
DEFAULT_WIDGET_HEIGHT_UPPERBOUND
public void addTick(double tickPosition,
com.google.gwt.user.client.ui.Widget tickWidget)
tickPosition - the position, in model units, along
this axis at which the tick is displayed.
For example, if the axis range goes from 0 to 1,
a tick at position 0.5 would appear in the middle of
the axis.tickWidget - the label for this tick, as defined
by any GWT Widget.addTick(double,Widget,int,int)public void clearTicks()
setTickCount,
addTick(double),
addTick(double,String),
addTick(double,String,int,int),
addTick(double,Widget),
addTick(double,Widget,int,int)public java.lang.String formatNumberAsTickLabel(double value)
setTickLabelFormatpublic com.google.gwt.user.client.ui.Widget getAxisLabel()
setAxisLabelpublic double getAxisMax()
setAxisMax,
getDataMin,
getDataMaxpublic double getAxisMin()
setAxisMinpublic boolean getAxisVisible()
setAxisVisiblepublic abstract double getDataMax()
getDataMin,
getAxisMax,
getAxisMinpublic abstract double getDataMin()
getDataMax,
getAxisMax,
getAxisMaxpublic boolean getHasGridlines()
setHasGridlinespublic int getTickCount()
setTickCount,
addTick(double),
addTick(double,String),
addTick(double,String,int,int),
addTick(double,Widget),
addTick(double,Widget,int,int),
clearTickspublic java.lang.String getTickLabelFontWeight()
setTickLabelFontWeightpublic java.lang.String getTickLabelFontColor()
setTickLabelFontColor,
DEFAULT_TICK_LABEL_FONT_COLORpublic java.lang.String getTickLabelFontStyle()
setTickLabelFontStylepublic int getTickLabelFontSize()
setTickLabelFontSizepublic java.lang.String getTickLabelFormat()
setTickLabelFormatpublic int getTickLabelThickness()
setTickLabelThicknesspublic int getTicksPerGridline()
setTicksPerGridlinepublic int getTicksPerLabel()
setTicksPerLabelpublic int getTickLength()
setTickLengthpublic int getTickThickness()
setTickThickness,
getTickLengthpublic void setAxisLabel(java.lang.String html)
html - HTML text used to define the axis labelsetAxisLabel(Widget)public void setAxisLabel(com.google.gwt.user.client.ui.Widget axisLabel)
This label will be positioned just outside of, and centered lengthwise on, the region adjacent to this axis that GChart reserves for this axis' tick labels.
axisLabel - a Widget to use as the label of this axis.getAxisLabel,
setTickLabelThicknesspublic void setAxisMax(double max)
Points with associated coordinates greater than this value will be clipped unless the chart's showOffChartPoints property is true.
If Double.NaN is specified, this maximum is auto-determined as described in getAxisMax.
Performance tip: Using auto-determined axis limits (via Double.NaN) forces GChart to re-render the axis every time you call GChart.update. When your axis limits don't change between updates, these (often expensive) re-renderings can be avoided by using explicitly specified axis limits on every axis.
max - maximum value visible on this axis, in "model units"
(arbitrary, application-specific, units) or Double.NaN
(the default value) to use an auto-determined maximum.getAxisMax,
getDataMin,
getDataMax,
setShowOffChartPointspublic void setAxisMin(double min)
Points with associated coordinates less than this value will be clipped unless the chart's showOffChartPoints property is true.
If Double.NaN is specified, this minimum is auto-determined as described in getAxisMin.
Performance tip: Using auto-determined axis limits (via Double.NaN) forces GChart to re-render the axis every time you call GChart.update. When your axis limits don't change between updates, these (often expensive) re-renderings can be avoided by using explicitly specified axis limits on every axis.
min - minumum value visible on this axis, in "model units"
(arbitrary, application-specific, units), or Double.NaN
(the default) to use an auto-determined minimum.getAxisMin,
getDataMin,
getDataMaxpublic void setAxisVisible(boolean axisVisible)
Tip:Tick marks can be made invisible by using setTickThickness to set the tick thickness to 0. Tick labels can be made invisible by using setTickLabelFontColor to set the tick label color to the chart's background color.
axisVisible - false to hide axis, true to show it.setTickThickness,
setTickLabelFontColor,
getAxisVisiblepublic void setHasGridlines(boolean hasGridlines)
hasGridlines - true to display gridlines,
false (the default) to not display them.getHasGridlines,
setTicksPerGridlinepublic void setTickCount(int tickCount)
Note that setting the tick count overrides (erases) any ticks explicitly specified via addTick.
tickCount - the number of ticks for this axis.getTickCount,
addTick(double),
addTick(double, String),
addTick(double,String,int,int),
addTick(double,Widget),
addTick(double,Widget,int,int),
setTickLabelFormat,
setTickLabelFontSize,
setTickLabelFontStyle,
setTickLabelFontColor,
setTickLabelFontWeightpublic void setTickLabelFontWeight(java.lang.String cssWeight)
cssWeight - the weight of the font, such as bold,
normal, light, 100, 200, ... 900, for tick labels.getTickLabelFontWeight,
setTickLabelFormat,
setTickCount,
addTick(double),
addTick(double,String),
addTick(double,String,int,int),
addTick(double,Widget),
addTick(double,Widget,int,int),
setTickLabelFontStyle,
setTickLabelFontColor,
setTickLabelFontSize,
DEFAULT_TICK_LABEL_FONT_WEIGHTpublic void setTickLabelFontColor(java.lang.String cssColor)
For more information on standard CSS color
specifications see the discussion in
Symbol.setBackgroundColor.
cssColor - color of the font used to display this
axes' tick labels, in standard CSS format.getTickLabelFontColor,
setTickLabelFormat,
setTickCount,
addTick(double),
addTick(double,String),
addTick(double,String,int,int),
addTick(double,Widget),
addTick(double,Widget,int,int),
setTickLabelFontStyle,
setTickLabelFontWeight,
setTickLabelFontSizepublic void setTickLabelFontStyle(java.lang.String cssStyle)
cssStyle - any valid CSS font-style, namely,
normal, italic, oblique, or inherit.getTickLabelFontStyle,
setTickLabelFormat,
setTickCount,
addTick(double),
addTick(double,String),
addTick(double,String,int,int),
addTick(double,Widget),
addTick(double,Widget,int,int),
setTickLabelFontColor,
setTickLabelFontWeight,
setTickLabelFontSize,
DEFAULT_TICK_LABEL_FONT_STYLEpublic void setTickLabelFontSize(int tickLabelFontSize)
tickLabelFontSize - the font size of tick labels
displayed on this axis.getTickLabelFontSize,
setTickLabelFormat,
setTickCount,
addTick(double),
addTick(double,String),
addTick(double,String,int,int),
addTick(double,Widget),
addTick(double,Widget,int,int),
setTickLabelFontStyle,
setTickLabelFontColor,
setTickLabelFontWeight,
DEFAULT_TICK_LABEL_FONTSIZEpublic void setTickLabelFormat(java.lang.String format)
For an example of how to use this prefix to create a semi-log plot, see the Chart Gallery's GChartExample04.
Note that the values associated with this Axis must represent the number of milliseconds since January 1, 1970 (in the GMT time zone) whenever this date casting prefix is used.
For example, if the x-axis tick label format were "=(Date)MMM-dd-yyyy HH", then, for a tick located at the x position of 0, the tick label would be "Jan-01-1970 00" (on a client in the GMT time zone) and for a tick located at the x position of 25*60*60*1000 (one day + one hour, in milliseconds) the tick label would be "Jan-02-1970 01" (again, on a GMT-based client). Results would be shifted appropriately on clients in different time zones.
Note that if your chart is based on absolute, GMT-based, millisecond times then date labels will change when your chart is displayed on clients in different time zones. Sometimes, this is what you want. To keep the date labels the same in all time zones, convert date labels into Java Date objects in your client-side code, then use the Date.getTime method, also in your client-side code, to convert those dates into the millisecond values GChart requires. The Chart Gallery's GChartExample12 illustrates how to use this second approach to produce a time series chart whose date-time labels are the same in all time zones.
Ben Martin describes an alternative (and more flexible) approach to formatting time series tick labels in his GChart tutorial. Ben's article, along with Malcolm Gorman's related GWT forum post were the origin of this date casting prefix. Thanks!
Though HTML text is not supported in the tick label format string, you can change the size, weight, style, and color of tick label text via the setTickLabelFont* family of methods. You can use HTML in tick labels (e.g. for a multi-line x-axis label) but but only if you define each tick label explicitly using the addTick method.
format - an appropriately prefixed
GWT NumberFormat compatible or
GWT DateTimeFormat compatible format string that
defines how to convert tick values into tick labels.setTickCount,
addTick(double),
addTick(double,String),
addTick(double,String,int,int),
addTick(double,Widget),
addTick(double,Widget,int,int),
setTickLabelFontSize,
setTickLabelFontStyle,
setTickLabelFontColor,
setTickLabelFontWeight,
getTickLabelFormatpublic void setTickLabelThickness(int tickLabelThickness)
For vertical axes, this represents the width of the widest tick label, for horizontal axes, this represents the height of highest tick label. By default, this property has the special "undefined" value GChart.NAI. With this value, the companion method getTickLabelThickness automatically estimates (and returns) this thickness using the following formulas:
For vertical (y or y2) axes:
0.7 * getTickLabelFontSize() *
(maximum number of characters in any label's first line)
For horizontal (x) axes:
1.0*getTickLabelFontSize()
With (single line) plain text labels, these defaults will usually allocate sufficient space to produce an acceptable gap between an axis' tick labels and the label for the axis itself.
However, with multi-line HTML labels, the first line of the above estimates includes all the characters before the first <br> tag. Frequently, (what if your HTML defines a table?) these rules will produce poor estimates of HTML tick label width and height. So, with HTML based tick labels, you will often have to use this method to specify an appropriate tick label thickness.
Tip: It is sometimes easier to just set the tick label thickness to 0, and then introduce any spacing required via appropriate padding applied to the axis label widget itself.
getTickLabelThickness,
getTickLabelFontSize,
setAxisLabel,
NAIpublic void setTicksPerGridline(int ticksPerGridline)
For example, with the default value of 1, every tick has an associated gridline, whereas with a ticksPerGridline setting of 2, only the first, third, fifth, etc. ticks have gridlines.
This setting only has an impact when the axis' gridlines are turned on, that is, when this axis' getHasGridlines method returns true.
ticksPerGridline - the number of ticks on this
axis per "gridline-extended" tick.setHasGridlines,
setTickCount,
addTick(double),
addTick(double,String),
addTick(double,String,int,int),
addTick(double,Widget),
addTick(double,Widget,int,int)public void setTicksPerLabel(int ticksPerLabel)
For example, with the default value of 1, every tick is labeled, whereas with a ticksPerLabel setting of 2, only the first, third, fifth, etc. ticks are labeled.
This setting is only used when tick labels are specified implicitly via setTickCount. It is ignored when tick positions and their labels are explicitly specified via addTick.
ticksPerLabel - the ratio of the number of ticks,
to the number of labeled ticks.setTickCount,
addTick(double),
addTick(double,String),
addTick(double,String,int,int),
addTick(double,Widget),
addTick(double,Widget,int,int)public abstract void setTickLength(int tickLength)
Note that GChart ticks are always "outside" ticks.
tickLength - the length of the tick.getTickLengthpublic abstract void setTickThickness(int tickThickness)
Tip: Set the tick thickness to zero to to hide the tick but retain the spacing between tick labels and the axis due to the ticks' length.
Note that GChart ticks are always "outside" ticks.
tickThickness - the thickness of the tick.getTickThickness,
setTickLength
|
For downloads, demos, and more
visit the Client-side GChart Home Page |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||