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



I’ve got an OhlcDataSeries<DateTime, double> and I’m trying to add a VerticalLineAnnotation by setting X1 = DateTime.UtcNow.AddDays(-2).

However, when the annotation is added, I get an InvalidCastException saying it can’t convert from DateTime to Int32.

What gives?


  • You must to post comments

Hi Georgios,

Probably the reason why this happens is that you use the CategoryDateTimeAxis. It uses IndexRange as VisibleRange, not DateRange. So to place an annotation, you need to convert a data value to its index. Please take a look at the article on coordinate transformation here:
(see under the “CoordinateCalculators API when using CategoryDateTimeAxis” paragraph)

Also this thread may be helpful:

Hope this helps! Please feel free to comment if you have any questions,

Best regards,

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.