[Tutor] How to create variable length bar chart ??
Alan Gauld
alan.gauld at btinternet.com
Wed Dec 6 21:03:29 CET 2006
"Asrarahmed Kadri" <ajkadri at googlemail.com> wrote in
> What I want is the height of the bar chart should be determined
> dynamically
> (basically it means the length of the Y-axis), as per the number of
> data-items being displayed.
Hmm, I thought we ansdwered this recently...
Anyhow you just calculate it.
The height will be for an example with 3 bars:
3 times the height of a bar plus the inter bar space.
You might want to add some extra height on at the top.
Or you might want to have a bigger or smaller gap at top
and bottom than between the bars but basically its a case
of work out rthe pattern then calculate according to the data.
The worst case is:
<- top_gap
XXXXXXXXXXXXX
XXXXXXXXXXXX
<- gap_size
XXXXXXXXXXXXXX <- bar_size
<- bottom_gap
-------------------------------- <-- X axis
height = (bottom_gap+ top_gap) + ((N-1) * (bar_size+gap_size)) +
bar_size
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list