6 Answers, 1 is accepted
Based on these details we cannot provide you with specific implementation. Basically creating real time data involves working with the native DateTime class.
Furthermore, it is up to your needs to decide how exactly that class should be used in your particular application.
The only example that I think is reasonable assumes that you need to create the data every first minute with start time this particular moment. For this scenario a counter/timer can be used.
Windows.UI.Xaml.DispatcherTimer timer;
void
CreateTimer()
{
timer =
new
Windows.UI.Xaml.DispatcherTimer();
timer.Interval = TimeSpan.FromMinutes(1);
timer.Tick += timer_Tick;
timer.Start();
}
void
timer_Tick(
object
sender,
object
e)
{
//this will be called every 1 minute
//you should create your data here
//using DateTime.Now you will be able to track the time
//when your data is created timer.Stop() should be called
}
I hope this information is helpful.
Regards,
Pavel R. Pavlov
Telerik
thanks Pavel R. Pavlov
in date time class i have code lineseries it not to add realtime data . how to add data real time chart
my code in timer tick : chart is refresh lineseries but no add data
private void _timer_Tick3(object sender, object e)
{​
List<Data> data1 = new List<Data>();
data1.Add(new Data() { Value = this.Temperature }); // or random data
data1.Add(new Data() { Value = this.Temperature });
List<Data> data2 = new List<Data>();
data2.Add(new Data() { Value1 = this.Humidity });
data2.Add(new Data() { Value1 = this.Humidity });
this.lineSeries.Series[0].DataContext = data1;
this.lineSeries.Series[1].DataContext = data2;
}
​
I have hard time understanding what your requirements are. Initially I thought you need to create business data where one of the fields is of type DateTime and you need to create new data record every second. I do not understand what you have in mind when you say: "chart is refresh lineseries but no add data ". Note that the charting component has nothing in common with the timer tick event you sent.
Moreover you actually create new list each tick of the timer. Is that what you really need? In case you want to preserve any number of points as history of the graph you need to only add points into the series - do not create new List<Data> every second.
And still I have the feeling that I do not fully understand your scenario. I need you to provide me with clear and detailed requirements in order to ensure that we are walking in the right direction.
P.S.: I would like to turn your attention to the fact that the Temperature and Humidity parameters in the most common sense are not expected to change every second. If the fields of the provided code hold real sensor readings maybe the reason behind not updating the chart is the dynamic of those parameters.
Regards,
Pavel R. Pavlov
Telerik
this is an example http://www.flotcharts.org/flot/examples/realtime/index.html
sorry.
I explain the poor.
The example was helpful. I understand what you need to achieve. For your convenience I created a sample project which can be used as foundations of your application. Please note that all the updating logic is in the custom logic in the ViewModel.
I hope this is helpful.
Regards,
Pavel R. Pavlov
Telerik