»
 

Go Back   ResellerRatings Store Ratings > ResellerRatings Forums > Tech Support

Reply
 
LinkBack Thread Tools Display Modes
Old 06-22-2003, 08:17 AM   #1 (permalink)
Registered User
 
Join Date: Mar 2003
Location: C++ Newbie Hell
Posts: 18
Morphios is on a distinguished road
Drawing a Chart using Borland

Okay where to start.

Hi Everyone

I have an external data file (Scores.dat), which I have written code for, it opens the file up counts the number of times each number is repeated and stores the answer in another file called chart.txt.

What I have now been trying to do is use this file (chart.txt) to draw (using Borland Builder's OnPaint event) a bar chart showing the number of times these numbers are duplicated.

This is my problem:
The code I have written below compiles but is not displaying a bar chart (actually don't know what the call what it's displaying). I have tried to display the bar chart only using Borlands MoveTo and LineTo methods.

After declaring variables and opening the file i have the following code:
Total is the Array.

Code:
while (!(InFile.eof()))//while file still has data 
{ 
InFile >> Index >> ws; //reads data from inFile to Data 
Total[Index] = Total[Index]++; 
Horizontal=0; 
} 
Canvas->MoveTo(0,190);//start point for chart, 1 less than height(200) 

for (Index=0; Index<=100; Index++) 
{ 

Canvas->LineTo(Horizontal,190-(Total[Index]*10));//top left of bar 
Canvas->LineTo(Horizontal+10,190-(Count[Index]*10)); //top right of bar 
Canvas->LineTo(Horizontal+10,190); //bottom right of bar- bottom left of next 
Horizontal=Horizontal+10; //advances bar position 
}
The height has been set to 200, and the size of each bar is its data number say 3 and then *10 to increase the size of the bar. Each bar has a width of 5 pixels.

Can anyone please point where I have gone wrong in my thinking, am I on the right track to drawing the bar chart or do I have to revise my thinking, yet again.?

Any help/guidance will be greatly appreciated

__________________
Morphios
Live Long And Prosper

Last edited by Morphios; 06-27-2003 at 07:47 PM.
Morphios is offline   Reply With Quote
Old 07-03-2003, 06:57 AM   #2 (permalink)
Registered User
 
Join Date: Mar 2003
Location: C++ Newbie Hell
Posts: 18
Morphios is on a distinguished road
Please don't reply, problem sorted now.
__________________
Morphios
Live Long And Prosper
Morphios is offline   Reply With Quote
Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Most Active Discussions

Recent Discussions

All times are GMT -6. The time now is 09:24 PM.