Get Parent LightningChartUltimate from the child view

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Arction_LasseP

lokesh
Posts: 45
Joined: Tue Feb 14, 2017 8:48 am

Get Parent LightningChartUltimate from the child view

Post by lokesh » Tue Feb 21, 2017 2:54 pm

Hi,
I am doing some event handling at the View and PointLineSeries level and some of the operations require me to call chart begin and end update methods. I read it somewhere that the whole thing has a tree architecture. So I am wondering if I could easily find the chart which the view belongs to from the view itself?
I also have another dependent question. Is it not necessary to call the begin and end update methods during event handling as it is being called internally?
Btw, in order to find out which view send the message, what I am doing now is to compare the sender with the view of each chart, which is not that good. I have quite some events being handled and prefer not to do this.

Thanks.

Regards,
Lokesh

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

Re: Get Parent LightningChartUltimate from the child view

Post by ArctionPasi » Tue Feb 21, 2017 4:17 pm

Hi Lokesh,

It seems there's no direct property or method to resolve the owner chart. It's rather assumed the programmer has the known reference to the chart, and then references the View like chart.ViewXY.
But we can add a getter property for Views to return the owner chart in future versions.

BeginUpdate...EndUpdate should be used also in event handlers, if the event handler changes chart's public properties or calls methods to update data or other elements.

You could also make a Dictionary<ViewXY, LightningChartUltimate>, to help solving the chart based on ViewXY. Note though... using Dictionary is expensive in performance, if you are resolving items like thousands of times / second.
LightningChart Support Team, PT

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

Re: Get Parent LightningChartUltimate from the child view

Post by ArctionPasi » Tue Feb 21, 2017 4:37 pm

Added OwnerChart getter property in upcoming v.8, for all Views.
LightningChart Support Team, PT

lokesh
Posts: 45
Joined: Tue Feb 14, 2017 8:48 am

Re: Get Parent LightningChartUltimate from the child view

Post by lokesh » Tue Feb 21, 2017 4:53 pm

Hi Pasi,
Thank you for the reply.
Yes, Dictionary is a good option but I don't really have a large collection of charts. I just have 4 and that too, I need to consider them all only in a particular layout. I still have to check which one would be a better choice. I will keep this in mind.
Thank you for the suggestion and quick implementation.

Edit:
I was evaluating this and I think your suggestion might actually be better because it will be storing only references anyway and the memory overhead wouldn't be that much(I was worried about this). And yes it would give me a better access of-course.

Edit2:
I see a Tag in the LegendBox in the View. I think, I will use that. Thanks :)

- Lokesh