Page 1 of 1

Bar chart showing positive and negative values on x-Axis

Posted: Tue Aug 14, 2007 10:37 am
by 13045482
I want to plot a bar graph which will display positive values on the right side and negative values on the left hand side.The positive and negative values will appear on the horizontal axis.I am new to Teechart So kindly help me to solve my problem.

Posted: Tue Aug 14, 2007 11:24 am
by narcis
Hi Tina,

Sorry but I don't fully understand what you are trying to achieve exactly. However, reading Tutorial 4 - Axis Control may be really helpful. You'll find the tutorials at TeeChart's program group.

If this doesn't help please give us some more details about what are you trying to achieve.

Thanks in advance.

Posted: Fri Aug 17, 2007 6:44 am
by 13045482
is there any way to send a screenshot or attachment so that it will be more clear. Also do you have any helpline phone no. where we can call you guys and describe it.

Basically I have a data

radio 30
tv -50
paper 60

Now when i plot a bar graph i get a graph in which on X axis i can see radio,tv and paper and on Y axis i can see -60 to 60 values. Now what i want is that on X axis I should be able to see -60 to 60 and Y axis should cut X axis at 0. Thus the resultant bars will be either on right or on left of Y axis.Please let me know how to achieve it preferably by some sample code. Its highly highly urgent requirement and we need v urgent support on this.Many thanks in advance.[/img]

Posted: Fri Aug 17, 2007 8:00 am
by narcis
Hi Tina,

Yes, it would be very helpful if you could send us an image of your requirements or even also a simple example project. You can send your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

We don't have a support phone line. If you are looking for priority support you may be interested in our Pro-Support program described here.

Thanks in advance.

Y AXIS SHOULD CUT x AXIS AT ZERO

Posted: Fri Aug 17, 2007 10:41 am
by 13045482
I have uploaded the screen shoot . I want my Y axis to cut x axis always on zero.Also x axis scale may change everytime the application runs. We have tried doing this by settinng position % of Y axis to 50% but it does not set it accurately(ie it does not erxacly cut x axis at zero). How to achieve this?

Posted: Fri Aug 17, 2007 11:06 am
by narcis
Hi Tina,

Thanks for the image.

You can find an example of what you request here. This example always positions horizontal and vertical axes on zero position. This is a TeeChart Pro ActiveX example but the same should be applied to TeeChart for .NET.

Posted: Mon Aug 20, 2007 10:13 am
by 13045482
Thanks I tried using this code in my .NET program
tChart1.Axes.Left.PositionUnits=puPercent;
tChart1.Axes.Left.PositionPercent = 50;

but it gives these errors:

1. pupercent does not exist in the class or namespace 'test_teechart.Form1".
2.
steema.teechart.axis does not contain definiotion for PositionPercent

Posted: Mon Aug 20, 2007 10:23 am
by narcis
Hi Tina,

Please find below the answers to your questions:

1. You should use this:

Code: Select all

tChart1.Axes.Left.PositionUnits == Steema.TeeChart.PositionUnits.Percent
2. Try using:

Code: Select all

teeChart.Axes.Left.RelativePosition = 50;

Posted: Mon Aug 20, 2007 10:45 am
by 13045482
Thanks this does not give synax error, but also it does not cut exactly at zero at X axis(it cuts somewhere near zero).I am uploading screenshot of same.

Posted: Mon Aug 20, 2007 11:29 am
by narcis
Hi Tina,

Would you be so kind to also send an example project we can run "as-is" to reproduce the problem here?

Thanks in advance.

Posted: Tue Aug 21, 2007 8:25 am
by 13045482
I have uploaded the same.

Posted: Tue Aug 21, 2007 8:50 am
by narcis
Hi Tina,

Thanks for your example project. It almost has nothing to do with the example I pointed you at. However this works fine like this:

Code: Select all

		private void button1_Click(object sender, System.EventArgs e)
		{
			horizBar1.Add(-3,"Pears",Color.Red); 
			horizBar1.Add(4,"Apples",Color.Blue);       
			horizBar1.Add(2,"Oranges",Color.Green);
			
			Bitmap bmp = tChart2.Bitmap;

			tChart2.Axes.Left.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
			tChart2.Axes.Left.RelativePosition = tChart2.Axes.Bottom.CalcXPosValue(0) - tChart2.Axes.Left.Position;
		}
Please notice that you'd better implement the axis positioning code at the AfterDraw event so that every time the chart is scrolled or zoomed the axes will be automatically repositioned. Also, to have valid axes positions to set up left axis I used the Bitmap call to have the chart being internally drawn and axes positions have valid values.