SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components
Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!
Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.
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
What would be the proper way to set a date range?
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!
Please login first to submit.