v7.2.4 When chart is not shown, series use first Y axis

Found a possible bug in LightningChart? Report it here.

Moderator: Arction_LasseP

Post Reply
zahir
Posts: 3
Joined: Wed Mar 15, 2017 7:04 am

v7.2.4 When chart is not shown, series use first Y axis

Post by zahir » Wed Mar 15, 2017 7:42 am

For a brief view, I am currently using a trial version of the LightningChartUltimate for WPF (no-binding). In my application I was trying to show and hide the graph according to the UI interactions. But occasionally I had this behavior. When I delved into the debugging in a separate VS solution I was able to pinpoint the problem. I have attached the solution to this post. All of the code is in MainWindow.xaml.cs file.

Details:
---------
Requirements:
1. There are too many channels of data that I cannot put all of them into the graph at the same time. Therefore, I am holding onto multiple series but add them into or remove them from the view when needed.
2. Duration of the view will be long, so amount of incoming data is huge. Therefore, I am holding data in the SampleDataSeries instead of holding in different buffers.
3. Graph will not always be visible, moreover when data starts pumping we may not even have a window open. Therefore, I need to create the chart instance apriori and show when needed.
4. Some of the channels need to be larger than other channels, therefore I use segmented layout instead of a stacked one.

Behavior:
When I feed data into a SampleDataSeries instance the series tries to find itself a YAxis to show the data. When the chart is visible, the series show itself in the YAxis which is given in its constructor. But if the chart is not visible, then the series show itself in the first YAxis regardless of whether its YAxis present in the chart or not.

Showcase(In the attached VS solution):
At first I don't add the chart into the window. I have 'm' YSegments and 'n' YAxis/SampleDataSeries, where 'm < n'. I add 'm' of the axes and series into the chart. Then I start generating data and feed into the series. I wait for a couple of seconds and then add the chart into the view. Then I see that the series that are added to the chart have lost their Y-axes. If I add remaining (n-m) series and axes into the view, I see that there is no problem with these remaining series. They show in their respective Y-axes

1. If I don't wait for a duration and add chart into the view immediately (not a solution to my problem)
2. If I don't add any series but add them after chart is added to the view manually (a possible workaround)
3. If I don't add any series and register for chart's IsVisibleChanged event, and then add series when the chart becomes visible. (a possible workaround)

In the end I have my workarounds to this problem. But it seems like a bug.
Attachments
CsLightningChartBug.zip
Deferred view bug example
(10.57 KiB) Downloaded 270 times

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

Re: v7.2.4 When chart is not shown, series use first Y axis

Post by ArctionKestutis » Wed Mar 15, 2017 3:21 pm

Hello,

Thank you for the detailed description and test project. It looks a little bit as our Demo's (WPF) example "Billion Points". You maybe interested to check the implementation there. For example, the CheckBox "Prefill with data" looks like the one you would like to use.
The problem you described sound very unusual. We will check your test project as soon as possible.

All the best.

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

Re: v7.2.4 When chart is not shown, series use first Y axis

Post by ArctionKestutis » Thu Mar 16, 2017 1:44 pm

Hello,

There are few bugs in your program, which spoil the party.
First and foremost, you binding series to Yaxis, which is not yet added to view. You need to add axis and only when create SampleDataSeries:

Code: Select all

                view.YAxes.Add(axis);
                var series = new SampleDataSeries(view, view.XAxes[0], axis);
Therefore, your series get default value 0 all the time.

Second, you have less segments than series. Therefore, you should not assign Segment's indices you don't have. For example something like this would be fine

Code: Select all

axis.SegmentIndex = i % SegmentCount;
Third, there is no reason why you should limit adding Series or Axis to ViewXY, because SeriesCount > SegmentCount. The line above will add 5th series/axis to Segment #0, 6th to Segment #1 etc. This will make List<AxisY> and List<SampleDataSeries>() unnecessary. Therefore, FeedData directly to the Series without intermediate list:

Code: Select all

                //allSeries[i].AddSamples(seriesSamples, false);
                lcu.ViewXY.SampleDataSeries[i].AddSamples(seriesSamples, false);
As you may noticed already, above modification makes MakeAllSeriesVisible() method completely useless or even harmful, as it is duplicating Series and Axis.

Hope this helps.
All the best.

P.S. Axis and Series have visibility property if you want to make them temporally invisible. You can add Vertical ScrollBar to LightningChart, which would allow to place more segments. There are many other ideas how to present dense data, please check them in our Demo app. If you could not find some implementation, you can always ask through support account.

zahir
Posts: 3
Joined: Wed Mar 15, 2017 7:04 am

Re: v7.2.4 When chart is not shown, series use first Y axis

Post by zahir » Thu Mar 16, 2017 3:35 pm

Thanks for the reply. The code I submitted was to demonstrate what I thought to be a bug. Some of the quirks may seem weird but I need them in my project and that is why I added to the given code.
First and foremost, you binding series to Yaxis, which is not yet added to view.
I have tried adding Y axis into view before constructing the series object. Worked for visible series. But if I add invisible series into the view this solution does not work. Therefore it seems like another workaround but not a problem with my sample code

As a reminder, constructing series before adding the Y axis into view works perfectly if the chart is visible (ie. added to the window) before updates. If chart gets visible sometime later, then the problem (broken relationship between the axis and the series) occurs.
Second, you have less segments than series.
This is intended, because like I have pointed out before (1)there are too many channels and I cannot show all of them at once because the details in the Y domain would be invisible, (2) I need to hold the data in series instead of somewhere else. If I have added all the segments then visible axes would become too small.
Third, there is no reason why you should limit adding Series or Axis to ViewXY, because SeriesCount > SegmentCount.
This causes "The Problem" even if I set series Visible property to false, if I add the series into ViewXY.SampleDataSeries list, the series assigns itself to the first visible Y axis when the chart is not visible but the data is being fed.

Moreover, even if I make series and the related Y-axis invisible remaining axes will be small and there will be a lot of empty space because of the remaining segments. Hence, we need to add/remove segments when needed.
MakeAllSeriesVisible() method completely useless or even harmful
"MakeAllSeriesVisible" method actually exists for demonstration that, if the series are not added to the view, they will keep the relationship with corresponding Y-Axis unlike the series that are added to the view.

Beyond these, we don't want scroll-bars and, in your demo application the segmented Y axis layout looked like a best fit for our needs. Therefore, it seems we will go on with the IsVisibleChanged event workaround for the time being.

zahir
Posts: 3
Joined: Wed Mar 15, 2017 7:04 am

Re: v7.2.4 When chart is not shown, series use first Y axis

Post by zahir » Thu Mar 16, 2017 4:31 pm

It seems like I was lost in the details and needed to look at the big picture again. While I was trying what you suggested I was testing one by one and something was off. If I add all the components (Y-Axes, series, annotations etc.) to the lists in the view but only keep the needed ones visible everything works perfectly. Thanks again.

Post Reply