Pre loader

Timezone affecting DateTimeAxis labels.

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

Hello,

I am currently working on an DateTimeAxis where I am trying to display the labels in two hours intervals. So far it is working well but I have noticed when working with different timezones , if the timezone is odd, the labels display only odd numbers. When the timezone is even however the labels are even as well (eg. get-4 displays labels such as 2pm 4pm 6pm 8pm while gmt-7 displays 1pm 3pm 5pm 7pm)
I have played around with hours and dates to try to dynamically adjust the min and max visible ranges depending on if the current time is even or odd but that doesn’t affect at all the labels even after providing the major deltas and range.

does anyone know how to fix this issue? I want even labels regardless of the situation.

Version
v3
  • You must to post comments
0
0

Default TickProvider implementation for DateAxis doesn’t consider time zones during calculation and uses only value provided by Date.getTime() method.

  • Yura Khariton
    This is expected behavior, because Date doesn’t save information about time zone. If you want to add custom handling you would need to write custom TickProvider implementation and then format ticks to string by creating custom LabelProvider for axis
  • You must to post comments
0
0

Hi there,

Well to do this you’ll need to create custom TickProvider and provide ticks at desired dates. Default TickProvider implementation for DateAxis doesn’t consider time zones during calculation and uses only value provided by Date.getTime() method.

    class CustomDateTickProvider extends DateTickProvider {
    private final double offset;

    public CustomDateTickProvider(double offset) {
        this.offset = offset;
    }
    @Override
    protected void updateTicks(DoubleValues minorTicks, DoubleValues majorTicks) {
        super.updateTicks(minorTicks, majorTicks);

        offsetTicksBy(minorTicks, offset);
        offsetTicksBy(majorTicks, offset);
    }

    private static void offsetTicksBy(DoubleValues ticks, double offset) {
        final int size = ticks.size();
        final double[] itemsArray = ticks.getItemsArray();
        for (int i = 0; i < size; i++) {
           itemsArray[i] += offset ;
        }
    }
}

and then create axis with timezone offset in mind

 final IAxis xAxis = sciChartBuilder.newDateAxis().build();

 xAxis.setTickProvider(new CustomDateTickProvider(DateIntervalUtil.fromHours(5.0)));

Best regards,
Yura

  • 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