space between old and new points in spline series

Hi,
I'm plotting real time data as a graph using spline series. While plotting new points I want to make some old points remove or empty that has to be visible as shown in attached sample graph. I'm updating the graph using timer. How to do this? Please help me.

Attachment: graph_287d25d9.7z

5 Replies

MK Muneesh Kumar G Syncfusion Team September 18, 2018 09:04 AM UTC

Hi Chandra sekhar, 
 
Greetings from Syncfusion, we have analyzed your query and you can achieve this by setting IsEmpty property as true in series’s Points collection as per the below code snippet.  
 
[C#] 
private void Timer_Tick(object sender, EventArgs e) 
{ 
    series.Points.Add(series.Points.Count, random.Next(10, 40)); 
    series.Points[5].IsEmpty = true; 
    timer.Stop();      
} 
 
In the above code, we have added new point and set the “IsEmpty” property of the old point as true. This will make the point as empty (not visible in chart). Like this you can customize the points as per your requirement.  
 
Please find below screenshot while rendering the chart. 
 
 
Screenshot after timer event 
 
 
In the above screenshot, as per the code example 5th point is empty. 
 
In the below link, we have attached sample for your reference.  
 
Sample: chart-sample 
 
For more details, please check the below UG. 
 
Hope this helps.  
 
Regards,
Muneesh Kumar G. 



CS chandra sekhar September 20, 2018 10:19 AM UTC

Hi,
Thanks for your reply.
I tried your chart sample in that after making point empty you are  stopping the timer.
but my requirement is timer shouldn't stop. It has to plot the points from 0 to 100 after that it has to start from 0 to 100 with new values in such a way while 
inserting 0, 1 to 10 graph points should be empty and while   
inserting 1, 2 to 11graph points should be empty and while   
inserting 292, 293 to 299 and 0   to 1 graph points should be empty ….
I tried this but unable to visualize the empty points, I used chart.ImprovePerformance = true also.
Please help me to do this.
 

Attachment: chart_e808c129.zip


MK Muneesh Kumar G Syncfusion Team September 21, 2018 05:18 AM UTC

Hi Chandrasekhar, 
 
We have analyzed your query and sample and we found that you are using 30 as gap, for every timer tick function you are adding new points for series and trying to empty 30 points in order (ex 0 to 30, 30 to 60 and so on).  
 
But as per your code in sample, first you are emptying the 30 points in series and removed those points using code series.points.removeAt(i) and add new points using series.points.add() (300 points). This code will remove the already existing points in which you have set IsEmpty as true and new points. By default, IsEmpty is false for new points. So, we have modified your code like below. 
 
[C#] 
series.Points.Clear(); 
for (int i = 0; i < datalist1.Count; i++) 
                    { 
                        series.Points.Add(i, datalist1[i]); 
                        if (interval == 1) 
                        { 
                            if (i < (interval * gap)) 
                            { 
                                series.Points[i].IsEmpty = true; 
                            } 
                        } 
                        else 
                        { 
                            if(i>((interval-1)*gap)&&i< (interval * gap)) 
                            { 
                                series.Points[i].IsEmpty = true; 
                            } 
                        } 
                    } 
                    if (interval == 10) 
                    { 
                        interval = 0; 
                    } 
                    else 
                    { 
                        interval++; 
                    } 
 
In the above code, we have emptied the 30 points gaps in series and before doing that we have cleared all the points in series. So, every time timer function is triggered new points are added into series and emptied 30 points in the series (0 to 30, 30 to 60 and so on).  
 
In the below link, we have attached sample for your reference.  
 
Sample link: chart-sample 
 
Please let us know if you have any queries.  
 
Thanks, 
Muneesh Kumar G. 
 



CS chandra sekhar October 4, 2018 07:58 PM UTC

Hello,
Thanks for your kind Support. our application is for plotting real time ECG data ,with 3 charts . Data Points will be coming through Rs232,and data is processed and buffered in a circular buffer way. Data Points arrives every 15ms approx and data is processed and buffered in lowest time as possible. we are using a windows forms timer to invoke chart updating routine and we tried setting the forms timer for 15ms,.we are creating a circular buffer with gap points with a smooth shifting and every time ,timer tick takes places, the update routine , updates all the 1500points from the buffer to the chart. so we can get a smooth ECG updating screen with new points arriving in real time.. Actually the gap is maintained in the buffer,so 5 points will be added every 15ms, but in screen we are seeing that instead of smooth update ,its like updating around 120 to 150points at once.its like batch updating..when inspected for the same,using stopwatch , we found that , though we are expecting a 15ms Timer Tick, the timer is getting called every 300 to 500ms randomly...it means all the gap points is maintained smoothly in buffer, but windows forms timer is not getting called accurately.

Can you please kindly support us to get a smooth update instead of batch updating... we tried using system.Timers.Timer also, using system timer, timer tick is getting called close to 15ms , but UI screen is not getting rendered properly ,if i increase system timer to 400ms,then it gives same effect as batch updating..

to make sure chart control updating routine is not so longer we tried using the stopwatch elapsed, it showing almost 0 or 1.means its getting updated in very less time.

kindly suggest us some way to achieve a smooth refreshing of entire screen every 15 to 20ms. Thank you very much

with regards
N.Chandra sekhar



MK Muneesh Kumar G Syncfusion Team October 5, 2018 11:36 AM UTC

Hi Chandra Sekhar, 
 
Thanks for your update. We have analyzed your queries and prepared sample as per your requirement. In our sample, we have created the chart with 3 empty series. For each series we have bound dataset as “ChartDataBindModel” and it is empty by initial. Please find the below code example. 
 
[C#] 
ChartSeries series = new ChartSeries(); 
model = new ChartDataBindModel(this.prodDs1, "Products"); 
model.XName = "Date"; 
model.YNames = new String[] { "Load" }; 
series.SeriesModel = model; 
 
ChartSeries series1 = new ChartSeries(); 
model1 = new ChartDataBindModel(this.prodDs1, "Products"); 
model1.XName = "Date"; 
model1.YNames = new String[] { "Load1" }; 
series1.SeriesModel = model1; 
 
ChartSeries series2 = new ChartSeries(); 
model2 = new ChartDataBindModel(this.prodDs1, "Products"); 
model2.XName = "Date"; 
model2.YNames = new String[] { "Load2" }; 
 
Using timer event we are adding 5 points in dataset for every 15 seconds. This will automatically redraw the chart with new points. Please find the below code example. 
 
[C#] 
private void timer1_Tick(object sender, System.EventArgs e) 
{ 
    try 
    { 
        string tableName = "Products"; 
        Random rand = new Random(); 
        if (prodDs1 != null && prodDs1.Tables.Count > 0) 
        { 
           for(int i = 0; i < 5; i++) 
           { 
             DataRow drEmpty = prodDs1.Tables[tableName].NewRow(); 
             prodDs1.Tables[tableName].Rows.Add(drEmpty); 
             int count = Math.Max(0, prodDs1.Tables[tableName].Rows.Count - 1); 
             prodDs1.Tables[tableName].Rows[count]["Load"] = (double)rand.Next(0, 60); 
             prodDs1.Tables[tableName].Rows[count]["Load1"] = (double)rand.Next(0, 60); 
            prodDs1.Tables[tableName].Rows[count]["Load2"] = (double)rand.Next(0, 60); 
             prodDs1.Tables[tableName].Rows[count]["Date"] = lastTime.AddMinutes(30); 
              }                    
      } 
 
   } 
} 
 
Sample: chart-sample 
 
Kindly check the sample and let us know if you have any concern. 
 
Regards,   
Muneesh Kumar G.  


Loader.
Up arrow icon