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

com.googlecode.gchart.client
Class GChart.Axis

java.lang.Object
  extended by com.googlecode.gchart.client.GChart.Axis
Direct Known Subclasses:
GChart.XAxis, GChart.Y2Axis, GChart.YAxis
Enclosing class:
GChart

public abstract class GChart.Axis
extends java.lang.Object

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.

See Also:
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

GChart.Axis

public GChart.Axis()
Method Detail

addTick

public void addTick(double tickPosition)
Adds a tick on this axis at the specified position. Note that explicitly adding a single tick via this method will eliminate any implicitly generated ticks associated with the setTickCount method.

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.

Parameters:
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.
See Also:
clearTicks, addTick(double,String), addTick(double,String,int,int), addTick(double,Widget,int,int), setTickCount, setTickLabelFormat, setTickLabelFontStyle, setTickLabelFontColor, setTickLabelFontWeight, setTickLabelFontSize

addTick

public 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.

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).

Parameters:
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.
See Also:
clearTicks, addTick(double), addTick(double,String), addTick(double,Widget,int,int), setTickCount, setTickLabelFormat, setTickLabelFontSize, setTickLabelFontStyle, setTickLabelFontColor, setTickLabelFontWeight, setAnnotationText, setAnnotationWidget

addTick

public void addTick(double tickPosition,
                    java.lang.String tickLabel)
Adds a tick at the specified position with the specified label on this axis.

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.

Parameters:
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.
See Also:
addTick(double,String,int,int), addTick(double,Widget)

addTick

public 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.

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.

Parameters:
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_UPPERBOUND
See Also:
addTick(double,Widget), addTick(double,String,int,int), setAnnotationWidget, DEFAULT_WIDGET_WIDTH_UPPERBOUND, DEFAULT_WIDGET_HEIGHT_UPPERBOUND

addTick

public void addTick(double tickPosition,
                    com.google.gwt.user.client.ui.Widget tickWidget)
Adds a Widget-defined tick label at the specified position. Convenience method equivalent to addTick(tickPosition, tickWidget, DEFAULT_WIDGET_WIDTH_UPPERBOUND, DEFAULT_WIDGET_HEIGHT_UPPERBOUND).

Parameters:
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.
See Also:
addTick(double,Widget,int,int)

clearTicks

public void clearTicks()
Removes all ticks from this axis. Specifically, erases any ticks that were explicitly specified via addTick, and also sets the tick count to 0.

See Also:
setTickCount, addTick(double), addTick(double,String), addTick(double,String,int,int), addTick(double,Widget), addTick(double,Widget,int,int)

formatNumberAsTickLabel

public java.lang.String formatNumberAsTickLabel(double value)
Applies this axis' tick label format to format a given value.

Returns:
the value formated as per this axis' currently specified tick label format.
See Also:
setTickLabelFormat

getAxisLabel

public com.google.gwt.user.client.ui.Widget getAxisLabel()
Returns the previously specified label of this axis.

Returns:
the Widget used as the label of this axis
See Also:
setAxisLabel

getAxisMax

public double getAxisMax()
Returns the maximum value displayed on this axis. If the explicitly specified maximum value is undefined (Double.NaN) the maximum value returned by this function is calculated as the maximum of all of the values either displayed on this axis via points on a curve, or explicitly specified via tick positions.

Returns:
maximum value visible on this axis, in "model units" (arbitrary, application-specific, units)
See Also:
setAxisMax, getDataMin, getDataMax

getAxisMin

public double getAxisMin()
Returns the minimum value displayed on this axis. If the minimum value is undefined (Double.NaN) the minimum value returned by this function is the minimum of all of the values either displayed on this axis via points on a curve, or explicitly specified via tick positions.

Returns:
minimum value visible on this axis, in "model units" (arbitrary, application-specific, units)
See Also:
setAxisMin

getAxisVisible

public boolean getAxisVisible()
Is axis line visible on the chart? Note that this property only determines the visibility of the axis line itself. It does not control the visibility of the tick marks or tick labels along this axis.

Returns:
true if the axis line is visible, false otherwise.
See Also:
setAxisVisible

getDataMax

public abstract double getDataMax()
Returns the maximum data value associated with values represented on this axis. For example, for the left y-axis, this would be the largest y-value of all points contained in curves that are displayed on the left y-axis.

Returns:
the maximum value associated with values mapped onto this axis.
See Also:
getDataMin, getAxisMax, getAxisMin

getDataMin

public abstract double getDataMin()
Returns the minimum data value associated with values represented on this axis. For example, for the left y-axis, this would be the smallest y-value of all points contained in curves that are displayed on the left y-axis.

Returns:
the minumum value associated with values mapped onto this axis.
See Also:
getDataMax, getAxisMax, getAxisMax

