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. Web Development
  3. ASP.NET
  4. Estimate/Calculate time to load a chart in asp.net / C# / JavaScript

Estimate/Calculate time to load a chart in asp.net / C# / JavaScript

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-netbeta-testingquestion
9 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
    Kaare Tragethon
    wrote on last edited by
    #1

    I have some charts taking a long time to load (up to 15 seconds). I would like to calculate the time to load if possible. I already have a feedback to the user using javascript and ajax extensions, but I cannot find any kind of "feedback" from the chart control so that I can display a "6 seconds to finish". Is there any way to calculate/estimate this?

    J K 2 Replies Last reply
    0
    • K Kaare Tragethon

      I have some charts taking a long time to load (up to 15 seconds). I would like to calculate the time to load if possible. I already have a feedback to the user using javascript and ajax extensions, but I cannot find any kind of "feedback" from the chart control so that I can display a "6 seconds to finish". Is there any way to calculate/estimate this?

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      Well the chart control just makes a JPG or PNG image, that you reference in HTML in which your server sends back to the users web browser for display. A well written chart program can generate an image in like 1/10th of a second. So your slow times must be from not closing a Paint handle, SQL handle or something like that, and your waiting for something to timeout. Or you forgot to destroy an object somewhere. The chart control is just a wrapper to the paint or GDI classes in asp.net, I'm not aware of any feedback handle in the chart control. Step through your program using debug, and set some breakpoints.

      K 2 Replies Last reply
      0
      • J jkirkerx

        Well the chart control just makes a JPG or PNG image, that you reference in HTML in which your server sends back to the users web browser for display. A well written chart program can generate an image in like 1/10th of a second. So your slow times must be from not closing a Paint handle, SQL handle or something like that, and your waiting for something to timeout. Or you forgot to destroy an object somewhere. The chart control is just a wrapper to the paint or GDI classes in asp.net, I'm not aware of any feedback handle in the chart control. Step through your program using debug, and set some breakpoints.

        K Offline
        K Offline
        Kaare Tragethon
        wrote on last edited by
        #3

        I'll check it out, thanks!

        1 Reply Last reply
        0
        • J jkirkerx

          Well the chart control just makes a JPG or PNG image, that you reference in HTML in which your server sends back to the users web browser for display. A well written chart program can generate an image in like 1/10th of a second. So your slow times must be from not closing a Paint handle, SQL handle or something like that, and your waiting for something to timeout. Or you forgot to destroy an object somewhere. The chart control is just a wrapper to the paint or GDI classes in asp.net, I'm not aware of any feedback handle in the chart control. Step through your program using debug, and set some breakpoints.

          K Offline
          K Offline
          Kaare Tragethon
          wrote on last edited by
          #4

          I've just tested, and when populating a small amount of data it runs fast, however when populating more data the process slows down. The SQL query runs fine, my x/y plotting runs fine. But after my methods are finished it slows down. It must be something with generating the picture.... FYI: I'm generating a chart based on a timeline with appr. 10000 rows with the X/Y values in two separate columns on each row. Any suggestions?

          J 1 Reply Last reply
          0
          • K Kaare Tragethon

            I've just tested, and when populating a small amount of data it runs fast, however when populating more data the process slows down. The SQL query runs fine, my x/y plotting runs fine. But after my methods are finished it slows down. It must be something with generating the picture.... FYI: I'm generating a chart based on a timeline with appr. 10000 rows with the X/Y values in two separate columns on each row. Any suggestions?

            J Offline
            J Offline
            jkirkerx
            wrote on last edited by
            #5

            Kaare Tragethon wrote:

            But after my methods are finished

            Could you elaborate on that, Which methods, the gathering and packaging of data, or plotting of chart values? or the final write to create the image file to the disk drive Did you make a thousand variables, that the garbage collector has to clean-up at the end of your function? garbage collection takes lots of time to complete. Since your writing in an high level language wrapper, you don't see the extra tasks and time needed to cleanup memory at the end. How big is the final image file size?, over 5 megs? Are you writing a huge PNG at 24 or 32 bits, instead of a compressed JPG? A nice chart is something that is 640 x 480, easy to read, no scrolling. Or you can change the program to create each record 1 by 1, and loop it to create 10K charts, just kidding, but serious about breaking it down into smaller pieces. You might of run out of memory RAM and threads, and the computer is doing a huge disk swap to complete the job. You may need to do some serious optimization on your code there.

            K 1 Reply Last reply
            0
            • J jkirkerx

              Kaare Tragethon wrote:

              But after my methods are finished

              Could you elaborate on that, Which methods, the gathering and packaging of data, or plotting of chart values? or the final write to create the image file to the disk drive Did you make a thousand variables, that the garbage collector has to clean-up at the end of your function? garbage collection takes lots of time to complete. Since your writing in an high level language wrapper, you don't see the extra tasks and time needed to cleanup memory at the end. How big is the final image file size?, over 5 megs? Are you writing a huge PNG at 24 or 32 bits, instead of a compressed JPG? A nice chart is something that is 640 x 480, easy to read, no scrolling. Or you can change the program to create each record 1 by 1, and loop it to create 10K charts, just kidding, but serious about breaking it down into smaller pieces. You might of run out of memory RAM and threads, and the computer is doing a huge disk swap to complete the job. You may need to do some serious optimization on your code there.

              K Offline
              K Offline
              Kaare Tragethon
              wrote on last edited by
              #6

              I mean that it doesn't take long to do the following:

              //.....
              command.CommandText = "SELECT TimeStamp, " + siloNo + " FROM SilosGraphHistory";
              UxChartSiloHistory.DataSource = command.ExecuteReader();
              UxChartSiloHistory.Series["UxChartSeriesSilo"].XValueMember = "TimeStamp";
              UxChartSiloHistory.Series["UxChartSeriesSilo"].YValueMembers = siloNo;
              UxChartSiloHistory.DataBind();
              //.....

              It exits my method (that fetches data from the SQL server and binds them to the chart) in milliseconds. Then, after that, I'm unable to find out why it takes so long... Do you have any tricks to detect where the time goes?? The final size when saving it to my desktop is just 30kb. I am indeed a beginner in ASP.NET and C# so please have that in mind, and thank you very much for taking the time to answer my questions....

              J 1 Reply Last reply
              0
              • K Kaare Tragethon

                I have some charts taking a long time to load (up to 15 seconds). I would like to calculate the time to load if possible. I already have a feedback to the user using javascript and ajax extensions, but I cannot find any kind of "feedback" from the chart control so that I can display a "6 seconds to finish". Is there any way to calculate/estimate this?

                K Offline
                K Offline
                Kaare Tragethon
                wrote on last edited by
                #7

                Found the "problem": I was using the Spline chart which takes a long time to calculate. Changed it to Fastline with the following results: 10000 points (10000 X-values and 10000 Y-values) Spline took appr. 27 seconds Fastline took appr. 0.5 seconds Thanks for the feedback, it helped me on the way...

                1 Reply Last reply
                0
                • K Kaare Tragethon

                  I mean that it doesn't take long to do the following:

                  //.....
                  command.CommandText = "SELECT TimeStamp, " + siloNo + " FROM SilosGraphHistory";
                  UxChartSiloHistory.DataSource = command.ExecuteReader();
                  UxChartSiloHistory.Series["UxChartSeriesSilo"].XValueMember = "TimeStamp";
                  UxChartSiloHistory.Series["UxChartSeriesSilo"].YValueMembers = siloNo;
                  UxChartSiloHistory.DataBind();
                  //.....

                  It exits my method (that fetches data from the SQL server and binds them to the chart) in milliseconds. Then, after that, I'm unable to find out why it takes so long... Do you have any tricks to detect where the time goes?? The final size when saving it to my desktop is just 30kb. I am indeed a beginner in ASP.NET and C# so please have that in mind, and thank you very much for taking the time to answer my questions....

                  J Offline
                  J Offline
                  jkirkerx
                  wrote on last edited by
                  #8

                  I didn't know you were binding, that's different. I thought you were using pure code to build your chart. I'm not sure if you have downloaded the sample project that shows how to make various charts. In the sample project, they are combinations of code behind and objects, and use small xml files for data to feed the points, so that's why they run so fast. The sample projects are a good way to learn how to build a faster chart object. I haven't used a bound object in over 7 years, so I'm not qualified for assisting you. There good for small websites, but not practical for hi volume use because of the amount of resources needed, and speed. There's nothing you can do about the speed right now, until you expand you skill set to write part of it in code. You should try here and ask for help, the chart control is a beast, and took me a couple of weeks to understand how to write one in pure code. Objects like the Chart and Gridview can actually be their own forum, because the skys the limit on those topics. But go ahead and ask the same question again, and see what the bound chart object guru's say about it. Good Luck with that! http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/[^]

                  K 1 Reply Last reply
                  0
                  • J jkirkerx

                    I didn't know you were binding, that's different. I thought you were using pure code to build your chart. I'm not sure if you have downloaded the sample project that shows how to make various charts. In the sample project, they are combinations of code behind and objects, and use small xml files for data to feed the points, so that's why they run so fast. The sample projects are a good way to learn how to build a faster chart object. I haven't used a bound object in over 7 years, so I'm not qualified for assisting you. There good for small websites, but not practical for hi volume use because of the amount of resources needed, and speed. There's nothing you can do about the speed right now, until you expand you skill set to write part of it in code. You should try here and ask for help, the chart control is a beast, and took me a couple of weeks to understand how to write one in pure code. Objects like the Chart and Gridview can actually be their own forum, because the skys the limit on those topics. But go ahead and ask the same question again, and see what the bound chart object guru's say about it. Good Luck with that! http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/[^]

                    K Offline
                    K Offline
                    Kaare Tragethon
                    wrote on last edited by
                    #9

                    jkirkerx wrote:

                    I didn't know you were binding, that's different.

                    Sorry for that, I should have provided more info in my initial post. Thanks for the excellent link, I'll sure read about it and may ask some questions here.... Thanks again for helping me out :-)

                    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