depicting data in c# in realtime
-
hello I want to depict a chart dynamically and every 3 millisecond a point is send to the chart . when I run my program about 8sec it will be executed very more than 8sec( about 3 mins or more).(i used wpftoolkit charting, dynamic data display , ... but none of them works well). also when I want to depict 6000 point in offline mode(storing data in an array and at last depicting it on a chart) ,yet there is a such problem. Matlab depicts these data very rapidly . is there any way to depict these data in c#?
-
hello I want to depict a chart dynamically and every 3 millisecond a point is send to the chart . when I run my program about 8sec it will be executed very more than 8sec( about 3 mins or more).(i used wpftoolkit charting, dynamic data display , ... but none of them works well). also when I want to depict 6000 point in offline mode(storing data in an array and at last depicting it on a chart) ,yet there is a such problem. Matlab depicts these data very rapidly . is there any way to depict these data in c#?
Matlab doesn't depict them in three milliseconds either. It may be quick, but it's not realtime. There's no realtime software under Windows, as Windows isn't a realtime OS. It's the OS that determines how many processortime you get.
khomeyni wrote:
is there any way to depict these data in c#?
Yes; and can be relatively quick too. Draw your graph once, and instead of redrawing when a new datapoint appears, scroll everything a single pixel and add the new point to the right. Having a complete table in memory and charting the complete table every iteration will never be fast - not even if you use assembly.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
Matlab doesn't depict them in three milliseconds either. It may be quick, but it's not realtime. There's no realtime software under Windows, as Windows isn't a realtime OS. It's the OS that determines how many processortime you get.
khomeyni wrote:
is there any way to depict these data in c#?
Yes; and can be relatively quick too. Draw your graph once, and instead of redrawing when a new datapoint appears, scroll everything a single pixel and add the new point to the right. Having a complete table in memory and charting the complete table every iteration will never be fast - not even if you use assembly.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
I've this simple code but it takes about 20sec to be depicted!
private void button1_Click(object sender, RoutedEventArgs e)
{
ObservableCollection<ChartItem> InputItems = new ObservableCollection<ChartItem>();
for (int i = 0; i < 6000; i++)
{
InputItems.Add(new ChartItem(i, i));
}
InputLine.ItemsSource = InputItems;}
}
public class ChartItem : INotifyPropertyChanged
{
public ChartItem(double t, double v)
{
time = t;
myVar = v;
}private double time; public double Time { get { return time; } set { time = value; OnPropertyChanged("Time"); } } private double myVar; public double Value { get { return myVar; } set { myVar = value; OnPropertyChanged("Value"); } } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { if (this.PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } }
}
with using : System.Windows.Controls.DataVisualization.Toolkit and System.Windows.Controls.DataVisualization.Toolkit
-
I've this simple code but it takes about 20sec to be depicted!
private void button1_Click(object sender, RoutedEventArgs e)
{
ObservableCollection<ChartItem> InputItems = new ObservableCollection<ChartItem>();
for (int i = 0; i < 6000; i++)
{
InputItems.Add(new ChartItem(i, i));
}
InputLine.ItemsSource = InputItems;}
}
public class ChartItem : INotifyPropertyChanged
{
public ChartItem(double t, double v)
{
time = t;
myVar = v;
}private double time; public double Time { get { return time; } set { time = value; OnPropertyChanged("Time"); } } private double myVar; public double Value { get { return myVar; } set { myVar = value; OnPropertyChanged("Value"); } } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { if (this.PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } }
}
with using : System.Windows.Controls.DataVisualization.Toolkit and System.Windows.Controls.DataVisualization.Toolkit
If you're "looking" for faster code - you won't find it. It's something that needs to be written. You plot the graph yourself, and update the graph with new info instead of redrawing it completely. Human eyes aren't realtime either; you'd need 24 frames/second to get it to look convincingly realtime. Although Windows might delay your app (one a single-core machine, a virusscanner and some automatic updates would do the trick), it should be doable to update a picture in a reasonable time.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
If you're "looking" for faster code - you won't find it. It's something that needs to be written. You plot the graph yourself, and update the graph with new info instead of redrawing it completely. Human eyes aren't realtime either; you'd need 24 frames/second to get it to look convincingly realtime. Although Windows might delay your app (one a single-core machine, a virusscanner and some automatic updates would do the trick), it should be doable to update a picture in a reasonable time.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]