Class Axis
- java.lang.Object
-
- org.pepstock.charba.client.configuration.Axis
-
- Direct Known Subclasses:
CartesianAxis
,ProjectionAxis
,RadialAxis
public abstract class Axis extends Object
Axes are an integral part of a chart.
They are used to determine how data maps to a pixel value on the chart.
It contains a number of config callbacks that can be used to change parameters in the scale at different points in the update process.- Author:
- Andrea "Stock" Stocchero
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AxisKind
getAxis()
Which kind of axis this is.
Possible values are: 'x', 'y' or 'r'.AxisBuildTicksCallback
getAxisBuildTicksCallback()
Returns the user callback that runs before/after of the ticks building.AxisCalculateLabelRotationCallback
getAxisCalculateLabelRotationCallback()
Returns the user callback that runs before/after tick rotation is determined.AxisDataLimitsCallback
getAxisDataLimitsCallback()
Returns the user callback that runs before/after data limits are determined.AxisDimensionsCallback
getAxisDimensionsCallback()
Returns the user callback that runs before/after dimensions are set.AxisFitCallback
getAxisFitCallback()
Returns the user callback that runs before/after the scale fits to the canvas.AxisTickToLabelConversionCallback
getAxisTickToLabelConversionCallback()
Returns the user callback that runs before/after ticks are converted in the strings.AxisUpdateCallback
getAxisUpdateCallback()
Returns the user callback that runs before/after of the update process.IsColor
getBackgroundColor()
Returns the background color of the scale area.String
getBackgroundColorAsString()
Returns the background color of the scale area.int
getCharbaId()
Returns the unique id of axis.IsChart
getChart()
Returns the chart instanceprotected T
getConfiguration()
Returns the configuration element.Display
getDisplay()
The display option controls the visibility of axis.
Controls the axis global visibility (visible when true, hidden when false).
WhenDisplay.AUTO
, the axis is visible only if at least one associated data set is visible.ScaleId
getId()
The ID is used to link datasets and scale axes together.
This is especially needed if multi-axes charts are used.AxisType
getType()
Returns the type of axis.double
getWeight()
The weight used to sort the axis.
Higher weights are further away from the chart area.boolean
isAlignToPixels()
Returnstrue
to align pixel values to device pixels.boolean
isReverse()
Returns the reverses order of tick labels.ChartEnvelop<NativeObject>
loadNativeObject(ChartEnvelop<NativeObject> envelop)
Returns the native object instance inside an envelop.
It can be called only fromorg.pepstock.charba.client
package.void
merge(NativeObjectContainer source, String property)
Merge a native object in the this one with a specific property name.
This is used by plugins implementation (native java script ones) when they are not using the standard way to add plugin configuration in the options of chart.void
setAlignToPixels(boolean alignToPixels)
Setstrue
to align pixel values to device pixels.void
setAxisBuildTicksCallback(AxisBuildTicksCallback axisBuildTicksCallback)
Sets the user callback that runs before/after of the ticks building.void
setAxisCalculateLabelRotationCallback(AxisCalculateLabelRotationCallback axisCalculateLabelRotationCallback)
Sets the user callback that runs before/after tick rotation is determined.void
setAxisDataLimitsCallback(AxisDataLimitsCallback axisDataLimitsCallback)
Sets the user callback that runs before/after data limits are determined.void
setAxisDimensionsCallback(AxisDimensionsCallback axisDimensionsCallback)
Sets the user callback that runs before/after dimensions are set.void
setAxisFitCallback(AxisFitCallback axisFitCallback)
Sets the user callback that runs before/after the scale fits to the canvas.void
setAxisTickToLabelConversionCallback(AxisTickToLabelConversionCallback axisTickToLabelConversionCallback)
Sets the user callback that runs before/after ticks are converted in the strings.void
setAxisUpdateCallback(AxisUpdateCallback axisUpdateCallback)
Sets the user callback that runs before/after of the update process.void
setBackgroundColor(String backgroundColor)
Sets the background color of the scale area.void
setBackgroundColor(IsColor backgroundColor)
Sets the default background color to use in the chart, on all objects, if not override by the specific configuration.protected void
setConfiguration(T configuration)
void
setDisplay(boolean display)
If set to false the axis is hidden from view.
OverridesGrid.setDisplay(boolean)
,ScaleTitle.setDisplay(boolean)
, andTick.setDisplay(boolean)
.void
setDisplay(Display display)
The display option controls the visibility of axis.
Controls the axis global visibility (visible when true, hidden when false).
WhenDisplay.AUTO
, the axis is visible only if at least one associated data set is visible.void
setReverse(boolean reverse)
Sets the reverses order of tick labels.void
setWeight(double weight)
The weight used to sort the axis.
Higher weights are further away from the chart area.String
toJSON()
Returns the JSON representation of the object.
-
-
-
Method Detail
-
getCharbaId
public final int getCharbaId()
Returns the unique id of axis.- Returns:
- the unique id of axis
-
getId
public final ScaleId getId()
The ID is used to link datasets and scale axes together.
This is especially needed if multi-axes charts are used.- Returns:
- The ID is used to link datasets and scale axes together or
DefaultScaleId.UNKNOWN
if not set
-
getType
public final AxisType getType()
Returns the type of axis.- Returns:
- the type of axis
-
getAxis
public final AxisKind getAxis()
Which kind of axis this is.
Possible values are: 'x', 'y' or 'r'.- Returns:
- the kind of axis.
-
setDisplay
public void setDisplay(boolean display)
If set to false the axis is hidden from view.
OverridesGrid.setDisplay(boolean)
,ScaleTitle.setDisplay(boolean)
, andTick.setDisplay(boolean)
.- Parameters:
display
- If set to false the axis is hidden from view.
OverridesGrid.setDisplay(boolean)
,ScaleTitle.setDisplay(boolean)
, andTick.setDisplay(boolean)
.
-
setDisplay
public final void setDisplay(Display display)
The display option controls the visibility of axis.
Controls the axis global visibility (visible when true, hidden when false).
WhenDisplay.AUTO
, the axis is visible only if at least one associated data set is visible.- Parameters:
display
- display option controls the visibility of axis
-
getDisplay
public final Display getDisplay()
The display option controls the visibility of axis.
Controls the axis global visibility (visible when true, hidden when false).
WhenDisplay.AUTO
, the axis is visible only if at least one associated data set is visible.- Returns:
- display option controls the visibility of axis
-
setBackgroundColor
public void setBackgroundColor(IsColor backgroundColor)
Sets the default background color to use in the chart, on all objects, if not override by the specific configuration.- Parameters:
backgroundColor
- background color to use in the chart.
-
setBackgroundColor
public void setBackgroundColor(String backgroundColor)
Sets the background color of the scale area.- Parameters:
backgroundColor
- the background color of the scale area.
-
getBackgroundColorAsString
public String getBackgroundColorAsString()
Returns the background color of the scale area.- Returns:
- the background color of the scale area.
-
getBackgroundColor
public IsColor getBackgroundColor()
Returns the background color of the scale area.- Returns:
- the background color of the scale area.
-
setWeight
public void setWeight(double weight)
The weight used to sort the axis.
Higher weights are further away from the chart area.- Parameters:
weight
- weight of axis
-
getWeight
public double getWeight()
The weight used to sort the axis.
Higher weights are further away from the chart area.- Returns:
- weight of axis
-
setAlignToPixels
public void setAlignToPixels(boolean alignToPixels)
Setstrue
to align pixel values to device pixels.- Parameters:
alignToPixels
-true
to align pixel values to device pixels.
-
isAlignToPixels
public boolean isAlignToPixels()
Returnstrue
to align pixel values to device pixels.- Returns:
true
to align pixel values to device pixels
-
setReverse
public void setReverse(boolean reverse)
Sets the reverses order of tick labels.- Parameters:
reverse
- reverses order of tick labels.
-
isReverse
public boolean isReverse()
Returns the reverses order of tick labels.- Returns:
- reverses order of tick labels.
-
getAxisCalculateLabelRotationCallback
public AxisCalculateLabelRotationCallback getAxisCalculateLabelRotationCallback()
Returns the user callback that runs before/after tick rotation is determined.- Returns:
- the axisCalculateLabelRotationCallback
-
setAxisCalculateLabelRotationCallback
public void setAxisCalculateLabelRotationCallback(AxisCalculateLabelRotationCallback axisCalculateLabelRotationCallback)
Sets the user callback that runs before/after tick rotation is determined.- Parameters:
axisCalculateLabelRotationCallback
- the axisCalculateLabelRotationCallback to set
-
getAxisDataLimitsCallback
public AxisDataLimitsCallback getAxisDataLimitsCallback()
Returns the user callback that runs before/after data limits are determined.- Returns:
- the user callback that runs before/after data limits are determined
-
setAxisDataLimitsCallback
public void setAxisDataLimitsCallback(AxisDataLimitsCallback axisDataLimitsCallback)
Sets the user callback that runs before/after data limits are determined.- Parameters:
axisDataLimitsCallback
- the user callback that runs before/after data limits are determined
-
getAxisDimensionsCallback
public AxisDimensionsCallback getAxisDimensionsCallback()
Returns the user callback that runs before/after dimensions are set.- Returns:
- the user callback that runs before/after dimensions are set
-
setAxisDimensionsCallback
public void setAxisDimensionsCallback(AxisDimensionsCallback axisDimensionsCallback)
Sets the user callback that runs before/after dimensions are set.- Parameters:
axisDimensionsCallback
- the user callback that runs before/after dimensions are set
-
getAxisFitCallback
public AxisFitCallback getAxisFitCallback()
Returns the user callback that runs before/after the scale fits to the canvas.- Returns:
- the user callback that runs before/after the scale fits to the canvas
-
setAxisFitCallback
public void setAxisFitCallback(AxisFitCallback axisFitCallback)
Sets the user callback that runs before/after the scale fits to the canvas.- Parameters:
axisFitCallback
- the user callback that runs before/after the scale fits to the canvas
-
getAxisTickToLabelConversionCallback
public AxisTickToLabelConversionCallback getAxisTickToLabelConversionCallback()
Returns the user callback that runs before/after ticks are converted in the strings.- Returns:
- the user callback that runs before/after ticks are converted in the strings
-
setAxisTickToLabelConversionCallback
public void setAxisTickToLabelConversionCallback(AxisTickToLabelConversionCallback axisTickToLabelConversionCallback)
Sets the user callback that runs before/after ticks are converted in the strings.- Parameters:
axisTickToLabelConversionCallback
- the user callback that runs before/after ticks are converted in the strings
-
getAxisBuildTicksCallback
public AxisBuildTicksCallback getAxisBuildTicksCallback()
Returns the user callback that runs before/after of the ticks building.- Returns:
- the user callback that runs before/after of the ticks building
-
setAxisBuildTicksCallback
public void setAxisBuildTicksCallback(AxisBuildTicksCallback axisBuildTicksCallback)
Sets the user callback that runs before/after of the ticks building.- Parameters:
axisBuildTicksCallback
- the user callback that runs before/after of the ticks building
-
getAxisUpdateCallback
public AxisUpdateCallback getAxisUpdateCallback()
Returns the user callback that runs before/after of the update process.- Returns:
- the user callback that runs before/after of the update process
-
setAxisUpdateCallback
public void setAxisUpdateCallback(AxisUpdateCallback axisUpdateCallback)
Sets the user callback that runs before/after of the update process.- Parameters:
axisUpdateCallback
- the user callback that runs before/after of the update process
-
setConfiguration
protected final void setConfiguration(T configuration)
- Parameters:
configuration
- the configuration to set
-
getConfiguration
protected final T getConfiguration()
Returns the configuration element.- Returns:
- the configuration element.
-
merge
public final void merge(NativeObjectContainer source, String property)
Merge a native object in the this one with a specific property name.
This is used by plugins implementation (native java script ones) when they are not using the standard way to add plugin configuration in the options of chart.- Parameters:
source
- native object container to addproperty
- property name
-
toJSON
public final String toJSON()
Returns the JSON representation of the object.- Returns:
- the JSON representation of the object.
-
loadNativeObject
public final ChartEnvelop<NativeObject> loadNativeObject(ChartEnvelop<NativeObject> envelop)
Returns the native object instance inside an envelop.
It can be called only fromorg.pepstock.charba.client
package.- Parameters:
envelop
- envelop instance which will contain the native object- Returns:
- the envelop, passed as argument, loaded with the native object
-
getChart
public final IsChart getChart()
Returns the chart instance- Returns:
- the chart
-
-