Performance issue when we reload the bounded data structure
Hi Syncfusion Support!
We noticed a performance issue when we have to reload the data structure behind our SfDateTimeRangeNavigator.
The performance is very well with the SfCharts. Most of the time we use SuspendSeriesNotification() and Resume method.
Is there a similar supportive set of methods for the SfDateTimeRangeNavigator available?
Thank you!
regards,
Sascha
SIGN IN To post a reply.
1 Reply
SR
Samuel Rajadurai Edwin Rajamanickam
Syncfusion Team
February 20, 2019 09:09 PM UTC
Hi Sacha,
Greetings from syncfusion,
SfDateTimeRangeNavigator does not support suspend notification. We can still achieve this using a temporary collection to handle the dynamic data and a current collection to update the SfDateTimeRangeNavigator. The following code snippet demonstrates to achieve your requirement. We have also attached a sample based on this.
Code Snippet
XAML
|
<chart:SfDateTimeRangeNavigator Grid.Row="1" XBindingPath="XValue” ItemsSource="{Binding CurrentData}"/>
|
C#
ViewModel
|
public class ViewModel
{
public ViewModel()
{
var date = new DateTime(2019, 1, 1);
TempData = new ObservableCollection<Model>();
CurrentData = new ObservableCollection<Model>();
CurrentData.Add(new Model() { XValue = date.AddDays(0), YValue = 20 });
CurrentData.Add(new Model() { XValue = date.AddDays(1), YValue = 10 });
CurrentData.Add(new Model() { XValue = date.AddDays(2), YValue = 40 });
CurrentData.Add(new Model() { XValue = date.AddDays(3), YValue = 30 });
}
public ObservableCollection<Model> TempData { get; set; }
public ObservableCollection<Model> CurrentData { get; set; }
}
|
Data Manipulation
|
public partial class MainWindow : Window
{
Random randomVariable = new Random();
DateTime lastDate = new DateTime();
// Timer to load dynamic data.
DispatcherTimer timer;
ViewModel viewModel;
public MainWindow()
{
InitializeComponent();
timer = new DispatcherTimer();
timer.Tick += Timer_Tick;
timer.Interval = TimeSpan.FromMilliseconds(100);
viewModel = this.DataContext as ViewModel;
}
private void Timer_Tick(object sender, EventArgs e)
{
var itemsSource = viewModel.TempData;
// Gets the last date from the collection.
if (itemsSource.Count > 0)
{
lastDate = itemsSource[itemsSource.Count - 1].XValue;
}
else
{
lastDate = viewModel.CurrentData[viewModel.CurrentData.Count - 1].XValue;
}
itemsSource.Add(new Model() { XValue = lastDate.AddDays(1), YValue = randomVariable.Next(10, 40) });
}
private void StartTimerButton_Click(object sender, RoutedEventArgs e)
{
timer.Start();
}
private void EndTimerButton_Click(object sender, RoutedEventArgs e)
{
timer.Stop();
}
private void UpdateButton_Click(object sender, RoutedEventArgs e)
{
var viewModel = (this.DataContext as ViewModel);
foreach (var tempData in viewModel.TempData)
{
viewModel.CurrentData.Add(tempData);
}
viewModel.TempData.Clear();
}
}
|
Regards,
Samuel
Samuel
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
SA Sascha
- Feb 19, 2019 05:34 PM UTC
- Feb 20, 2019 09:09 PM UTC