Changing PointLineSeries parent View issue

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Arction_LasseP

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

Changing PointLineSeries parent View issue

Post by lokesh » Wed Feb 22, 2017 8:44 pm

Hi,
I am not sure if the way I did this is correct but I tried to change the parent view of a PointLineSeries and I am facing an issue.
I did the following:

Code: Select all

pls.OwnerView.PointLineSeries.Remove(pls);
                  pls.AssignYAxisIndex = 0;
                  pls.Visible = true;
                  pls.SeriesEventMarkers[0].Visible = true;
                  _xyCharts[i].ViewXY.PointLineSeries.Add(pls);
It worked and the PointLineSeries was displayed in the new chart. Perfect.

Now I tried to set the scale using the following:

Code: Select all

_xyCharts[i].ViewXY.XAxes[0].SetRange(_xyCharts[0].ViewXY.XAxes[0].Minimum, _xyCharts[0].ViewXY.XAxes[0].Maximum);
               _xyCharts[i].ViewXY.YAxes[0].GetSeriesMinMax(out minSeriesVal, out maxSeriesVal);
               offset = Math.Abs(maxSeriesVal - minSeriesVal) / 10;
               _xyCharts[i].ViewXY.YAxes[0].SetRange(minSeriesVal - offset, maxSeriesVal + offset);
Here I am getting the out minSeriesVal and maxSeriesVal as 0.
So I tried the following:

Code: Select all

PointLineSeries newpls = new PointLineSeries(); // _xyCharts[i].ViewXY, _xyCharts[i].ViewXY.XAxes[0], _xyCharts[i].ViewXY.YAxes[0]);
                  newpls.AssignYAxisIndex = 0;
                  newpls.AssignXAxisIndex = 0;
                  newpls.Points = pls.Points;
                  newpls.Visible = true;
                  newpls.PointsVisible = true;
                  newpls.LineStyle.Color = pls.LineStyle.Color;
                  _xyCharts[i].ViewXY.PointLineSeries.Add(newpls);
and I am able to set the scale properly. The problem with the above is that I am setting a style for the PointLineSeries and I don't want to set it again when changing the layout.
So I am wondering if there is a way to deep clone the PointLineseries or switch the parent? (I think I am able to switch actually, I see the pointlineseries on the new chart.)
For now I could just use the scale of the previous parent, but the code might add a new PointLineSeries to the chart and then the scaling won't be proper.

Thanks.

Regards,
Lokesh

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

Re: Changing PointLineSeries parent View issue

Post by ArctionPasi » Thu Feb 23, 2017 11:15 am

Hi Lokesh,

one should not change the parents after creating objects. ChartError event handler should give a warning if you do that.

Please create chart, then series. If you need to create a series later, recreate it from scratch for the existing view.

We strongly recommend creating series with their parametric constructors, like PointLineSeries pls = new PointLineSeries(viewXY, xAxis, yAxis);
Then the parent tree is automatically made, and there's no need to assign axes by indices.



Also please read notes in User's Manual, Chapter 24.1 Sharing objects between other objects.
LightningChart Support Team, PT

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

Re: Changing PointLineSeries parent View issue

Post by lokesh » Thu Feb 23, 2017 1:16 pm

Hi Pasi,
Thanks for the comments.
Sorry for my misunderstanding. I was under the impression that the objects were more loosely coupled and could be taken out and plugged it to another place.
I am following the order that you recommended and is using parameterized constructors. I was basically trying with the default because, in that case there is no option of explicitly setting the owner and maybe that is the reason for the unexpected behaviour, but I guess not.
Anyways, is there an option of cloning or using a particular template for the PointLineSeries? I am setting them to behave in a particular way and if I have to create them all again, that is a bit expensive for me.

Further, I tried as you suggested, i.e handling the ChartError and I noticed something unusual and completely off this topic. When I hide the parent container of a chart, it throws me a Warning with the details null. Should I be worried about this?

Thanks again.

- Lokesh

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

Re: Changing PointLineSeries parent View issue

Post by ArctionPasi » Tue Feb 28, 2017 6:08 am

Hi Lokesh,

there's unfortunately no copy constructors or cloning methods in our objects. Just create a new object, and set the properties by your code, according to the appearance you prefer.

ChartError event handler produces output where you should mainly be worried about Errors, but not Warnings. They might be useful info, though, if experiencing problems.
LightningChart Support Team, PT