public final class

ChartAxis

com.artfulbits.aiCharts.Base.ChartAxis

Class Overview

Represents chart axis element. Instantiated either by aiChart engine or manually for customizations purposes. Axis may be rendered differently depending on CoordinateSystem that corresponds to type represented by series.
For Cartesian coordinate system:

For Polar coordinate system:

Generally, axis consists of five visual elements: grid, labels, main axis line, labels ticks and title.

XML Attributes
format Defines labels format
tick Defines tick mode
ticksize Defines ticks size
inverted Defines whether axis is inverted
title Defines title
padding Defines padding
spacing Defines spacing
min Defines min value
max Defines max value
interval Defines axis interval
gridLinesColor Defines color used to draw grid lines

Summary

Nested Classes
class ChartAxis.Label Represents axis label. 
enum ChartAxis.LabelLayoutMode Labels layout mode enumeration. 
enum ChartAxis.LabelPosition Determines axis labels position relatively to axis line. 
interface ChartAxis.LabelsAdapter Interface to implement custom labels generation. 
enum ChartAxis.Position Represents axis position enumeration. 
interface ChartAxis.ScaleChangeListener  
enum ChartAxis.TickMarkMode Represents mode that is used to draw tick marks. 
enum ChartAxis.ValueType Identifies type of value that is represented by axis labels. 
Fields
public static final ChartAxis.LabelsAdapter DEFAULT_LABELS_ADAPTER Label adapter that represent in configuration XML in 'labels_mode' attribute as 'RangeLabels'
public static final ChartAxis.LabelsAdapter SERIES_LABELS_ADAPTER Label adapter that represent in configuration XML in 'labels_mode' attribute as 'SeriesLabels'
public static final ChartAxis.LabelsAdapter SMART_LABELS_ADAPTER Label adapter that represent in configuration XML in 'labels_mode' attribute as 'HybridLabels'
Public Constructors
ChartAxis(ChartAxis.Position position)
Initializes the new ChartAxis instance.
Public Methods
double coeficientToValue(double coeficient)
Converts absolute portion of axis to ranged value.
Drawable getBackground()
@return
RectF getBounds()
Gets the rectangular area occupied by axis.
ChartCollection<ChartAxis.Label> getCustomLabels()
Get the collection of custom labels.
Format getFormat()
This method is deprecated. Renamed to getLabelFormat()
Paint getGridLinePaint()
Gets the Paint object that is used to draw grid lines.
boolean getGridVisible()
Gets the value indicating whether axis grid is visible.
Alignment getLabelAlignment()
Gets value the indicating labels alignment.
float getLabelAngle()
Gets rotation angle of labels
Format getLabelFormat()
Gets the Format instance to use for the format labels.
ChartAxis.LabelLayoutMode getLabelLayoutMode()
Gets value determining labels layout mode.
TextPaint getLabelPaint()
Gets the TextPaint object that is used to draw axis labels.
ChartAxis.LabelPosition getLabelPosition()
Gets value indicating how labels should be positioned on axis line.
ChartAxis.LabelsAdapter getLabelsAdapter()
Returns current label adapter.
Paint getLinePaint()
Gets the Paint object that is used to draw axis line and ticks.
double getOrigin()
Gets the origin value for axis.
int getPadding()
Gets the padding value for axis.
ChartAxis.Position getPosition()
Gets the position of axis.
ChartAxisScale getScale()
Gets instance of ChartAxisScale object that is in change of axis range calculations.
ChartAxis.ScaleChangeListener getScaleChangeListener()
ChartAxisScrollBar getScrollBar()
Gets instance of ChartAxisScrollBar to customize axis scrollbar.
boolean getShowLabels()
Gets value identifying whether labels should be shown for this axis.
int getSpacing()
Gets value indicating distance between axis elements.
ChartCollection<ChartAxisStripLine> getStripLines()
Get the collection of strip lines.
ChartAxis.TickMarkMode getTickMarkMode()
Gets the mode used to draw tick marks.
int getTickMarkSize()
Gets the mode used to draw tick marks.
String getTitle()
Gets the string representation of axis' title.
Alignment getTitleAlignment()
Gets value the indicating title alignment.
Paint getTitlePaint()
Gets the TextPaint object that is used to draw axis title.
ChartAxis.ValueType getValueType()
Gets the type of value that is used to represent axis labels.
boolean isInverted()
Indicates whether axis is inverted.
boolean isScrollBarEnabled()
Gets value determining whether scrollbar for this axis was enabled.
boolean isVisible()
Gets the visibility state for this element.
void setBackground(Drawable drawable)
void setFormat(Format format)
This method is deprecated. Renamed to setLabelFormat(Format)
void setFormat(String format)
This method is deprecated. setFormat(Format) with MessageFormat parameter.
void setGridLineColor(int color)
Sets color used to draw ticks grid lines.
void setGridVisible(boolean value)
Sets the value indicating whether area grid is visible.
void setInverted(boolean inverted)
Indicates whether axis is inverted.
void setLabelAlignment(Alignment alignment)
Sets value the indicating labels alignment.
void setLabelAngle(float angle)
Sets rotation angle of labels
void setLabelFormat(Format format)
Sets the Format instance to use for the format labels.
void setLabelLayoutMode(ChartAxis.LabelLayoutMode mode)
Sets value determining labels layout mode.
void setLabelPosition(ChartAxis.LabelPosition position)
Sets value indicating how labels should be positioned on axis line.
void setLabelsAdapter(ChartAxis.LabelsAdapter adapter)
Sets adapter that provide custom labels generation.
void setLineType(float width, int color)
Sets line parameters that is used to draw main axis line.
void setOrigin(double origin)
Sets the origin value for axis.
void setPadding(int padding)
Sets the padding value for axis.
void setPosition(ChartAxis.Position position)
Sets the position of axis.
void setScaleChangeListener(ChartAxis.ScaleChangeListener scaleChangeListener)
Sets instance of ChartAxis.ScaleChangeListener to listen scale changes.
void setScrollBarEnabled(boolean enabled)
Enables/disables scrollbar for this axis.
void setShowLabels(boolean showLabels)
Sets value determining whether labels should be drawn for this axis.
void setSpacing(int spacing)
Sets value indicating distance between axis elements.
void setTickMarkMode(ChartAxis.TickMarkMode mode)
Sets mode for the tick marks.
void setTickMarkSize(int size)
Sets size for the tick marks.
void setTitle(String title)
Sets the title for axis.
void setTitleAlignment(Alignment alignment)
Sets value the indicating title alignment.
void setValueType(ChartAxis.ValueType type)
Sets type of value that should be represented by axis labels.
void setVisible(boolean visible)
Sets visibility of this element on parent ChartView.
double valueToCoeficient(double value)
Converts ranged axis value to absolute portion of axis.

