best way to keep an annotation's position sync'd to cursor?

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Arction_LasseP

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

best way to keep an annotation's position sync'd to cursor?

Post by plotter » Mon Sep 18, 2017 7:41 pm

Hi,
I have a couple of cursors that have dedicated annotations that I position in the center of the cursor, just above the X axis.
I put text on these to identify the cursors. Even though I have the cursor width set fairly wide, the annotations work great as cursor touch pads in touch environments.
They seem to be way more consistent in their touch responsivness and interactivity, plus they work great to identify each cursor.

The problem I am having is trying to keep the annotation 'pads' positioned properly on the cursors.
When rectangle zooming, unzooming, panning, autofitting Y Axis, changing x axis range in code, etc, all require the pad to be repositioned as the cursor moves.
Currently every available event to report cursor value changes are tied to movement "by mouse", which doesn't trigger of course when the cursor's position is changed by one of the causes above.
This gives me a huge headache trying to solve ths problem of knowing when to reposition the pads on the cursors.

Is there any way to get an event for the cursors simply when their (x) axis value is changed, regardless of the cause?
Or is there some other way to solve this problem that I'm just missing?

Thanks in advance for your help,
Heather


Hi, I wanted to clarify a bit more what I mean...
The problem is not when the cursor position (value) changes, that is straight forward to handle,
The issue is when the cursor moves relative to it's screen position due to scaling, panning, zooming, etc. when it's actual value doesn't change.
That is where I am struggling...
Thanks, Heather

User avatar
ArctionPasi
Posts: 1365
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland

Re: best way to keep an annotation's position sync'd to curs

Post by ArctionPasi » Thu Sep 21, 2017 7:30 am

Hi Heather,

have you tried to use cursor.PositionChanged event?
LightningChart Support Team, PT

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

Re: best way to keep an annotation's position sync'd to curs

Post by plotter » Thu Sep 21, 2017 12:05 pm

Good Morning Pasi,
Yes, I have tried that event, as well as chart size changed, and every other event I could find...
The issue is that PositionChanged seems to be really Cursor_ValueChanged, and not really PositionChanged...

The event I need just seems to be missing...
Here's a perfect example scenario I am suffering through...

I have the ability to adjust the font sizes of the Axis Titles and Labels manually...
When I change the font size, the width of the actual graphing region of the chart changes to make/take room for/from the Axis/Label placement...
This does not change the cursor values at all, just changes where they are displayed on the screen...
Being unable to detect this with an efficient event causes the cursor annotations to become unsyc'd.
On average, a typical chart has 10,000,000 points over 15-30 Y axises and series with 300+ annotations and is used primarily in touch mode.(Which means there is inherently a little additional touch driver response latency)

This problem occurs whenever anything happens which changes the cursor's screen location, (never triggering a cursor 'Value' change...)
This can be during scaling and zooming (since that can change the Y axis scale widths for instance)

Performance is reasonable most of the time...

If you were to add a Cursor_ScreenLocationChanged event, and even a Chart_Graphing_Boundries_Changed event that would fire at appropriate times, that would make life SOoooo much easier...

Thanks in advance for your help and understanding,
Heather

User avatar
ArctionPasi
Posts: 1365
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland

Re: best way to keep an annotation's position sync'd to curs

Post by ArctionPasi » Thu Sep 21, 2017 2:34 pm

We have scheduled ViewXY.MarginsUpdated or equivalent event adding preliminary in 8.3.

Currently you can subscribe to chart.BeforeRendering or AfterRendering event, and read ViewXY.GetMarginsRect(). If the rect has changed compared to previous round, margins have changed, and you can position your objects again.
LightningChart Support Team, PT

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

Re: best way to keep an annotation's position sync'd to curs

Post by plotter » Thu Sep 21, 2017 3:47 pm

Thank You Pasi,
I would love to get a beta version to 'test' this for you :D
Thanks,
Heather

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

Re: best way to keep an annotation's position sync'd to curs

Post by plotter » Sun Sep 24, 2017 7:58 pm

Hello,

As I do need to implement a solution as soon as possible on this one, what do you suggest would be the best implementation for this, performance wise.

I have pretty much avoided the rendering events as they seem to have a significant performance penalty.
If I do it in the after rendering event, then I have to do another update to get the changes rendered, but if I do it in the PreRender event ???

Any suggestions/tips how/where to implement it with minimal performance penalty?

Thanks Again,
Heather

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

Re: best way to keep an annotation's position sync'd to curs

Post by ArctionKestutis » Mon Sep 25, 2017 9:26 am

Hello Heather,

I think you need to check Margins (ViewXY.GetMarginsRect()) in BeforeRendering and AfterRendering event handlers. LightningChart creates frame between those two events. If Margins changed, when you should modify those objects which location is bind to screen coordinates. I believe that performance penalty is minimal (compare to all other calculations) - after all it is only few IF statements. Yes, if you change any Chart's property in AfterRendering event handler, it will trigger new frame generation. Unless you have very interactive, scrolling chart few extra frames should not be a problem. What average FPS you have in your application?

By the way, what Coordinate System you are using for Annotation location/target? Do you know that you can use 'AxisValues' Coordinate System? Or you can even have Annotation.Sizing = AxisValuesBoundaries (to place annotation in particular x and y range)? Would this solve your problem with co-positioning of Annotation with Cursor problem?

All the best.

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

Re: best way to keep an annotation's position sync'd to curs

Post by plotter » Tue Sep 26, 2017 8:22 pm

Good Afternoon,
Thanks for the detailed tips.

I do get pretty good responsiveness overall, but it does seem to be a steep slippery slope trying to keep UI touch lag to a minimum,
as the UI becomes feature rich, especially on pc's that do not have good graphics adapters.

I will try your suggestions and let you know the results.
Thanks Again,
Heather