Re: Chart Performance Problem with Large Data Set
From: Sascha Sertel (sascha_at_ninaza.com)
Date: 08/02/04
- Next message: Alvin Bruney [MVP]: "Re: OWC11 ExportPicture messed up alignment, label positions, and more"
- Previous message: Sascha Sertel: "Re: OWC11 ExportPicture messed up alignment, label positions, and more"
- In reply to: Salil Gaitonde: "Chart Performance Problem with Large Data Set"
- Next in thread: Salil Gaitonde: "Re: Chart Performance Problem with Large Data Set"
- Reply: Salil Gaitonde: "Re: Chart Performance Problem with Large Data Set"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 2 Aug 2004 09:03:28 -0700
Salil,
first of all, I'm not sure if there is a way to make your code significantly
faster, since even if you put 50,000+ data points in an Excel *** and
generate a chart from it, it will take some time. However, you did not
specify how much time "long time" actually is, so I will try to give you my
2 cents for performance optimization:
1. I looked through your code and the first thing I saw is that everything
seems to be hardcoded. Did you do that only for readability in the posting
or is this really done this way? Especially for all those lines like
seriesData(0 , 0) = "0.0"
...snip...
seriesData(8863 , 0) = "0.0"
seriesData(8864 , 0) = "0.0"
it would be much better to have FOR loops running over your dataset to
assign 0 as initialization value. Not only will this be optimized for
execution by the interpreter, but it also makes your code a lot shorter,
because you get from 50,000+ lines down to just a couple. Remember that
Internet Explorer also has to load your whole file and parse it before
executing it, and having 50,000+ lines just for initialization and another
100,000+ lines for setting the colors and borders makes a HUGE file to
parse, which already takes a significant amount of time.
2. The same thing applies to your colors. Even though you are using
different colors, from what I can tell from your code example it seems that
there is a certain pattern, so if there is one, use FOR loops and
conditional statements to assign your colors and borders instead of
hardcoding everything, which really creates a lot of code, and you already
identified this as a potential performance bottleneck. Have you tried
building your graph without that code and letting the OWC use its standard
colors? How does this affect the execution time?
3. The next thing I saw in your code is that you are using a Workbook to
supply your graph with data. That seems like a unnecessary detour to me.
Since your data is in an array already, why don't you just use the array
data directly to set the data for your Series with c.chDataLiteral instead
of c.chDataBound? I think you are losing time by recreating your whole data
in the Workbook again and then creating the graph from that data. I have to
admit, though, that using the array directly requires some code changes,
mainly that you split your two-dimensional array in 6 one-dimensional
arrays, so that you can use each array for one Series in your graph.
However, eventually it might speed up things.
4. This just popped into my head, it might not be an issue at all, but I
still want to mention it: Sometimes drawing routines can significantly slow
down such a process, since in a worst case scenario the graph or visible
object is updated for every change to the data sets, every color you set
etc., and therefore causes huge slowdowns for large amounts of data. A
simple example for that is a ListView. Anyone who has ever populated a
ListView dynamically has probably experienced that updating the scrollbar
for every added item takes up 90% of the time, and what took 30 seconds
before can be done in a fraction of a second when hiding the control, adding
the data, and making it visible then. Maybe the same scheme could do some
magic for you, you could for example try hiding the div your are drawing
your graph in and display it after the graph creation is finished, and you
could also swap around some function calls and first populate and initialize
your data arrays before you create the Workbook and Chart objects. As I
said, this might not do anything at all in this case, but it's always good
to keep every possiblity in mind!
Hope that helps,
Sascha
- Next message: Alvin Bruney [MVP]: "Re: OWC11 ExportPicture messed up alignment, label positions, and more"
- Previous message: Sascha Sertel: "Re: OWC11 ExportPicture messed up alignment, label positions, and more"
- In reply to: Salil Gaitonde: "Chart Performance Problem with Large Data Set"
- Next in thread: Salil Gaitonde: "Re: Chart Performance Problem with Large Data Set"
- Reply: Salil Gaitonde: "Re: Chart Performance Problem with Large Data Set"
- Messages sorted by: [ date ] [ thread ]