Fields

public static final ChartAxis.LabelsAdapter DEFAULT_LABELS_ADAPTER

Label adapter that represent in configuration XML in 'labels_mode' attribute as 'RangeLabels'

public static final ChartAxis.LabelsAdapter SERIES_LABELS_ADAPTER

Label adapter that represent in configuration XML in 'labels_mode' attribute as 'SeriesLabels'

public static final ChartAxis.LabelsAdapter SMART_LABELS_ADAPTER

Label adapter that represent in configuration XML in 'labels_mode' attribute as 'HybridLabels'

Public Constructors

public ChartAxis (ChartAxis.Position position)

Initializes the new ChartAxis instance.

Parameters
position instance of ChartAxis.Position to identify axis layout.

Public Methods

public double coeficientToValue (double coeficient)

Converts absolute portion of axis to ranged value.

Parameters
coeficient absolute portion of axis.
Returns
  • ranged value.

public Drawable getBackground ()

@return

public RectF getBounds ()

Gets the rectangular area occupied by axis.

Returns
  • RectF rectangle containing bounds.

public ChartCollection<ChartAxis.Label> getCustomLabels ()

Get the collection of custom labels. Neither ValueType , LabelsAdapter, or Format is taken into consideration for custom labels.

Returns
  • collection of custom labels.

