-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
The XAxisValueFormatter interface
Philipp Jahoda edited this page Sep 20, 2015
·
6 revisions
The XValueFormatter 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 x-axis label from the getXValue(...) method.
Example of a custom formatter
public class MyCustomXValueFormatter implements XValueFormatter {
@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.setXValueFormatter(new MyCustomXValueFormatter());Predefined XValueFormatters
Example XValueFormatters