Page 1 of 1

Need help with Horizontal histogram!

Posted: Fri May 09, 2008 3:48 pm
by 13048939
I've been using TeeChart successfully with line and bar charts however I'm having trouble with a horizontal Histogram.

I have a range or numbers, for example one hundred numbers between 1 and 5. In other words x number are 1, x number are 2, x number are 3 etc etc.

I need to plot the nmbers 1 - 5 on the Y axis and the number of occurences on the X and display horizontal bars displaying the number of occurences for each. Something like this

5 ||||||||||||
4 ||||||
3 |||||||||||||||||
2 ||||
1 ||||||||||||
0 5 10 15 20 25

I'm having trouble creating a series and adding it in such a way to produce the chart required. Any help would be much appreciated, many thanks.

Posted: Mon May 12, 2008 8:10 am
by narcis
Hi edgemeistergeneral,

To achieve what you request you need to populate horizontal series like this:

Code: Select all

			horizHistogram1.Add(25, 0);
			horizHistogram1.Add(13, 1);
			horizHistogram1.Add(23, 2);
			horizHistogram1.Add(19, 3);
			horizHistogram1.Add(3, 4);
			horizHistogram1.Add(6, 5);

Posted: Mon May 12, 2008 3:18 pm
by 13048939
Many thanks, that worked a treat.

There is one small problem however that I can't seem to solve. The bottom and top horizontal lines of the series are half the size of the others. Is there a way I can set the thickness of the bars so they are all the same?

thanks

Posted: Mon May 12, 2008 3:29 pm
by narcis
Hi edgemeistergeneral,

Yes, you can either set axes min. and max. offset:

Code: Select all

			tChart1.Axes.Left.MaximumOffset = 30;
			tChart1.Axes.Left.MinimumOffset = 30;
or manually set left axis min. and max. values:

Code: Select all

			tChart1.Axes.Left.SetMinMax(horizHistogram1.MinYValue() - 1, horizHistogram1.MaxYValue() + 1);

Posted: Mon May 12, 2008 3:37 pm
by 13048939
perfect, many thanks!