|
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
com.googlecode.gchart.client.GChart.YAxis
public class GChart.YAxis
The left y-axis of a GChart.
getYAxis| Method Summary | |
|---|---|
double |
clientToModel(int clientCoordinate)
Converts a pixel, client-window coordinate position along this axis into the model units associated with this axis. |
double |
getDataMax()
Returns the maximum data value associated with values represented on this axis. |
double |
getDataMin()
Returns the minimum data value associated with values represented on this axis. |
double |
getMouseCoordinate()
Returns the coordinate along this axis that is associated with the last "GChart-tracked" mouse location. |
double |
modelToClient(double modelCoordinate)
Converts a coordinate position in the model units associated with this axis into a corresponding coordinate position expressed in standard GWT client-window pixel coordinates. |
double |
modelToPixel(double modelCoordinate)
Converts a coordinate position in the model units associated with this axis into a corresponding coordinate position expressed in GChart's decorated chart pixel coordinates. |
double |
modelToPlotAreaPixel(double modelCoordinate)
Converts a coordinate position in the model units associated with this axis into a corresponding coordinate position expressed in GChart's plot area pixel coordinates. |
double |
pixelToModel(int pixelCoordinate)
Converts a coordinate position in GChart's decorated chart pixel coordinates into the model units associated with this axis. |
double |
plotAreaPixelToModel(int pixelCoordinate)
Converts a coordinate position in GChart's plot area pixel coordinates into the model units associated with this axis. |
void |
setTickLength(int tickLength)
Sets this axis' tick length. |
void |
setTickThickness(int tickThickness)
Sets this axis' tick thickness. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public double clientToModel(int clientCoordinate)
GChart.AxisFor example, if the client coordinate associated with this axis' midpoint were passed to this method, it would return (getAxisMin() + getAxisMax())/2.0.
Note that the client/model coordinate mapping used is as of the last update. Before the first update, this method returns GChart.NaN. This method also invokes either getAbsoluteTop (for the y or y2 axis) or getAbsoluteLeft (for the x axis), and these GWT methods return 0 if the chart isn't actually rendered within the browser. So, results likely won't be useful to you until after the page containing your chart becomes visible to the user. Since most applications are expected to invoke this method in response to the user mousing over the page, these requirements should usually be satisfied.
Saurabh Hirani in this GWT Forum post and in GChart issue #22 most recently suggested the need for client to model coordinate mapping. Client to model conversion was requested earlier in GChart issue #9 from yoxel.com.
clientToModel in class GChart.AxisclientCoordinate - a pixel-based coordinate that defines
the dimension associated with this axis in the standard
client window coordinates of GWT.
getMouseCoordinate,
modelToClient,
pixelToModel,
modelToPixelpublic double getDataMax()
GChart.Axis
getDataMax in class GChart.AxisgetDataMin,
getAxisMax,
getAxisMinpublic double getDataMin()
GChart.Axis
getDataMin in class GChart.AxisgetDataMax,
getAxisMax,
getAxisMaxpublic double getMouseCoordinate()
GChart.AxisThe coordinate returned is in the "scale" associated with the axis. For example, if the axis mininum is 0 and the maximum is 100, and the mouse is at the axis midpoint, this method would return 50.
The main intended use for this method is to allow you to create points that, if they have x and y coordinates defined by calling this method on appropriate axes, will be positioned on the chart at the last GChart-tracked mouse location.
As the user moves their mouse over the chart, GChart watches those mouse moves and updates it's currently "tracked" mouse location. That internally maintained position is the basis for the value returned by this method. Note that the actual, physical, mouse cursor position could differ from this GChart-tracked position because:
In other words, this routine tells you where, for hit testing and hover selection feedback purposes, GChart considers the mouse to be, not the actual physical location of the mouse. Despite the potential for differences, in most cases, with the default setting of setHoverTouchingEnabled(true), and when you are not over the opened hover widget, you can use the value returned by this method as if it represented the physical mouse location.
For an example that uses this method to create points at the current mouse location within a very simple line chart editor, see the Chart Gallery's GChartExample22a.
getMouseCoordinate in class GChart.AxisclientToModel,
modelToClient,
pixelToModel,
modelToPixel,
setHoverTouchingEnabledpublic double modelToClient(double modelCoordinate)
GChart.AxisFor example, consider a completely undecorated chart (no axes, tick labels, legend keys, etc.) that exactly fills a 1000px wide client window, and whose x-axis min and max are 0 and 100. Then getXAxis().modelToClient(50) would return 500.
Note that the client/model coordinate mapping used is as of the last update. Before the first update, this method returns GChart.NaN. This method also invokes either getAbsoluteTop (for the y or y2 axis) or getAbsoluteLeft (for the x axis), and these GWT methods return 0 if the chart isn't actually rendered within the browser. So, results likely won't be useful to you until after the page containing your chart becomes visible to the user. Since most applications are expected to invoke this method in response to the user mousing over the page, these requirements should usually be satisfied.
modelToClient in class GChart.AxismodelCoordinate - the position along this axis defined
in the model units associated with this axis.
getMouseCoordinate,
clientToModel,
pixelToModel,
modelToPixelpublic double modelToPixel(double modelCoordinate)
GChart.AxisThese coordinates have their origin at the upper left corner of the decorated GChart, and x pixel-coordinates that increase as you move right, and y pixel-coordinates that increase as you move down. They are related to GWT's standard client window coordinates via the following equations:
xClient = plotPanel.getAbsoluteLeft()
- Window.getScrollLeft()
+ xPixel;
yClient = plotPanel.getAbsoluteTop()
- Window.getScrollTop()
+ yPixel;
In the above plotPanel is an internal AbsolutePanel GChart creates to hold the entire, decorated, chart. Apart from borders and such applied to the GChart as a whole, its absolute top and left positions should be the same as those of the GChart itself.
Tip: In applications that continuously track mouse moves over the chart, and where absolute and scroll positions cannot change, you can gain a significant performance boost by computing the difference between pixel and client coordinates once (modelToPixel(axisMin)-modelToClient(axisMin)) and then adding that difference to the client coordinates to get the pixel coordinates, and then using pixelToModel, instead of using clientToModel directly, which must repeatedly call GWT's scroll and absolute position methods.
For example, for a completely undecorated chart (no tick labels, legend keys, etc.) the plot area takes up the entire chart. In that case, if the pixel units of the plot area range from 0...100 along this axis, and the model coordinates range from 0...10 along this axis, then modelToPixel(modelCoordinate) returns 10*modelCoordinate.
The model/pixel mapping is as of the last update; this method returns Double.NaN before the first update. Note that, unlike clientToModel and modelToClient, the GChart does not need to be actually rendered within the browser for you to use this method--a call to update is sufficient.
Tip: If you need to access this mapping before the first real update, you can explicitly specify the min and max of this axis via setAxisMin and setAxisMax, and then call update before adding any curves to the chart (which, since the chart is empty, should be very fast). This approach will allow you to convert between model and pixel coordinates before the first real update, and before the chart is rendered in the browser.
modelToPixel in class GChart.AxismodelCoordinate - a position on this axis expressed
in the model units associated with this axis.
getMouseCoordinate,
clientToModel,
modelToClient,
modelToClient,
pixelToModelpublic double modelToPlotAreaPixel(double modelCoordinate)
GChart.AxisThese coordinates have their origin at the upper left corner of the plot area, and x pixel-coordinates that increase as you move right, and y pixel-coordinates that increase as you move down.
The plot area is the rectangular region bounded by the chart's axes, and with a size specified via setChartSize, where the chart's curves are typically displayed.
Apart from a shift in the origin of the pixel coordinates used, this method works just like modelToPixel; see that method for additional details, tips, and restrictions.
modelToPlotAreaPixel in class GChart.AxismodelCoordinate - a position on this axis expressed
in the model units associated with this axis.
getMouseCoordinate,
plotAreaPixelToModel,
modelToPixel,
setChartSizepublic double pixelToModel(int pixelCoordinate)
GChart.AxisGChart's decorated chart pixel coordinates have their origin at the upper left corner of the decorated GChart, and x pixel-coordinates that increase as you move right, and y pixel-coordinates that increase as you move down. They are related to GWT's standard client window coordinates via the following equations:
xClient = plotPanel.getAbsoluteLeft()
- Window.getScrollLeft()
+ xPixel;
yClient = plotPanel.getAbsoluteTop()
- Window.getScrollTop()
+ yPixel;
In the above plotPanel is an internal AbsolutePanel GChart creates to hold the entire, decorated, chart. Apart from borders and such applied to the GChart as a whole, its absolute top and left positions should be the same as those of the GChart itself.
For example, for a completely undecorated chart (no tick labels, legend keys, etc.) the plot area takes up the entire chart. In that case, if the pixel units of the plot area range from 0...100 along this axis, and the model coordinates range from 0...10 along this axis, then pixelToModel(pixelCoordinate) returns pixelCoordinate/10..
The model/pixel mapping is as of the last update; this method returns Double.NaN before the first update. Note that, unlike clientToModel and modelToClient, the GChart does not need to be actually rendered within the browser for you to use this method.
Tip: If you need to access this mapping before the first real update, you can explicitly specify the min and max of this axis via setAxisMin and setAxisMax, and then call update before adding any curves to the chart (which, since the chart is empty, should be very fast). This approach will allow you to convert between model and pixel coordinates before the first real update, and before the chart is rendered in the browser.
pixelToModel in class GChart.AxispixelCoordinate - the distance,
in pixels, from the left edge (for the x axis) or top
edge (for the y or y2 axis) of
the decorated chart to a point on this axis.
getMouseCoordinate,
clientToModel,
modelToClient,
modelToPixel,
plotAreaPixelToModelpublic double plotAreaPixelToModel(int pixelCoordinate)
GChart.AxisGChart's plot area pixel coordinates have their origin at the upper left corner of the plot area, and x pixel-coordinates that increase as you move right, and y pixel-coordinates that increase as you move down.
The plot area is the rectangular region bounded by the chart's axes, and with a size specified via setChartSize, where the chart's curves are typically displayed.
Apart from a shift in the origin of the pixel coordinates used, this method works just like pixelToModel; see that method for additional details, tips, and restrictions.
plotAreaPixelToModel in class GChart.AxispixelCoordinate - the distance,
in pixels, from the left edge (for the x axis) or top
edge (for the y or y2 axis) of
the plot area to a point on this axis.
modelToPlotAreaPixel,
pixelToModel,
setChartSizepublic void setTickLength(int tickLength)
GChart.Axis
setTickLength in class GChart.AxistickLength - the length of the tick.getTickLength,
setTickThickness,
setTickLabelPadding,
setTickLocationpublic void setTickThickness(int tickThickness)
GChart.Axis
setTickThickness in class GChart.AxistickThickness - the thickness of the tick.getTickThickness,
setTickLength,
setTickLabelPadding,
setTickLocation
|
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 | ||||||||