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

Welcome to the SciChart Community Forums!

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.

0
0

Hi,

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?

Thanks

  • You must to post comments
1
0

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:
http://support.scichart.com/index.php?/Knowledgebase/Article/View/17207/0/convert-pixel-to-data-coordinates
(see under the “CoordinateCalculators API when using CategoryDateTimeAxis” paragraph)

Also this thread may be helpful:
https://www.scichart.com/questions/question/categorydatetimeaxis-with-daterange

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

Best regards,
Yuriy

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.