Pre loader

Crash when using DateRange with CategoryDateAxis#setVisibleRange

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

Based on the example in https://www.scichart.com/documentation/android/v1.x/webframe.html#Axis%20Types.html


IAxis axis = new CategoryDateAxis(getActivity());
axis.setAxisAlignment(AxisAlignment.Right);
axis.setAutoRange(AutoRange.Once);
axis.setGrowBy(new DoubleRange(0.1d, 0.1d));
axis.setVisibleRange(new DateRange(dateMin, dateMax));

It will crash at setVisibleRange with

java.lang.UnsupportedOperationException: Expected instance of DoubleRange
at com.scichart.core.utility.Guard.instanceOf(SourceFile:45)
at com.scichart.core.utility.Guard.instanceOfAndNotNull(SourceFile:52)
at com.scichart.charting.visuals.axes.AxisCore.setVisibleRange(SourceFile:241)

What would be the proper way to set a date range?

Version
1.2.0
  • You must to post comments
1
0

Hi there,

Thank you for pointing this out to us! The article wasn’t updated in time and contains misleading information about CategoryDateAxis. We are going to fix it ASAP.

As to your question, CategoryDateAxis expects a DoubleRange as the VisibleRange. It draws things based on data indexes, not actual values. So setting the VisibleRange should look like that:

 IAxis xAxis = new CategoryDateAxis(getActivity());


// set VisibleRange to [min data index, max data index]
double dataIndex1 = 10d, dataIndex2 = 100d;
DoubleRange visibleRange = new DoubleRange(dataIndex1, dataIndex2);

// apply the visibleRange
xAxis.setVisibleRange(visibleRange);

Concerning converting Dates to Indexes (described in the Convert Pixels to Chart Coordinates article). Please bear in mind that it requires a chart being measured (rendered) first.

Hope this helps!
Best regards,
Yuriy

  • abc def
    Since CategoryDateAxis uses Index, logically it should allow IndexRange to be used.
  • Yuriy Zadereckiy
    Hi there, originally it was using the IndexRange. In WPF version it is even now. But this has brought some inconvenience like inability to scroll smoothly, pan to areas outside the data range and place annotations in future. So it’s been changed and all these is possible to do now. Still, I agree that it isn’t very clear that DoubleRange is used by the Axis.
  • You must to post comments
Showing 1 result
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