Pre loader

Date xAxis with one day tick

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

Answered
0
0

Hi,

I’d like to set line chart’s date xAxis ticks to be exactly one day apart in a way that where the label is shown, the time would be exactly 24:00.
I know I can set the minorDelta() and majorDelta(), but what value should I provide them? The minor tick when I zoom in should be 2 minutes and the major tick should be 24 hours.

Version
3.1.0.4322
  • You must to post comments
Best Answer
0
0

Hi Erika,

I think I have easier way for you to provide desired output in DateAxis. Date is usually represent UTC time and we calculate ticks assuming that they are in UTC ( so when you set major tick = 1 day it rounds ticks to midnight in UTC time ), but we format labels in local time zone. So you can try to format labels in UTC time as well:

axis.setLabelProvider(new DateLabelProvider(new DateLabelFormatter(Locale.getDefault(), TimeZone.getTimeZone("UTC"))));

Can you try it? Is it suitable for your needs?

Best regards,
Yura

  • Erika Sankari
    Yeah this works, thanks! Also formatted my dates to UTC as I populate the graph so it shows the point markers in proper places.
  • You must to post comments
0
0

Hi there,

For DateAxis, since Android doesn’t provide built-in type for specifying time spans, it expects Date which store long representation of desired time span:

final long oneDay = DateIntervalUtil.fromDays(1);
final long twoMinutes = DateIntervalUtil.fromMinutes(2);
final IAxis xBottomAxis = sciChartBuilder.newDateAxis().withMajorDelta(new Date(oneDay)).withMinorDelta(new Date(twoMinutes)).withAutoTicks(false).build();

Best regards,
Yura

  • Erika Sankari
    Thanks once more for the quick reply! The tick is now otherwise perfect except it is drawn to 02:00, not 24:00. Any idea why this would happen?
  • Yura Khariton
    Hard to tell without seeing the data which you’re trying to render and code where you configure chart. It’s possible that this is how our default TickProvider algorithm works in your case. In this case I would suggest to create custom TickProvider and place each tick manually. Here is a link on our documentation – https://www.scichart.com/documentation/android/current/webframe.html#Axis%20Ticks%20-%20TickProvider%20and%20DeltaCalculator%20API.html . You will need to extend DateTickProvider and adjust major and minor ticks values ( for DateAxis each double tick calculated by getting Date.getTime() and casting it to double, to restore Date stored in xxxTicks you need to cast it to long and pass it into Date constructor).
  • Erika Sankari
    Got the ticks to proper place 00:00 of each day. Now my labels show on top of each other, the major bands are drawn to all the spaces between ticks and as I zoom in the minor ticks do not draw:D Do I need to make custom solutions for those too or am I missing some configuration? If I just call super() in my CustomDateTickProvider.updateTicks() method then everything looks right except the tick place.
  • Yura Khariton
    Can you post your code here, so I can take a look?
  • Erika Sankari
    I posted the code below so it is easier to read:)
  • You must to post comments
Showing 2 results
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