SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

0
0

Hi,

I’m trying to set the Visible Range of a CategoryDateTime Axis and its throwing an “Object must be of type DateTime” exception. Can you tell me whats wrong here

var scs = new SciChartSurface();
scs.XAxis = new CategoryDateTimeAxis() { DrawMajorGridLines = false, DrawMinorGridLines = false,AutoRange=AutoRange.Never };
scs.YAxis = new NumericAxis() { Id = "Y1", DrawMajorGridLines = false, DrawMinorGridLines = false };
scs.Style = (System.Windows.Style)this.chartForm.sciChartControl.Resources["SciChartSurfaceStyle"];
DateTime startDate = new DateTime(2003, 9, 1);
DateTime endDate = new DateTime(2004, 1, 31);
scs.XAxis.VisibleRange = new DateRange(startDate, endDate);

The exception gets thrown on the last line. I also tried populating the series before I called the visible range, but it has not effect on the exception.

Thanks,
Deepak

Images
  • You must to post comments
0
0

Hi Deepak,

The CategoryDateTimeAxis expects VisibleRange of type IndexRange. This specifies the start/end indices of the bars to show on the chart. This is because this axis does not measure by Dates at all but point index, so that it can collapse gaps e.g. at weekends.

Hope this helps,
Andrew

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.