Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Character based graphs from VFP
Message
From
24/07/1998 07:02:17
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
24/07/1998 03:47:17
Andrew Logie
Institute of Food Research
Reading, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00120892
Message ID:
00120909
Views:
22
>Hello,
>
>A little background is required to justify my posting in the 1998 windows world...
>
>I have written a little web based application that allows our budget managers access to their accounting data (VFP Automation Server, it includes Excel downloads, drill down and around etc. etc.) I was asked recently about providing a frame within the browser to display a graph of whatever level of detail was currently being viewed. No problem ... looked at MS Graph object model - that could work. The basic problem I have is that the VFP part is blindingly fast on our data sets (200,000 rows) compared to the graphing element and I get a major difference between users "wandering" through their data and the graphs being calculated, downloaded and then displayed. As an alternative I thought I might be able to use VFP to output a text character bar chart - could use HTML to brighten it up.
>
>So at the danger of sounding naff has anyone written or heard of a character based VFP utility to output character based graphs ?
>
>Andrew Logie
Andrew,
I don't know how you provide viewing (no experience in web forms). If you could show whatever printed on a form (I mean if VFP lines, shapes etc) then doing it purely with VFP is fastest (I provide my users with line graphs repainted as data changes, blindingly fast and pure VFP). If you could show MSGraph object then at runtime you can just change datasheet values so no reload time.

I had been writing char based bar graphs in FPDOS 2.x. It's somewhat a series of graph chars in system font (ASCII table). I don't know how it would work if done in win world. Bar chart type was horizontal bars. Idea is to start from top, go down and finally add an axis, labels. First highest value row is calculated and translated into 80 or 136 char wide format with a constant K. All other bar widths are calculated with this K with max accuracy half char width (I mean if a full block represented 100 then 42 and 26 both have half width block). Another approach I used was temporarily calling an exe written in Turbo Prolog (uses Borland graphing).

Below is a simplier percent graph routine. A report is created with detail has two 100 char width fields and one RowLabel field with expressions :
padl(pcGraf(nLeftBarField,nRowTotal),100," ")
padr(pcGraf(nRightBarField,nRowTotal),100," ")
Between two detail fields another third field (centered) holds row labels :
eval(cRowLabel)

In footer there are lines under two detail fields (each 100 char width) as axis and below them vertical lines for tickmarks and finally below it labels ranging (100 - 0 for left and 0-100 for right bars).

The main problem is FP report writer formats output sometimes not compatible with text viewing (especially containing lines and boxes, grouping) and later must be processed (wrote code for that but so long to include here).

Also you should use "report .. to file ascii" with a generic printer and nocptrans, terminal font I think (or chnage blockchars with windows ie:symbol, wingdings set).
* Note : Format\font\Terminal to see actual DOS chars
* Viewing in DOS also needs CP 437 (printing in DOS is OK)
FUNCTION PCGRAF
parameters nNumber, nTotal, lLeft
if parameters() < 3
   lLeft = .f.
endif
REMAINDER=(nNumber*100/nTotal)*10%10
FULLBLOK=FLOOR((nNumber*100/nTotal))
if lLeft
	RETURN ;
		LTRIM(STR(nNumber))+	" (%"+;
		LTRIM(STR(nNumber*100/nTotal,6,2)) +	") "+ ;
		IIF(REMAINDER<2.5,"",IIF(REMAINDER>7.5,"Û","&#222;"))+;
		REPLICATE("Û",FULLBLOK)
else
	RETURN REPLICATE("Û",FULLBLOK)+;
		IIF(REMAINDER<2.5,"",IIF(REMAINDER>7.5,"Û","Y")) +;
		+" "+LTRIM(STR(nNumber))+	" (%"+;
		LTRIM(STR(nNumber*100/nTotal,6,2)) +	")"
endif
Good luck.
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