Pre loader

Looking for tips on X-Axis numerical labeling change with real-time display

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 all,

I’m developing an app which receives and displays 100’s of samples per second similar to what you would see with the FIFO tutorial. Instead of the sample number, 1000, 1001, etc., I’d like to show seconds so far instead of the sample number.

For example, at sample 1000 display 10, from 1001 to 1099 display nothing, at 1100 display 11, etc. Something simple like sampleNum/100. Can you give me a hint where to start looking to change the behavior of the (major?) tick markings? Do I do something with the NumericAxis class?

Thank you for pointers.

Ed

Version
Unsure, but recent. Do not believe the question is release specific
  • You must to post comments
0
0

Hi Ed,

Thanks for your inquiry.

First of all to achieve desired output you’ll need to customize tick generation to produce ticks after every 100 samples. To do this you can use MajorDelta property provided by axis ( set it to 100 so major ticks will be generated every 100 points ). If you need more information then we have a tutorial which shows how to adjust axis scale.

After altering tick generation you’ll need to create a custom LabelProvider which will divide each data value (major tick) by 100 and then will convert it to a string which will be displayed as axis tick label:

  class CustomNumericLabelFormatter extends SimpleNumericLabelFormatter<NumericAxis>{
        @Override
        public CharSequence formatLabel(Comparable dataValue) {
            dataValue = ComparableUtil.toDouble(dataValue) / 100;
            return super.formatLabel(dataValue);
        }

        @Override
        public CharSequence formatCursorLabel(Comparable dataValue) {
            dataValue = ComparableUtil.toDouble(dataValue) / 100;
            return super.formatCursorLabel(dataValue);
        }
    } 

  xAxis.setLabelProvider(new NumericLabelProvider(new CustomNumericLabelFormatter()));

Another solution which came into my mind – just try to divide xValues by 100 before adding them into data series. I believe in this case you won’t need to customize xAxis because values which are stored in data series will be already in seconds.

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