SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components



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.

  • You must to post comments

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

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.