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