Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Slow Graph
Message
From
12/04/2000 11:06:26
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
12/04/2000 07:37:31
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Miscellaneous
Thread ID:
00358580
Message ID:
00358695
Views:
17
>Does anyone have any ideas why Microsoft Graph 8 is so slow? I have it instantiated and formatted as I would like it on a form. The form opens - no problem, but as soon as the code fires to bring the graph up to date, my disk goes into overdrive and I have to wait until the graph wakes up.
>
>Once the intial wake up period is over, the update speed isn't too bad (could be better) but its this initial time out that is the real pain and fustration to the users.
>
>Here's the update code. It may help someone to see what's wrong.
>
>(It only goes to sleep during the first up date)
>
>lnPressRow = 1
>lnTempRow = 2
>lnColCtr = 1
>
>with this.olePTGraph
>
> scan
> lnColCtr = lnColCtr + 1
> .Worksheets("Sheet1").cells( lnPressRow, lnColCtr ).value = PressBarg
> .Worksheets("Sheet1").cells( lnTempRow, lnColCtr ).value = Temp
> endscan
>
> lcColLtr = chr( dnLetterA + lnColCtr - 1 )
>
> .Charts("Chart1").SetSourceData( .Worksheets("Sheet1").Range("a1:" + lcColLtr + "2"))
>endwith
>
>
>Better still, I would appreciate if anyone could point me in the right direct for a better solution (preferably free) which is faster and stable withing FoxPro.
>
>Any ideas would be most welcome
>
>Jason


Jason,
First of all know that MSGraph, Excel, Word etc etc using VBA code are slow. It's something that you cannot do much about. You could only do much of process possible at VFP side before going to OLE object. That is, say for example you need to write 20 lines of text in Word. If you write them line by line at word side via VBA code than you would really wait. Worse you would wait more if the word is visible then. OTOH if VFP first makes 20 lines of text a single string with CRLF in it then word would only write "one" line :) Same in Excel, filling 100 cell values one by one is like toothpulling. Prepare at VFP side as a tab delimited string, copy to clipboard and paste in excel. You would really see what I mean if it was 1000-10000 or so cells. MSGraph uses same logic in this context. In that scan loop, instead of setting cell values one by one , prepare a tab delimited string with CRLF for rows. Then invoke graph with that string.

For the update part, instead of changing cell values one by one in scan loop, change it when data changes so overload would be distributed (and not changed ones unnecesserialy wouldn't be set again).
Your code seems more like Excel code than MSGraph. This is another side of it. Code style, support changes from version to version. Your code might fail on a computer where MSGraph is registered with version 5. Unfortunately only free alternative I know is MSChart Activex. It's really much faster than MSGraph but I don't know its constants (IOW cannot use for the moment). If your charts are simple type (line, bar) then the fastest and free one is pure VFP itself :) With VFP only approach you could even dare to refresh 10 graphs per field change -lostfocus- on a grid on a P200 with 32Mb RAM (been there done that:).
For complex charts nonFree alternative is Excel itself as my preference. Its code support is much better than MSGraph. Also there are 3rd party ones like Flipper but I didn't have a chance to see one of them on action.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform