Video Tutorials

If you are interested in detailed video tutorials (📹 | 🖥️), have a look at the downloads. These videos made by the developer of the library e.g. explain how you can configure the X-axis in detail. Source code is also included.

XAxis

The XAxis is a subclass of AxisBase from which it inherits a number of styling and convenience methods.

The XAxis class (in versions prior to 2.0.0 called XLabels), 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...