Page 1 of 2

vertical axe in a Horizontal bar graph

Posted: Wed Nov 29, 2006 12:59 pm
by 8122357
Hi,

Is it possible to have a vertical axe in a horizontal bar graph that always aligns to 0 on the horizontal axe? The 0 aligns in the middle and the bars are, dependent of their values, on the left or the right side of the vertical axe.

I hope it's a bit clear what I mean.

Greetings,

Ricky

Posted: Wed Nov 29, 2006 1:22 pm
by narcis
Hi Ricky,

Yes, this is possible, you can try doing something like this:

Code: Select all

		private void Form1_Load(object sender, EventArgs e)
		{
			for (int i = 0; i < 10; i++)
			{
				horizBar1.Add((i - 5) * 10);
			}
		}

		private void tChart1_BeforeDrawAxes(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			Rectangle rect = tChart1.Chart.ChartRect;

			tChart1.Axes.Left.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
			tChart1.Axes.Left.RelativePosition = tChart1.Axes.Bottom.CalcPosValue(0) - rect.Left;
			tChart1.Axes.Left.StartPosition = 0;
			tChart1.Axes.Left.EndPosition = rect.Bottom - rect.Top;
		}

Posted: Wed Nov 29, 2006 2:08 pm
by 8122357
I don't know if this is te right sollution. I have an image wich explains the situation a bit better.

The bar should be on the 0 between the bars on the left and the right side.

Posted: Wed Nov 29, 2006 2:12 pm
by narcis
Hi SNSSEC,

The code snippet I posted does what you request for me here using latest TeeChart for .NET v2 release at the client area. Which TeeChart version are you using? Are you using the code in the BeforeDrawAxes event?

Posted: Wed Nov 29, 2006 3:57 pm
by 8122357
Hi,
Thank you for the quick reply. The problem was indeed that I didn't use the BeforeDrawAxes event.

It works fine now, thank you. :)

Greetings,

Ricky

Posted: Wed Dec 13, 2006 9:12 am
by 8122357
Hi,

I thought it worked, it places the left axe in the middle of the chart, but the 0% on the bottom axe doesn't align with it. Does anyone have a idea to do this?

Images for reference:
Image

Image

Greetings,

Ricky

Posted: Wed Dec 13, 2006 9:39 am
by narcis
Hi Ricky

I guess that this offset is caused by the "-200%" label which goes out of the bottom axis. You can try setting bottom axes offsets:

Code: Select all

			tChart1.Axes.Bottom.MinimumOffset = 10;
			tChart1.Axes.Bottom.MaximumOffset = 10;

Posted: Wed Dec 13, 2006 9:58 am
by 8122357
Thnx for the reply, but this doesn't seem to work. Isn't there a way to get the 0 always in the middle. It isn't just one where it has to work, there are multiple graphs with different sizes. I need a sollution works for all of them.

Greetings.

Posted: Wed Dec 13, 2006 10:23 am
by narcis
Hi SNSSEC,

Could you please send us a simple example we can run "as-is" to reproduce the problem here or export the image chart to a .ten file? We will try if we can find a solution to this issue.

You can post your files at news://www.steema.net/steema.public.attachments newsgroup.

Thanks in advance.

Posted: Wed Dec 13, 2006 10:31 am
by 8122357
Hi,

because of security reasons I can't get on the newsgroup, so I've uploaded the file somewhere else.

http://www.yousendit.com/transfer.php?a ... 0a161d5d16

Thanks in advance.

Greetings,

Ricky

Posted: Wed Dec 13, 2006 1:10 pm
by narcis
Hi Ricky,

Thanks for your the file. It works fine for me here importing your file and forcing the chart to be re-drawn after loading it:

Code: Select all

		private void Form1_Load(object sender, System.EventArgs e)
		{
			this.tChart1.Import.Template.Load("Chart1.ten");

			//Call to force the chart being re-drawn and axes positions calculated:
			Bitmap bmp = this.tChart1.Bitmap;
		}

		private void tChart1_BeforeDrawAxes(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			Rectangle rect = tChart1.Chart.ChartRect;

			tChart1.Axes.Left.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
			tChart1.Axes.Left.RelativePosition = tChart1.Axes.Bottom.CalcPosValue(0) - rect.Left;
			tChart1.Axes.Left.StartPosition = 0;
			tChart1.Axes.Left.EndPosition = rect.Bottom - rect.Top;
		}
I'm using latest TeeChart for .NET v2 maintenance release available at the client area. Which TeeChart version are you using?

I've also tried to reproduce the problem in a new project without success:

Code: Select all

		private void Form1_Load(object sender, EventArgs e)
		{
			tChart1.Aspect.View3D = false;

			Steema.TeeChart.Styles.HorizBar horizBar1 = new Steema.TeeChart.Styles.HorizBar(tChart1.Chart);

			for (int i = 0; i < 10; i++)
			{
				horizBar1.Add((i - 5) * 10);
			}

			tChart1.Axes.Bottom.SetMinMax(-100, 100);			
		}

		private void tChart1_BeforeDrawAxes(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			Rectangle rect = tChart1.Chart.ChartRect;

			tChart1.Axes.Left.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
			tChart1.Axes.Left.RelativePosition = tChart1.Axes.Bottom.CalcPosValue(0) - rect.Left;
			tChart1.Axes.Left.StartPosition = 0;
			tChart1.Axes.Left.EndPosition = rect.Bottom - rect.Top;
		}

		private void tChart1_GetAxisLabel(object sender, Steema.TeeChart.GetAxisLabelEventArgs e)
		{
			if (sender == tChart1.Axes.Bottom)
			{
				e.LabelText += " %";
			}
		}
If the problem persists, could you pleas modify my code so that we can reproduce the problem here?

Thanks in advance.

Posted: Wed Dec 13, 2006 2:21 pm
by 8122357
I'm using Teechart for .net 1.1 (1.1.2004.16592), maybe the problem lies there.

I can't reproduce the code in the way you have it, as it isn't build in one place.

Greetings,

Ricky

Posted: Wed Dec 13, 2006 2:35 pm
by narcis
Hi Ricky,

Importing your .ten file, as I posted previously, also works fine for me using the latest TeeChart for .NET v1 update build we posted last week at the client area. Can you please test if it works fine at your end?

Posted: Thu Dec 14, 2006 7:44 am
by 8122357
I've installed the latest build (Build 1.1.2531.28391), but the problem still exists. I just don't understand why it isn't a standard option within teechart to have an axe on that postion, instead of finding a workaround. When you want a horizontal bar graph with negatives in one side and the positives on the other, it's most likely you want to devide them with an axe.
As it seems now I have to do it without one, because leaving it in there like this is a bit useless.

Thanks for your help though. I hope someone finds a solution to solve this problem.

Greetings,
Ricky

Posted: Thu Dec 14, 2006 9:43 am
by narcis
Hi Ricky,

Have you checked that your project's TeeChart.dll reference has been properly updated? If the problem persists could you please send us a simple example project we can run "as-is" to reproduce the problem here?

Thanks in advance.