getHasGridlines

public boolean getHasGridlines()
Returns the gridline setting previously made with setHasGridlines.

Returns:
true if gridlines have been enabled, false if not.
See Also:
setHasGridlines

getTickCount

public int getTickCount()
Returns the number of ticks on this axis.

Returns:
the number of ticks on this axis.
See Also:
setTickCount, addTick(double), addTick(double,String), addTick(double,String,int,int), addTick(double,Widget), addTick(double,Widget,int,int), clearTicks

getTickLabelFontWeight

public java.lang.String getTickLabelFontWeight()
Returns the CSS font-weight specification to be used by this axis' tick labels.

Returns:
font-weight of this axis' tick labels
See Also:
setTickLabelFontWeight

getTickLabelFontColor

public java.lang.String getTickLabelFontColor()
Returns the color of the font used to display the text of the tick labels on this axis.

Returns:
CSS color string defining the color of the text of the tick labels for this axis.
See Also:
setTickLabelFontColor, DEFAULT_TICK_LABEL_FONT_COLOR

getTickLabelFontStyle

public java.lang.String getTickLabelFontStyle()
Returns the font-style of the font used to render tick labels on this axis (typically either "italic" or "normal")

Returns:
the CSS font-style in which tick labels of this axis are rendered.
See Also:
setTickLabelFontStyle

getTickLabelFontSize

public int getTickLabelFontSize()
Returns the font size, in pixels, used for tick labels on this axis.

Returns:
the tick label font size in pixels
See Also:
setTickLabelFontSize

getTickLabelFormat

public java.lang.String getTickLabelFormat()
Returns the tick label numeric format string for this axis.

Returns:
numeric format used to generate tick labels.
See Also:
setTickLabelFormat

getTickLabelThickness

public int getTickLabelThickness()
Returns the thickness of the band adjacent to this axis that GChart will allocate to hold this axis' tick labels.

Returns:
width of band, in pixels, GChart will reserve for this axis' tick labels.
See Also:
setTickLabelThickness

getTicksPerGridline

public int getTicksPerGridline()
Returns the ratio of the number of ticks to the number of ticks that have an associated gridline.

Returns:
number of ticks per gridline for this axis
See Also:
setTicksPerGridline

getTicksPerLabel

public int getTicksPerLabel()
Returns the ratio of the number of ticks to the number of labeled ticks.

Returns:
number of ticks per label.
See Also:
setTicksPerLabel

getTickLength

public int getTickLength()
Returns the length of ticks for this axis.

Returns:
the length of this axis' ticks, in pixels.
See Also:
setTickLength

getTickThickness

public int getTickThickness()
Returns the thickness of ticks for this axis.

Returns:
the thickness of this axis' ticks, in pixels.
See Also:
setTickThickness, getTickLength

setAxisLabel

public void setAxisLabel(java.lang.String html)
Convenience method equivalent to setAxisLabel(new HTML(html))

Parameters:
html - HTML text used to define the axis label
See Also:
setAxisLabel(Widget)

setAxisLabel

public void setAxisLabel(com.google.gwt.user.client.ui.Widget axisLabel)
Specifies the label of this axis.

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.

Parameters:
axisLabel - a Widget to use as the label of this axis.
See Also:
getAxisLabel, setTickLabelThickness

setAxisMax

public void setAxisMax(double max)
Specifies the maximum value visible on this axis.

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.

Parameters:
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.
See Also:
getAxisMax, getDataMin, getDataMax, setShowOffChartPoints

setAxisMin

public void setAxisMin(double min)
Specifies the minimum value of this axis.

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.

Parameters:
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.
See Also:
getAxisMin, getDataMin, getDataMax

setAxisVisible

public void setAxisVisible(boolean axisVisible)
Defines if this axis is visible. Note that this property only defines the visibility of the axis line itself, it does not control the visibility of tick marks or tick labels associated with the axis.

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.

Parameters:
axisVisible - false to hide axis, true to show it.
See Also:
setTickThickness, setTickLabelFontColor, getAxisVisible

setHasGridlines

public void setHasGridlines(boolean hasGridlines)
Specifies if this axis should have gridlines. When an axis has gridlines, tick marks with indexes 0, N, 2*N,... where N is the value of this axis' ticksPerGridline property, are in effect extended across the entire chart.

Parameters:
hasGridlines - true to display gridlines, false (the default) to not display them.
See Also:
getHasGridlines, setTicksPerGridline

setTickCount

public void setTickCount(int tickCount)
Sets the number of ticks to be placed on this axis. The default tick count is 10. Ticks are always evenly spaced across the entire axis, unless explicitly specified via addTick.

Note that setting the tick count overrides (erases) any ticks explicitly specified via addTick.