public Format getFormat ()

This method is deprecated.
Renamed to getLabelFormat()

Gets the Format instance to use for the format labels.

Returns

public Paint getGridLinePaint ()

Gets the Paint object that is used to draw grid lines.

Returns
  • paint object instance.

public boolean getGridVisible ()

Gets the value indicating whether axis grid is visible.

 axis.setGridVisible(false);
 
will provide similar output:

Returns
  • true if area's grid is visible, otherwise false.

public Alignment getLabelAlignment ()

Gets value the indicating labels alignment.

Returns

public float getLabelAngle ()

Gets rotation angle of labels

Returns
  • angle value.

public Format getLabelFormat ()

Gets the Format instance to use for the format labels.

Returns

public ChartAxis.LabelLayoutMode getLabelLayoutMode ()

Gets value determining labels layout mode.

Returns

public TextPaint getLabelPaint ()

Gets the TextPaint object that is used to draw axis labels.

Returns
  • paint object instance.

public ChartAxis.LabelPosition getLabelPosition ()

Gets value indicating how labels should be positioned on axis line.

Returns
  • value of current labels position.

public ChartAxis.LabelsAdapter getLabelsAdapter ()

Returns current label adapter.

Returns

public Paint getLinePaint ()

Gets the Paint object that is used to draw axis line and ticks.

Returns
  • paint object instance.

public double getOrigin ()

Gets the origin value for axis.

Returns
  • value of origin.

public int getPadding ()

Gets the padding value for axis.

Returns
  • value of padding.

public ChartAxis.Position getPosition ()

Gets the position of axis.

Returns

public ChartAxisScale getScale ()

Gets instance of ChartAxisScale object that is in change of axis range calculations.

Returns
  • instance of current axis scale.
See Also

public ChartAxis.ScaleChangeListener getScaleChangeListener ()

Returns

public ChartAxisScrollBar getScrollBar ()

Gets instance of ChartAxisScrollBar to customize axis scrollbar.

Returns

public boolean getShowLabels ()

Gets value identifying whether labels should be shown for this axis.

Returns
  • true, if labels should be present on this axis, otherwise false.

public int getSpacing ()

Gets value indicating distance between axis elements.

Returns
  • value of spacing applied to all axis elements.

public ChartCollection<ChartAxisStripLine> getStripLines ()

Get the collection of strip lines.

Returns
  • collection of strip lines

public ChartAxis.TickMarkMode getTickMarkMode ()

Gets the mode used to draw tick marks.

Returns

public int getTickMarkSize ()

Gets the mode used to draw tick marks.

Returns

public String getTitle ()

Gets the string representation of axis' title.

Returns

public Alignment getTitleAlignment ()

Gets value the indicating title alignment.

Returns

public Paint getTitlePaint ()

Gets the TextPaint object that is used to draw axis title.

Returns
  • paint object instance.

public ChartAxis.ValueType getValueType ()

Gets the type of value that is used to represent axis labels.

Returns

public boolean isInverted ()

Indicates whether axis is inverted.

Returns
  • inverted is inverted.

public boolean isScrollBarEnabled ()

Gets value determining whether scrollbar for this axis was enabled.

Returns
  • true, if this axis will draw the scrollbar when necessary, otherwise false.

public boolean isVisible ()

Gets the visibility state for this element.

Returns
  • true if element is visible, otherwise false.

public void setBackground (Drawable drawable)

public void setFormat (Format format)

This method is deprecated.
Renamed to setLabelFormat(Format)

Sets the Format instance to use for the format labels.

Parameters
format Format instance

