-
-
Notifications
You must be signed in to change notification settings - Fork 9k
The XAxisValueFormatter interface
Philipp Jahoda edited this page Sep 22, 2015
·
6 revisions
Available since v2.1.4
The XAxisValueFormatter
interface can be used to create custom-made formatter classes that allow to dynamically adjust x-values before drawing them to the screen.
For using the XValueFormatter
, simply create a new class and let it implement the interface and return whatever you want to be displayed as a XAxis
label from the getXValue(...)
method.
Example of a custom formatter
public class MyCustomXAxisValueFormatter implements XAxisValueFormatter {
@Override
public String getXValue(String original, int index, ViewPortHandler viewPortHandler) {
// implement your logic here ...
return ...;
}
}
Then, set your formatter to the XAxis
:
// usage on XAxis, get axis instance:
XAxis xAxis = chart.getXAxis();
// set the formatter
xAxis.setValueFormatter(new MyCustomXAxisValueFormatter ());
Predefined XAxisValueFormatters
Example XAxisValueFormatters