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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

real timpe ploting in xamarin.forms

Thread ID:

Created:

Updated:

Platform:

Replies:

144066 Apr 16,2019 06:34 PM UTC Apr 18,2019 05:04 AM UTC Xamarin.Forms 3
loading
Tags: SfChart
mohamad
Asked On April 16, 2019 06:34 PM UTC

hello,I'm writing a program that receives  values from a list and combine it with real time and makes an observableobject  list. but the ptoblem is I want that any 0.5 milliseconds creates a new value on chart. but the function addmillisecond() only takes integers. what should I do?
heres the code:

class viewModel
    {
        public ObservableCollection data { get; set; }
        List values;

        DateTime datetimes;
        public viewModel()
        {
            data = new ObservableCollection();
            values = new List()
            {
                    6.3507080e-02,
                     6.6223145e-02,
                     6.1676025e-02,
                     5.6243896e-02,
                     5.0811768e-02,
                     5.5328369e-02,
                     7.1655273e-02,
                     5.6243896e-02,
                     3.6010742e-03,
                    -2.2674561e-02,
                    -7.2326660e-03,
                     8.8500977e-04,
                    -1.8005371e-03,
                    -1.8005371e-03,
                    -8.1481934e-03,
                    -1.3610840e-02,
                    -2.7160645e-03,
                    ...
                    };
               datetimes = new DateTime(0);

            for (int i = 0; i < 1000; i++)
            {
                data.Add(new model(values[i], datetimes));
                datetimes = datetimes.AddMilliseconds(1);
            }

            LoadData();
        }

        public void LoadData()
        {
            bool val = true;
            int counter = 1001;
            Device.StartTimer(new TimeSpan(0, 0, 0, 0, 50), () =>
            {
                for (int n = 0; n <= 49; n++)
                {
                    data.RemoveAt(n);
                    if (counter == values.Count)
                    {
                        val = false;
                        break;
                        
                    }
                    data.Add(new model(values[counter], datetimes));
                    counter++;
                    datetimes = datetimes.AddMilliseconds(1);
                }
                return val;
            });
        }
    }


Bharathiraja K [Syncfusion]
Replied On April 17, 2019 10:31 AM UTC

Hi Mohamad, 
 
Greetings from Syncfusion. 
 
Yes, the method DateTime.AddMilliseconds(Double) rounded the millisecond to nearest integer, as by the .Net documentation we can use DateTime.AddTicks (Double) method. One Millisecond = 10,000 ticks. So, we can add 5000 ticks for half millisecond. Even though the millisecond will always be rounded to nearest possible integer. We don’t have any other chance.  
.Net documentation: How_to_Add_Milisecond & How_to_Add_ticks 
 
 
 
Regards, 
Bharathi. 


mohamad
Replied On April 17, 2019 06:35 PM UTC

Hi Mohamad, 
 
Greetings from Syncfusion. 
 
Yes, the method DateTime.AddMilliseconds(Double) rounded the millisecond to nearest integer, as by the .Net documentation we can use DateTime.AddTicks (Double) method. One Millisecond = 10,000 ticks. So, we can add 5000 ticks for half millisecond. Even though the millisecond will always be rounded to nearest possible integer. We don’t have any other chance.  
.Net documentation: How_to_Add_Milisecond & How_to_Add_ticks 
 
 
 
Regards, 
Bharathi. 


thanks a lot man

Bharathiraja K [Syncfusion]
Replied On April 18, 2019 05:04 AM UTC

Hi Mohamad,  
 
Thanks for your feedback. 
 
-Bharathi. 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon