Search code examples
javadate-rangescichart

Scichart's setVisibleRange() having no effect


I'm trying to set the visible range of a DateAxis. Here's what I have:

final IXyDataSeries<Date, Double> dataSeries = sciChartBuilder.newXyDataSeries(Date.class, Double.class).build();

final IAxis xBottomAxis = sciChartBuilder.newDateAxis()
       .withAxisId("xBottomAxis")
       .build();

xBottomAxis.setAutoRange(AutoRange.Never);
xBottomAxis.setTextFormatting("MM.dd.yyyy h:mm a");

Calendar rightNow = Calendar.getInstance();
long t = rightNow.getTimeInMillis();
Date rightNowPlusFiveMin = new Date(t + (5 * ONE_MINUTE_IN_MILLIS));
Date rightNowMinusThreeHr = new Date(t - (3 * ONE_HOUR_IN_MILLIS));

xBottomAxis.setVisibleRange(new DateRange(rightNowMinusThreeHr, rightNowPlusFiveMin));

This should keep it from AutoRanging and set the default min and max on the xBottomAxis. Is this not how you do it?

Currently, it's just AutoRanging to fit the data.

Edit: Here are the applicable links for its documentation.


Solution

  • It looks like removing mySciChartSurface.zoomExtents() fixed it. Link to zoomExtents documentation.

    Thanks to Yura Khariton for the help.