SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components

0
0

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!

Version
2.0
  • Andrew
    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 to post comments
0
0

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

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.