We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Real time plot performance

Hi,
I'm plotting 20 series of temperatures sampled once per second (all temperatures are sampled at exactly same time), visible interval will be 120 seconds. I change min and max value on x axis (min = DateTime.Now - 120 seconds, max = DateTime.Now) once per 100 ms to cause the graph sliding from right to left.

This is how I update the plot:

                for (int i = 0; i < 20; i++) // iterate through series
                {
                    var serie = model.SeriesData[i];
                    serie.Add(new ChartDataPoint(DateTime.Now, readings[i])); // append new temperature reading
                    for(int j = 0; j < serie.Count(); j++) { // delete old data
                        if ((DateTime)serie[j].XValue < model.Min) { // model.Min = DateTime.Now - 120 seconds
                            serie.Remove(serie[j]);
                            continue;
                        }
                        break;
                    }
                }

This is how I update min and max value on x axis:

            Xamarin.Forms.Device.StartTimer(TimeSpan.FromMilliseconds(100), () =>
            {
                min = DateTime.Now - TimeSpan.FromSeconds(60);
                max = DateTime.Now;
                NotifyPropertyChanged("Max"); // max and min values are binded
                NotifyPropertyChanged("Min");
                return true;
            });

Can you please comment whether this is good way to update data and x axis of my real time plot? E.g. If every append/delete of sample causes chart to redraw, then my chart is redrawed at least 20 times in for loop, which is not ideal as it will be sufficient to redraw plot just once (after the for loop when all new samples were appended and old samples were deleted).

5 Replies

PS Parthiban Sundaram Syncfusion Team October 19, 2016 02:15 PM UTC

Hi Martin,

Thanks for contacting Syncfusion support.

We have prepared a sample based on your requirement. If this sample doesn't match your requirement, kindly provide us more details which will be helpful to provide further assistance on this.

Sample: http://www.syncfusion.com/downloads/support/forum/126959/ze/SimpleSample1418437260  

Regards,
Parthiban S

 



MD Martin Dusek October 19, 2016 03:32 PM UTC

Hi Parthiban,
thank you very much for the sample project. I have 5 notes:

1) Your plot is not realtime - the graph moves 5 seconds every 100 realtime milliseconds.

2) You autoscroll the plot using xAxis.AutoScrollingDelta. I would like the graph to autoscroll on x axis smoothly (or nearly smoothly - 10 Hz = 100 ms is enough) as time passes (using AutoScrollingDelta autoscrolls the graph moves only when new sample is added to the serie).

3) I want x axis to be always 120 seconds wide even when there is small number of samples to be plotted.

4) You don't delete old data. In my situation the app can run for hours collecting data and as the plot displays only the newest 120 seconds I think it is good idea to remove old data.

5) You plot just one serie. I plot 20 series of data to one graph. New data to all series are appended at exactly same time (all 20 new samples arrives all at once).

All I ask for can be achieved by my code in my first post. However, I'm not sure whether my code is optimal in regards of performace. I don't want the graph rendering to consume a lot of CPU.


PS Parthiban Sundaram Syncfusion Team October 21, 2016 02:38 PM UTC

Hi Martin,

Thansk for your patience.

We would like to let you know that every add/delete of data will not cause the chart to redraw. It will be redrawn only once when the data manipulation is completed.

We would also like to let you know that you can achieve you requirement in the way you have updated.

Please get back to us if you need further assistance on this.

Regards,
Parthiban S


MD Martin Dusek November 25, 2016 04:34 PM UTC

Hi,
I'm getting back to this topic. Unfortunately it seems that Syncfusion charts is not suitable for realtime plotting of data, at least on Android device (LG G3) and Xamarin.Forms app.

I modified a little your SimpleSample1418437260 - I added 20 series and I'm adding new record to each serie every second:

        public void LoadData()
        {
            Device.StartTimer(new TimeSpan(0, 0, 0, 0, 1000), () =>
            {
                for (int j = 0; j < 20; j++)
                {
                    data[j].Add(new Model2(dateTime, random.Next(10, 50)));
                }
                dateTime = dateTime.AddSeconds(1);
                return true;
            });
        }

I can then experience a glitch e.g. when there should be smooth animation of some UI element on my page each time new data are added to the graph. Can you confirm this?



PS Parthiban Sundaram Syncfusion Team December 1, 2016 02:23 PM UTC

Hi Martin,

Thanks for the update.

We were unable to reproduce the issue at our end. Please download the sample from following location.

Sample: http://www.syncfusion.com/downloads/support/forum/126959/ze/Realtime-1630305354  

We also recommend you to use latest version of Essential Studio 14.4.0.15 in which we have improved the performance which is available for download under the following link.

https://www.syncfusion.com/forums/127486/essential-studio-2016-volume-4-release-v14-4-0-15-is-available-for-download

If you are still facing this issue, we kindly request you to update us the modified sample for helping you further with most appropriate solution.

Regards,
Parthiban S
 


Loader.
Live Chat Icon For mobile
Up arrow icon