You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
publicclassMyCustomXAxisValueFormatterimplementsXAxisValueFormatter {
@OverridepublicStringgetXValue(Stringoriginal, intindex, ViewPortHandlerviewPortHandler) {
// original is the original value to use, x-index is the index in your x-values array// implement your logic here ...return ...;
}
}
Then, set your formatter to the XAxis:
// usage on XAxis, get axis instance:XAxisxAxis = chart.getXAxis();
// set the formatterxAxis.setValueFormatter(newMyCustomXAxisValueFormatter());