Skip to content
Philipp Jahoda edited this page Aug 7, 2016 · 4 revisions

The XAxis is a subclass of AxisBase.

The XAxis class (in versions prior to 2.0.0 XLabels called), is the data and information container for everything related to the the horizontal axis. Each Line-, Bar-, Scatter-, CandleStick- and RadarChart has an XAxis object.

The XAxis class allows specific styling and consists (can consist) of the following components/parts:

  • A so called "axis-line" that is drawn directly next to and parallel to the labels
  • The "grid-lines", each originating from an axis-label in vertical direction

In order to acquire an instance of the XAxis class, do the following:

XAxis xAxis = chart.getXAxis();

###Customizing the axis values

  • setLabelRotationAngle(float angle): Sets the angle for drawing the x-axis labels (in degrees).
  • setPosition(XAxisPosition pos): Sets the position where the XAxis should appear. Choose between TOP, BOTTOM, BOTH_SIDED, TOP_INSIDE or BOTTOM_INSIDE.

###Example Code

XAxis xAxis = chart.getXAxis();
xAxis.setPosition(XAxisPosition.BOTTOM);
xAxis.setTextSize(10f);
xAxis.setTextColor(Color.RED);
xAxis.setDrawAxisLine(true);
xAxis.setDrawGridLines(false);
// set a custom value formatter
xAxis.setValueFormatter(new MyCustomFormatter()); 
// and more...

The documentation has moved.

Clone this wiki locally