Parameters:
tickCount - the number of ticks for this axis.
See Also:
getTickCount, addTick(double), addTick(double, String), addTick(double,String,int,int), addTick(double,Widget), addTick(double,Widget,int,int), setTickLabelFormat, setTickLabelFontSize, setTickLabelFontStyle, setTickLabelFontColor, setTickLabelFontWeight

setTickLabelFontWeight

public void setTickLabelFontWeight(java.lang.String cssWeight)
Specifies the weight of the font used in this axis' tick labels.

Parameters:
cssWeight - the weight of the font, such as bold, normal, light, 100, 200, ... 900, for tick labels.
See Also:
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_WEIGHT

setTickLabelFontColor

public void setTickLabelFontColor(java.lang.String cssColor)
Specifies the color of the font used to render tick labels for this axis.

For more information on standard CSS color specifications see the discussion in Symbol.setBackgroundColor.

Parameters:
cssColor - color of the font used to display this axes' tick labels, in standard CSS format.
See Also:
getTickLabelFontColor, setTickLabelFormat, setTickCount, addTick(double), addTick(double,String), addTick(double,String,int,int), addTick(double,Widget), addTick(double,Widget,int,int), setTickLabelFontStyle, setTickLabelFontWeight, setTickLabelFontSize

setTickLabelFontStyle

public void setTickLabelFontStyle(java.lang.String cssStyle)
Specifies the CSS font-style of this axis' tick labels.

Parameters:
cssStyle - any valid CSS font-style, namely, normal, italic, oblique, or inherit.
See Also:
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_STYLE

setTickLabelFontSize

public void setTickLabelFontSize(int tickLabelFontSize)
Sets the tick label font size for tick labels on this axis, in pixels.

Parameters:
tickLabelFontSize - the font size of tick labels displayed on this axis.
See Also:
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_FONTSIZE

setTickLabelFormat

public 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. This string must follow the conventions of the number format patterns used by the GWT NumberFormat class, with three exceptions:

  1. Log10 inverse prefix: If the string begins with the prefix =10^ the value is replaced with pow(10.,value) and the so-transformed value is then formatted using the part of the format string that comes after this prefix, which must be a valid GWT NumberFormat pattern (e.g. "##.##").

    For an example of how to use this prefix to create a semi-log plot, see the Chart Gallery's GChartExample04.

  2. Log2 inverse prefix: If the string begins with the prefix =2^ the value is replaced with pow(2.,value) and the so-transformed value is then formatted using the part of the format string that comes after this prefix, which must be a valid GWT NumberFormat pattern.

  3. Date casting prefix: If the string begins with the prefix =(Date) the value is replaced with new Date((long) value) and the so-transformed value is then formatted using the format string that comes after this prefix, which must be a valid GWT DateTimeFormat pattern (e.g. "yyyy-MM-dd HH:mm"). For the special case format string of "=(Date)" (just the date casting prefix) GChart uses the DateTimeFormat returned by the DateTimeFormat.getShortDateTimeFormat method.

    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.

Parameters:
format - an appropriately prefixed GWT NumberFormat compatible or GWT DateTimeFormat compatible format string that defines how to convert tick values into tick labels.
See Also:
setTickCount, addTick(double), addTick(double,String), addTick(double,String,int,int), addTick(double,Widget), addTick(double,Widget,int,int), setTickLabelFontSize, setTickLabelFontStyle, setTickLabelFontColor, setTickLabelFontWeight, getTickLabelFormat

setTickLabelThickness

public 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.

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.

See Also:
getTickLabelThickness, getTickLabelFontSize, setAxisLabel, NAI

setTicksPerGridline

public void setTicksPerGridline(int ticksPerGridline)
Specifies the ratio of the number of tick marks on the axis, to the number of gridlines on the axis.

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.

Parameters:
ticksPerGridline - the number of ticks on this axis per "gridline-extended" tick.
See Also:
setHasGridlines, setTickCount, addTick(double), addTick(double,String), addTick(double,String,int,int), addTick(double,Widget), addTick(double,Widget,int,int)

setTicksPerLabel

public 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.

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.

Parameters:
ticksPerLabel - the ratio of the number of ticks, to the number of labeled ticks.
See Also:
setTickCount, addTick(double), addTick(double,String), addTick(double,String,int,int), addTick(double,Widget), addTick(double,Widget,int,int)

setTickLength

public abstract void setTickLength(int tickLength)
Sets this axes' tick length. Set the tick length to zero to eliminate the tick entirely.

Note that GChart ticks are always "outside" ticks.

Parameters:
tickLength - the length of the tick.
See Also:
getTickLength

setTickThickness

public abstract void setTickThickness(int tickThickness)
Sets this axes' tick thickness.

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.

Parameters:
tickThickness - the thickness of the tick.
See Also:
getTickThickness, setTickLength

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

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