Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. depicting data in c# in realtime

depicting data in c# in realtime

Scheduled Pinned Locked Moved C#
csharpdata-structureshelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    khomeyni
    wrote on last edited by
    #1

    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#?

    L 1 Reply Last reply
    0
    • K khomeyni

      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#?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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[^]

      K 1 Reply Last reply
      0
      • L Lost User

        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[^]

        K Offline
        K Offline
        khomeyni
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • K khomeyni

          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

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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[^]

          K 1 Reply Last reply
          0
          • L Lost User

            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[^]

            K Offline
            K Offline
            khomeyni
            wrote on last edited by
            #5

            there is one another question: why can Matlab depict these charts so faster than c# ?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups