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 / C++ / MFC
  4. trying to draw a line graph

trying to draw a line graph

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structuresquestion
9 Posts 5 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.
  • A Offline
    A Offline
    aei_totten
    wrote on last edited by
    #1

    OK, Here's the deal. I have a dialog based MFC application and a large amount of data points (7296 of them actually) and I want to be able to graph these on a line graph on the dialog somewhere. One additional consern, I want to be able to do this from within a thread that is called frequently (every 8 ms). So here are the questions. 1. Is it possible? LOL. 2. What object type do I need to add to my dialog class to use functions like polyline, which I see in a lot of examples? All of the examples are not using a dialog based app. Can you even use those functions with a dialog app? oops I guess that was two quesitons. 4. Is that a good way to approach this or should I be looking for a library? 5. Any good free libraries you know of that do this?

    S C A L 4 Replies Last reply
    0
    • A aei_totten

      OK, Here's the deal. I have a dialog based MFC application and a large amount of data points (7296 of them actually) and I want to be able to graph these on a line graph on the dialog somewhere. One additional consern, I want to be able to do this from within a thread that is called frequently (every 8 ms). So here are the questions. 1. Is it possible? LOL. 2. What object type do I need to add to my dialog class to use functions like polyline, which I see in a lot of examples? All of the examples are not using a dialog based app. Can you even use those functions with a dialog app? oops I guess that was two quesitons. 4. Is that a good way to approach this or should I be looking for a library? 5. Any good free libraries you know of that do this?

      S Offline
      S Offline
      Saurabh Garg
      wrote on last edited by
      #2

      There are several graph components on codeproject. Plot Graphic Library[^] A 2D data visualisation class[^] A 2D Graph Component With Zoom Capability[^] -Saurabh

      1 Reply Last reply
      0
      • A aei_totten

        OK, Here's the deal. I have a dialog based MFC application and a large amount of data points (7296 of them actually) and I want to be able to graph these on a line graph on the dialog somewhere. One additional consern, I want to be able to do this from within a thread that is called frequently (every 8 ms). So here are the questions. 1. Is it possible? LOL. 2. What object type do I need to add to my dialog class to use functions like polyline, which I see in a lot of examples? All of the examples are not using a dialog based app. Can you even use those functions with a dialog app? oops I guess that was two quesitons. 4. Is that a good way to approach this or should I be looking for a library? 5. Any good free libraries you know of that do this?

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        As an alternative from the other reply: I also made a chart control (see my sig) and I think it can fulfill your needs. Some remarks though: if you plan to do that from a worker thread, a better approach would be to send a user-defined message to the dialog on which you have the graph instead of accessing the graph directly from your thread: MFC objects can't be shared across threads. Once you receive the message, you extract the point value out of it and plot it on the chart.

        Cédric Moonen Software developer
        Charting control [v1.4] OpenGL game tutorial in C++

        1 Reply Last reply
        0
        • A aei_totten

          OK, Here's the deal. I have a dialog based MFC application and a large amount of data points (7296 of them actually) and I want to be able to graph these on a line graph on the dialog somewhere. One additional consern, I want to be able to do this from within a thread that is called frequently (every 8 ms). So here are the questions. 1. Is it possible? LOL. 2. What object type do I need to add to my dialog class to use functions like polyline, which I see in a lot of examples? All of the examples are not using a dialog based app. Can you even use those functions with a dialog app? oops I guess that was two quesitons. 4. Is that a good way to approach this or should I be looking for a library? 5. Any good free libraries you know of that do this?

          A Offline
          A Offline
          aei_totten
          wrote on last edited by
          #4

          I have been going through all of the stuff you listed and I think at least something will work, I just haven't decided on what yet. Thanks

          1 Reply Last reply
          0
          • A aei_totten

            OK, Here's the deal. I have a dialog based MFC application and a large amount of data points (7296 of them actually) and I want to be able to graph these on a line graph on the dialog somewhere. One additional consern, I want to be able to do this from within a thread that is called frequently (every 8 ms). So here are the questions. 1. Is it possible? LOL. 2. What object type do I need to add to my dialog class to use functions like polyline, which I see in a lot of examples? All of the examples are not using a dialog based app. Can you even use those functions with a dialog app? oops I guess that was two quesitons. 4. Is that a good way to approach this or should I be looking for a library? 5. Any good free libraries you know of that do this?

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #5

            aei_totten wrote:

            Is that a good way to approach this or should I be looking for a library?

            A simple line graph without 3D Vista spinning glitzery should be very simple to draw.

            aei_totten wrote:

            I want to be able to do this from within a thread that is called frequently (every 8 ms).

            8 ms? That's an animation not a graph. I don't think that is very realistic unless it's part of game or something.

            led mike

            C 1 Reply Last reply
            0
            • L led mike

              aei_totten wrote:

              Is that a good way to approach this or should I be looking for a library?

              A simple line graph without 3D Vista spinning glitzery should be very simple to draw.

              aei_totten wrote:

              I want to be able to do this from within a thread that is called frequently (every 8 ms).

              8 ms? That's an animation not a graph. I don't think that is very realistic unless it's part of game or something.

              led mike

              C Offline
              C Offline
              Cedric Moonen
              wrote on last edited by
              #6

              led mike wrote:

              8 ms? That's an animation not a graph. I don't think that is very realistic unless it's part of game or something.

              Yes, it can be realistic: for example if you are receiving data from an external sensor that sends a point every 8 msec. Of course, the rendering won't be displayed every 8 msec because of the delays in the chain but the user won't see a difference (sometimes data will be enqueued and processed later for example).

              Cédric Moonen Software developer
              Charting control [v1.4] OpenGL game tutorial in C++

              M 1 Reply Last reply
              0
              • C Cedric Moonen

                led mike wrote:

                8 ms? That's an animation not a graph. I don't think that is very realistic unless it's part of game or something.

                Yes, it can be realistic: for example if you are receiving data from an external sensor that sends a point every 8 msec. Of course, the rendering won't be displayed every 8 msec because of the delays in the chain but the user won't see a difference (sometimes data will be enqueued and processed later for example).

                Cédric Moonen Software developer
                Charting control [v1.4] OpenGL game tutorial in C++

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                There's still no reason to redraw faster than a monitor is refreshing :) I'd personally save my CPU cycles for other work and throttle the redraws down to 25-50 FPS (even 50 would be overkill) - there wouldn't be any visible difference. Mark

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                C 1 Reply Last reply
                0
                • M Mark Salsbery

                  There's still no reason to redraw faster than a monitor is refreshing :) I'd personally save my CPU cycles for other work and throttle the redraws down to 25-50 FPS (even 50 would be overkill) - there wouldn't be any visible difference. Mark

                  Mark Salsbery Microsoft MVP - Visual C++ :java:

                  C Offline
                  C Offline
                  Cedric Moonen
                  wrote on last edited by
                  #8

                  Mark Salsbery wrote:

                  There's still no reason to redraw faster than a monitor is refreshing

                  One 'reason' would be that the chart control you are using doesn't support refreshing at constant rate :). Most of the time, you add a point to a series and the control displays it immediately. But you can do that in a better way (like I did for my control for example :-D ): in the case of my chart control, adding a point to a series will only draw the missing segment. But of course that only happen under a certain condition: if the axes are not automatic for example (the control doesn't need to be refreshed in that case). Another solution would be to store those points in your application and draw several of them at a certain time. But then you'll need to use a timer to trigger the redrawing of the points (or a thread).

                  Cédric Moonen Software developer
                  Charting control [v1.4] OpenGL game tutorial in C++

                  M 1 Reply Last reply
                  0
                  • C Cedric Moonen

                    Mark Salsbery wrote:

                    There's still no reason to redraw faster than a monitor is refreshing

                    One 'reason' would be that the chart control you are using doesn't support refreshing at constant rate :). Most of the time, you add a point to a series and the control displays it immediately. But you can do that in a better way (like I did for my control for example :-D ): in the case of my chart control, adding a point to a series will only draw the missing segment. But of course that only happen under a certain condition: if the axes are not automatic for example (the control doesn't need to be refreshed in that case). Another solution would be to store those points in your application and draw several of them at a certain time. But then you'll need to use a timer to trigger the redrawing of the points (or a thread).

                    Cédric Moonen Software developer
                    Charting control [v1.4] OpenGL game tutorial in C++

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    Indeed! :) :beer:

                    Mark Salsbery Microsoft MVP - Visual C++ :java:

                    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