hi,
I am currently trying to implement a chart with a category datetime axis. I custom a label formatter for handling a custom datetime format, let say”yyyy/MM”. Only the 1st tick of each year will display the label.
Eg: data with[“2018/1”,“2018/3”,“2018/5”], only show 2018/1, others show with empty/no label
I find the overrided method of label and cursor label formatter have only returned Comparable object which should be only returned the current rederering datetime axis label’s date.
Is there any way to find the previous one label to compare or any suggestion for implement this axis? Thank you!
- may lym asked 5 years ago
-
I don’t think the question is very clear, perhaps you can add more info such as a screenshot as to what you want and a code sample of what you’ve tried?
- You must login to post comments
Hi there,
Have you tried to use FormattedTickLabels collection provided by LabelProvider? It stores tick labels in collection which then will be used to render axis. I believe you can replace required labels on empty strings( it’s is important that you don’t remove labels from collection because in this case axis renderer won’t be able to map major ticks generated by TickProvider by index to appropriate label in LabelProvider ):
class CustomLabelProvider extends TradeChartAxisLabelProvider {
@Override
public void update() {
super.update();
final List<CharSequence> formattedTickLabels = getFormattedTickLabels();
// replace every third label on empty string
for (int i = 0; i < formattedTickLabels.size(); i++) {
if(i%3 == 0) {
formattedTickLabels.set(i, "");
}
}
}
}
Hope this will help you!
Best regards,
Yura
- Yura Khariton answered 5 years ago
- You must login to post comments
Please login first to submit.