Problem with DrawBarGraph

Moderator: Rathinagiri

chrisjx2002
Posts: 192
Joined: Wed Jan 06, 2010 5:39 pm

Problem with DrawBarGraph

Post by chrisjx2002 »

Hello,

When I want to draw a bar graph, the labels are not in front of the bars (look at the attached file : there is a little shift for each month). I have made a small example of that problem using the sample in GRAPH.03. If using the line or point there is no problem. The bug seems to be in h_graph.prg but I don't know how to correct it.

There is another limit in this program : it is impossible to draw a graph with more than 16 values. I have to change it in the h_graph.prg program and to make a rebuild. The values that have to be changed are in the FOR NEXT using ni.

Any help would be very appreciated
Attachments
Graph03.jpg
Graph03.jpg (49.49 KiB) Viewed 4922 times
chrisjx2002
Posts: 192
Joined: Wed Jan 06, 2010 5:39 pm

Re: Problem with DrawBarGraph

Post by chrisjx2002 »

RE UP

Nobody uses this function or there is perhaps another possibility to draw graph with HMG?
User avatar
Rathinagiri
Posts: 5480
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Problem with DrawBarGraph

Post by Rathinagiri »

I will check and revert back.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
chrisjx2002
Posts: 192
Joined: Wed Jan 06, 2010 5:39 pm

Re: Problem with DrawBarGraph

Post by chrisjx2002 »

Thanks a lot!
chrisjx2002
Posts: 192
Joined: Wed Jan 06, 2010 5:39 pm

Re: Problem with DrawBarGraph

Post by chrisjx2002 »

Hello,

I have made some changes in the h_graph.prg file in order to have the labels in front of the bars.

You will find attached the new version. I have also supress three variables that seems to do nothing : nSep, nResH and nResV.

I also change the limits of the graph in order to have the possibility to have 31 bars : for a graph on a month for example.

I test it with the 3.0.46 version. It seems to work correctly.

You can add it in a next release of HMG.

Regards
Attachments
h_graph.zip
(7.09 KiB) Downloaded 231 times
Graph01.jpg
Graph01.jpg (48.47 KiB) Viewed 4656 times
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: Problem with DrawBarGraph

Post by Pablo César »

chrisjx2002 wrote:I have made some changes in the h_graph.prg file in order to have the labels in front of the bars.
..//..
I also change the limits of the graph in order to have the possibility to have 31 bars : for a graph on a month for example.
Good. Can you post any example just to see the differances ?
I have also supress three variables that seems to do nothing : nSep, nResH and nResV.
What I noted that nSep, nResH and nResV is used in several places. I think it is used as factorial value. Sorry, but I do not think is good idea to be removed.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
chrisjx2002
Posts: 192
Joined: Wed Jan 06, 2010 5:39 pm

Re: Problem with DrawBarGraph

Post by chrisjx2002 »

Hello,

To test it you can use the samples provided with HMG. You will notice that now the labels are in the right places. You can see that on the screenshots that have joined to this previous message : on the first there is a shift of the labels.

For the parameters that i have suppressed do as you want but they are fixed values that are not changed in the programm... Perhaps they were created for a future option never developed.

Regards
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Problem with DrawBarGraph

Post by Pablo César »

chrisjx2002 wrote:To test it you can use the samples provided with HMG.
I have not the same example to test it.
chrisjx2002 wrote:I have made a small example of that problem using the sample in GRAPH.03.
I have compiled this same teste and the result seems ok for me:
Screen65.PNG
Screen65.PNG (23.78 KiB) Viewed 4607 times
I have compiled this example without your modifications, ie, with original HMG lib.
You can see that on the screenshots that have joined to this previous message : on the first there is a shift of the labels.
It is for this reason I asked you to post this example to be compared.
For the parameters that i have suppressed do as you want but they are fixed values that are not changed in the programm... Perhaps they were created for a future option never developed.
You are right: at moment it has not any function because this local variables are default value with 1 for (nResH and nResV) and 0 for nSep. But if you see this nSep could be assignable because is an argument of function, look at this:

Procedure GraphShow(parent,nTop,nLeft,nBottom,nRight,nHeight,nWidth,aData,cTitle,aYVals,nBarD,nWideB,nSep,nXRanges,;
l3D,lGrid,lxGrid,lyGrid,lxVal,lyVal,lLegends,aSeries,aColors,nType,lViewVal,cPicture , nLegendWindth , lNoborder )

But at i_graph.ch nSep is with value Nil then inside the procedure will be assigned a default value with 0.

Any way, my suggestion it is to let like this, probably in the future, could make new parameters and can be utilized this variables. For now, I do not think this is problem for untidy strings in the graphic. Doesn't it ? And better not be cutted off these variables in order to let for the future implements.

Thanks for your explanations but I would to know where exactly you have modified. I shall see later both sources to compare...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
chrisjx2002
Posts: 192
Joined: Wed Jan 06, 2010 5:39 pm

Re: Problem with DrawBarGraph

Post by chrisjx2002 »

Hello,

When you look at the graph, it is not good. Look at the green bar. On the first month the bar is in front of the label : Jan. For the label Mar it is the orange bar and for May it is the purple one.

If you change the h_graph.prg by the one I have modified you will have for this example another graph where the green bar is always in front of the label : no shift.

The change is at line 526 : nPos += nWide+nSep
is replaced by
nPos += ( nWideB - nWide )/ Len(aSeries) - 10 * (Len(aSeries) - 1) / Len(aSeries)

I have made a few tests with this correction and it seems to be OK. What is strange is that it is OK for the other kinds of graph.
Attachments
demograph.jpg
demograph.jpg (58.27 KiB) Viewed 4580 times
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Problem with DrawBarGraph

Post by Pablo César »

Chrisjx2002, thank you for your explanations. :)

But sorry, in my humble opinion, this graphic should be shown like this:
Screen65a.PNG
Screen65a.PNG (74.19 KiB) Viewed 4448 times
Please note, this graphic I re-edited by "Paint Brush". Also see that quadrants are out of range in the original picture. Should be shown 5 columns not 6.

For me, this rotine there is more than this problem of columns description (in this case months).
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply