SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & Android Chart Components
I want to display a chart using a DateAxis as X-Axis. The data set contains values for each basic unit of chosen time base, e.g. for a time base of one month, I get 31 data points, with one value assigned for each day. I want the chart to display a label for each value assigned, but using automatic settings I get the following output:
I wanted to manipulate the ticks by setting the MajorDelta and MinorDelta properties, but it expects a value of type Date, and I’m not sure which value I should provide to get a timespan of 1 day, 1 hour etc.
I set EnableLabelCulling to false, but somehow it doesn’t seem to take any effect.
Yes, DateAxis expects Date as Major/MinorDelta values because Android SDK doesn’t provide any classes which allow to specify time span.
So to provide a Major/MinorDelta for DateAxis you need to create a Date which has desired time span:
Date majorDelta = new Date(DateIntervalUtil.fromHours(1))); Date minorDelta = new Date(DateIntervalUtil.fromMinutes(15));
DateIntervalUtil class which is part of SciChart library contains some methods which allow to return intervals in milliseconds. Then you can use this long value with interval to create Date and pass it into DateAxis.
Also if you want to specify Major/MinorDelta values explicitly on axis you need to disable auto tick generation for this axis because by default Major/MinorDelta values are calculated based on current VisibleRange and MaxAutoTicks value of axis:
final DateAxis xAxis = sciChartBuilder.newDateAxis() .withMajorDelta(new Date(DateIntervalUtil.fromHours(1))) .withMinorDelta(new Date(DateIntervalUtil.fromMinutes(15))) .withAutoTicks(false) .build();
Hope this will help you!
Please login first to submit.