Positioning AnnotationXY on Initial Chart Creation

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Arction_LasseP

plotter
Posts: 41
Joined: Thu Apr 06, 2017 2:29 am

Positioning AnnotationXY on Initial Chart Creation

Post by plotter » Thu May 04, 2017 11:06 am

Good Morning,
I am struggling to display a set of annotations positioned over cursors during chart creation.
I want to annotation to appear just above the bottom of the chart, (or just below the top of the chart)
I have 15 series spread over 5 segments. I do not use to use .ZoomToFit.
When I create the chart, the annotation is not in the Y visible region until I move the cursor. (If I zoom vertically out really far, I can see the cursor IS actually visible, not in the current viewing area.

Your ExampleCursorTrackingXY exhibits this same behavior when I comment out the _chart.ViewXY.ZoomToFit(); line 153. and insert the UpdateCursorResult(); at the end of CreateChart().

The Annotation 's Y coordinate is at the Y position of the Y series 0, not the bottom of the chart (until of course I move the cursor) (Even though UpdateCursorResult(); says it is positioning Y at the X-Axis vertical position)

What am I doing wrong?
Thanks.

ArctionKestutis
Posts: 386
Joined: Mon Mar 14, 2016 9:22 am

Re: Positioning AnnotationXY on Initial Chart Creation

Post by ArctionKestutis » Fri May 05, 2017 10:52 am

Hello,

You are not doing anything wrong. For methods like Axes.CoordToValue() it is very important to have accurate chart size and axis range information. During Chart creation/initialization all properties go through several update cycles. Therefore, it is very important to select right event to check particular values.
For our ExampleCursorTrackingXY (in WinForms) the missing event is SizeChanged. Please subscribe to that event and call cursor update:

Code: Select all

        _chart.SizeChanged += _chart_SizeChanged;

        private void _chart_SizeChanged(object sender, EventArgs e)
        {
            UpdateCursorResult();
        }
Similar solution should help in your app.

P.S. The events like BeforeRendering or AfterRendering are another good alternative (but you need to be careful with them not to end-up in infinite update cycle).

Hope this helps.
All the best.

plotter
Posts: 41
Joined: Thu Apr 06, 2017 2:29 am

Re: Positioning AnnotationXY on Initial Chart Creation

Post by plotter » Fri May 05, 2017 1:34 pm

Thank You Very Much!

I DO rely on the samples heavily as they provide much more detail than the user manual, and have tried to go through every relevant example's code
to try to see 'how it's done', but there IS a lot to digest. And sometimes the most useful tidbits are in examples not apparently relevant at first.

You have identified certain examples by name when steering users to certain functionality examples, sometimes I wish you had a functionality keyword search textbox in the demo application (visual studio and resharper search seems too broad and doesn't function well for this purpose for me).

That might save some time in the forum as most users could get more self help from the demo sample code...

Thanks again

ArctionKestutis
Posts: 386
Joined: Mon Mar 14, 2016 9:22 am

Re: Positioning AnnotationXY on Initial Chart Creation

Post by ArctionKestutis » Fri May 05, 2017 1:57 pm

Yes, we know that we need to improve documentation :oops: