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 AlignToPixelsCallbackgetAlignToPixelsCallback()Returns the user callback that setstrueto align pixel values to device pixels.AxisKindgetAxis()Which kind of axis this is.
Possible values are: 'x', 'y' or 'r'.AxisBuildTicksCallbackgetAxisBuildTicksCallback()Returns the user callback that runs before/after of the ticks building.AxisCalculateLabelRotationCallbackgetAxisCalculateLabelRotationCallback()Returns the user callback that runs before/after tick rotation is determined.AxisDataLimitsCallbackgetAxisDataLimitsCallback()Returns the user callback that runs before/after data limits are determined.AxisDimensionsCallbackgetAxisDimensionsCallback()Returns the user callback that runs before/after dimensions are set.AxisFitCallbackgetAxisFitCallback()Returns the user callback that runs before/after the scale fits to the canvas.AxisTickToLabelConversionCallbackgetAxisTickToLabelConversionCallback()Returns the user callback that runs before/after ticks are converted in the strings.AxisUpdateCallbackgetAxisUpdateCallback()Returns the user callback that runs before/after of the update process.IsColorgetBackgroundColor()Returns the background color of the scale area.StringgetBackgroundColorAsString()Returns the background color of the scale area.ColorCallback<ScaleContext>getBackgroundColorCallback()Returns the background color callback, if set, otherwisenull.intgetCharbaId()Returns the unique id of axis.IsChartgetChart()Returns the chart instanceprotected TgetConfiguration()Returns the configuration element.DisplaygetDisplay()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.DisplayCallback<ScaleContext>getDisplayCallback()Returns the user callback that sets if the axis will be shown.ScaleIdgetId()The ID is used to link datasets and scale axes together.
This is especially needed if multi-axes charts are used.ReverseCallbackgetReverseCallback()Returns the user callback that sets the reversed order of tick labels.AxisTypegetType()Returns the type of axis.doublegetWeight()The weight used to sort the axis.
Higher weights are further away from the chart area.ScaleWeightCallbackgetWeightCallback()Returns the user callback that sets the weight used to sort the axis.booleanisAlignToPixels()Returnstrueto align pixel values to device pixels.booleanisReverse()Returns the reversed 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.clientpackage.voidmerge(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.voidsetAlignToPixels(boolean alignToPixels)Setstrueto align pixel values to device pixels.voidsetAlignToPixels(AlignToPixelsCallback alignToPixelsCallback)Sets the user callback that setstrueto align pixel values to device pixels.voidsetAlignToPixels(NativeCallback alignToPixelsCallback)Sets the user callback that setstrueto align pixel values to device pixels.voidsetAxisBuildTicksCallback(AxisBuildTicksCallback axisBuildTicksCallback)Sets the user callback that runs before/after of the ticks building.voidsetAxisCalculateLabelRotationCallback(AxisCalculateLabelRotationCallback axisCalculateLabelRotationCallback)Sets the user callback that runs before/after tick rotation is determined.voidsetAxisDataLimitsCallback(AxisDataLimitsCallback axisDataLimitsCallback)Sets the user callback that runs before/after data limits are determined.voidsetAxisDimensionsCallback(AxisDimensionsCallback axisDimensionsCallback)Sets the user callback that runs before/after dimensions are set.voidsetAxisFitCallback(AxisFitCallback axisFitCallback)Sets the user callback that runs before/after the scale fits to the canvas.voidsetAxisTickToLabelConversionCallback(AxisTickToLabelConversionCallback axisTickToLabelConversionCallback)Sets the user callback that runs before/after ticks are converted in the strings.voidsetAxisUpdateCallback(AxisUpdateCallback axisUpdateCallback)Sets the user callback that runs before/after of the update process.voidsetBackgroundColor(String backgroundColor)Sets the background color of the scale area.voidsetBackgroundColor(ColorCallback<ScaleContext> backgroundColorCallback)Sets the background color callback.voidsetBackgroundColor(NativeCallback backgroundColorCallback)Sets the background color callback.voidsetBackgroundColor(IsColor backgroundColor)Sets the default background color to use in the chart, on all objects, if not override by the specific configuration.protected voidsetConfiguration(T configuration)voidsetDisplay(boolean display)If set to false the axis is hidden from view.
OverridesGrid.setDisplay(boolean),ScaleTitle.setDisplay(boolean), andTick.setDisplay(boolean).voidsetDisplay(DisplayCallback<ScaleContext> displayCallback)Sets the user callback that sets if the axis will be shown.voidsetDisplay(NativeCallback displayCallback)Sets the user callback that sets if the axis will be shown.voidsetDisplay(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.voidsetReverse(boolean reverse)Sets the reversed order of tick labels.voidsetReverse(NativeCallback reverseCallback)Sets the user callback that sets the reversed order of tick labels.voidsetReverse(ReverseCallback reverseCallback)Sets the user callback that sets the reversed order of tick labels.voidsetWeight(double weight)The weight used to sort the axis.
Higher weights are further away from the chart area.voidsetWeight(NativeCallback weightCallback)Sets the user callback that sets the weight used to sort the axis.voidsetWeight(ScaleWeightCallback weightCallback)Sets the user callback that sets the weight used to sort the axis.StringtoJSON()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.UNKNOWNif 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)
Setstrueto align pixel values to device pixels.- Parameters:
alignToPixels-trueto align pixel values to device pixels.
-
isAlignToPixels
public boolean isAlignToPixels()
Returnstrueto align pixel values to device pixels.- Returns:
trueto align pixel values to device pixels
-
setReverse
public void setReverse(boolean reverse)
Sets the reversed order of tick labels.- Parameters:
reverse- reversed order of tick labels.
-
isReverse
public boolean isReverse()
Returns the reversed order of tick labels.- Returns:
- reversed order of tick labels.
-
getDisplayCallback
public DisplayCallback<ScaleContext> getDisplayCallback()
Returns the user callback that sets if the axis will be shown.- Returns:
- the user callback that sets if the axis will be shown.
-
setDisplay
public void setDisplay(DisplayCallback<ScaleContext> displayCallback)
Sets the user callback that sets if the axis will be shown.- Parameters:
displayCallback- the user callback that sets if the axis will be shown
-
setDisplay
public void setDisplay(NativeCallback displayCallback)
Sets the user callback that sets if the axis will be shown.- Parameters:
displayCallback- that sets if the axis will be shown.
-
getBackgroundColorCallback
public ColorCallback<ScaleContext> getBackgroundColorCallback()
Returns the background color callback, if set, otherwisenull.- Returns:
- the background color callback, if set, otherwise
null.
-
setBackgroundColor
public void setBackgroundColor(ColorCallback<ScaleContext> backgroundColorCallback)
Sets the background color callback.- Parameters:
backgroundColorCallback- the background color callback.
-
setBackgroundColor
public void setBackgroundColor(NativeCallback backgroundColorCallback)
Sets the background color callback.- Parameters:
backgroundColorCallback- the background color callback.
-
getReverseCallback
public ReverseCallback getReverseCallback()
Returns the user callback that sets the reversed order of tick labels.- Returns:
- the user callback that sets the reversed order of tick labels.
-
setReverse
public void setReverse(ReverseCallback reverseCallback)
Sets the user callback that sets the reversed order of tick labels.- Parameters:
reverseCallback- the user callback that sets the reversed order of tick labels.
-
setReverse
public void setReverse(NativeCallback reverseCallback)
Sets the user callback that sets the reversed order of tick labels.- Parameters:
reverseCallback- that sets the reversed order of tick labels.
-
getAlignToPixelsCallback
public AlignToPixelsCallback getAlignToPixelsCallback()
Returns the user callback that setstrueto align pixel values to device pixels.- Returns:
- the user callback that sets
trueto align pixel values to device pixels.
-
setAlignToPixels
public void setAlignToPixels(AlignToPixelsCallback alignToPixelsCallback)
Sets the user callback that setstrueto align pixel values to device pixels.- Parameters:
alignToPixelsCallback- the user callback that setstrueto align pixel values to device pixels.
-
setAlignToPixels
public void setAlignToPixels(NativeCallback alignToPixelsCallback)
Sets the user callback that setstrueto align pixel values to device pixels.- Parameters:
alignToPixelsCallback- that setstrueto align pixel values to device pixels.
-
getWeightCallback
public ScaleWeightCallback getWeightCallback()
Returns the user callback that sets the weight used to sort the axis.- Returns:
- the user callback that sets the weight used to sort the axis.
-
setWeight
public void setWeight(ScaleWeightCallback weightCallback)
Sets the user callback that sets the weight used to sort the axis.- Parameters:
weightCallback- the user callback that sets the weight used to sort the axis.
-
setWeight
public void setWeight(NativeCallback weightCallback)
Sets the user callback that sets the weight used to sort the axis.- Parameters:
weightCallback- that sets the weight used to sort the axis.
-
getAxisCalculateLabelRotationCallback
public AxisCalculateLabelRotationCallback getAxisCalculateLabelRotationCallback()
Returns the user callback that runs before/after tick rotation is determined.- Returns:
- the user callback that runs before/after tick rotation is determined
-
setAxisCalculateLabelRotationCallback
public void setAxisCalculateLabelRotationCallback(AxisCalculateLabelRotationCallback axisCalculateLabelRotationCallback)
Sets the user callback that runs before/after tick rotation is determined.- Parameters:
axisCalculateLabelRotationCallback- the the user callback that runs before/after tick rotation is determined 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.clientpackage.- 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
-
-