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.
Unfortunately, activation email could not send to your email. Please try again.

Real time plot performance

Thread ID:

Created:

Updated:

Platform:

Replies:

126959 Oct 18,2016 02:43 PM Dec 1,2016 09:23 AM Xamarin.Forms 5
loading
Tags: SfChart
Martin Dusek
Asked On October 18, 2016 02:43 PM

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).

Parthiban Sundaram [Syncfusion]
Replied On October 19, 2016 10:15 AM

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

 


Martin Dusek
Replied On October 19, 2016 11:32 AM

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.

Parthiban Sundaram [Syncfusion]
Replied On October 21, 2016 10:38 AM

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

Martin Dusek
Replied On November 25, 2016 11:34 AM

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?


Parthiban Sundaram [Syncfusion]
Replied On December 1, 2016 09:23 AM

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
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;