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.
- papa diaw asked 3 years ago
- You must login 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;
}
@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
- Yura Khariton answered 3 years ago
- You must login to post comments
Default TickProvider implementation for DateAxis doesn’t consider time zones during calculation and uses only value provided by Date.getTime() method.
- Adam Brody answered 3 years ago
- last edited 3 years ago
-
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 login to post comments
Please login first to submit.