Pre loader

Autoscaling Axis for Minutes & Hours

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 have a chart that display time-series data and sometimes I have a few minutes of data, other times I have hours. All of the data points are taken every minutes. The X-Axis starts at 0 minutes and progresses from there.

My goal is to have the Axis Title say “Minutes” if there are < 120 points of data. If there are > 120 points of data then I want the Axis to be titled “Hours” and then divide the X-Axis label by 60.

I’ve started with this: https://www.scichart.com/documentation/v5.x/webframe.html#Axis%20Labels%20-%20LabelProvider%20API.html

and it’s doing about what I expect. I check the AxisCore’s Range and if the range is > 120 I set the AxisCore.AxisTitle to “Hours”, otherwise “Minutes”. So far so good.

The problem is that doing it this way means I have labels such as “48.333333” for the hours.

If, on the other hand, when I create the XYSeries that I’m plotting I pass in the already-divided-by-60 values, SciChart seems to select whole numbers so instead of showing me something like “48.333333” it would either show me “48” or it would use 50 or another whole number for the tick marks.

So my question: Is this doable by just writing a custom LabelProvider? Do I need to write a custom Axis class instead? Or somehow tell the Axis that’s in-use to recalibrate itself by dividing all of the elements by 60 before computing tick marks?

In the images I’m attaching, one plot shows me plotting a series where when I create series the x-value is being divided by 60 before I call .Append() on the series. The other one shows what happens when I use my custom LabelProvider and divide by 60 when the Axis label is drawn.

Thanks!

-David

Version
5.4.0.12119
Images
  • You must to post comments
0
0

Hi David,

Sorry that no-one has replied to this in a timely manner. This should be possible with SciChart, however you may need to use the TickProvider API in combination with the LabelProvider API to provide labels at sensible points in time.

The TickProvider API is described here. This lets you tell SciChart where the labels (and gridlines) are going to be placed. We have a pretty good algorithm in there but it will subdivide your chart into nice human readable labels which are divisible by 1,2,5 and 10. That doesn’t help you if you have 1.2, 1.4, 1.6, 1.8 hours.

You can create your own Tickprovider (there are examples in the page above) to output labels at hour-intervals. That combined with the LabelProvider can help you create labels on the hour.

Let me know if this helps. If you have further questions, please ask,

Best regards,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.