public void setFormat (String format)

This method is deprecated.
setFormat(Format) with MessageFormat parameter.

Sets the formatting pattern for axis labels. This method is deprecated. Use setFormat(Format)

Parameters
format String format.

public void setGridLineColor (int color)

Sets color used to draw ticks grid lines. Passed value is applied on wrapped Paint that participates in axis grid lines drawing. This object is exposed via getGridLinePaint() method.

Parameters
color value of color that will be used to draw area grid lines.

public void setGridVisible (boolean value)

Sets the value indicating whether area grid is visible.

Parameters
value true if area's grid should be visible, otherwise false.

public void setInverted (boolean inverted)

Indicates whether axis is inverted.

Parameters
inverted the inverted to set

public void setLabelAlignment (Alignment alignment)

Sets value the indicating labels alignment.

Parameters
alignment Alignment value

public void setLabelAngle (float angle)

Sets rotation angle of labels

Parameters
angle labels angle

public void setLabelFormat (Format format)

Sets the Format instance to use for the format labels.

Parameters
format Format instance

public void setLabelLayoutMode (ChartAxis.LabelLayoutMode mode)

Sets value determining labels layout mode. (Horizontal axes only)

Parameters
mode instance of ChartAxis.LabelLayoutMode

public void setLabelPosition (ChartAxis.LabelPosition position)

Sets value indicating how labels should be positioned on axis line.

Parameters
position value of desired labels position.

public void setLabelsAdapter (ChartAxis.LabelsAdapter adapter)

Sets adapter that provide custom labels generation.

Parameters
adapter instance of ChartAxis.LabelsAdapter

public void setLineType (float width, int color)

Sets line parameters that is used to draw main axis line.

Parameters
width width of line.
color color of line represented by HEX value.

public void setOrigin (double origin)

Sets the origin value for axis. Use Double.POSITIVE_INFINITY value to set maximal value of scale and Double.NEGATIVE_INFINITY to set minimal value of scale.

Parameters
origin value of origin.

public void setPadding (int padding)

Sets the padding value for axis.

Parameters
padding value of padding.

public void setPosition (ChartAxis.Position position)

Sets the position of axis.

Parameters
position of ChartAxis.Position.

public void setScaleChangeListener (ChartAxis.ScaleChangeListener scaleChangeListener)

Sets instance of ChartAxis.ScaleChangeListener to listen scale changes.

Parameters
scaleChangeListener instance of ChartAxis.ScaleChangeListener

public void setScrollBarEnabled (boolean enabled)

Enables/disables scrollbar for this axis.

Parameters
enabled true, if scrollbar should be enabled, otherwise false.

public void setShowLabels (boolean showLabels)

Sets value determining whether labels should be drawn for this axis.

Parameters
showLabels true, if labels should be present on this axis, otherwise false.
See Also

public void setSpacing (int spacing)

Sets value indicating distance between axis elements.

Parameters
spacing value of spacing applied to all axis elements.

public void setTickMarkMode (ChartAxis.TickMarkMode mode)

Sets mode for the tick marks.

Parameters
mode instance of ChartAxis.TickMarkMode

public void setTickMarkSize (int size)

Sets size for the tick marks.

Parameters
size tick marks size in pixels.

public void setTitle (String title)

Sets the title for axis.

Parameters
title string representation of axis' title.

public void setTitleAlignment (Alignment alignment)

Sets value the indicating title alignment.

Parameters
alignment Alignment value

public void setValueType (ChartAxis.ValueType type)

Sets type of value that should be represented by axis labels.

Parameters
type ChartAxis.ValueType enumeration instance.

public void setVisible (boolean visible)

Sets visibility of this element on parent ChartView.

Parameters
visible true if element should be visible, otherwise false.

public double valueToCoeficient (double value)

Converts ranged axis value to absolute portion of axis.

Parameters
value value related to axis range.
Returns
  • absolute portion value on axis.