Pre loader

avoid duplicate datetime label

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

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 Burnett-Thompson
    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.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies