2

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.

TheKingElessar
  • 1,654
  • 1
  • 10
  • 30

2 Answers2

2

I tried to copy-paste your code in this example and it worked as expected - axis was rendered with assigned VisibleRange value.

I noticed that you used custom AxisId for your DateAxis. Does it mean that you have more than one XAxis and maybe your RenderableSeries is attached to wrong axis?

Also I would suggest you to update to the latest version of the library - it could be possible that if it's a bug then it's already fixed in latest build.

If it doesn't help then you'll need to provide more code or entire project which reproduces this issue because with code which you provided it's hard to tell what could be the cause of this issue.

Yura Khariton
  • 484
  • 2
  • 6
0

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

Thanks to Yura Khariton for the help.

TheKingElessar
  • 1,654
  • 1
  • 10
  • 30