vertical axe in a Horizontal bar graph

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
SNSSEC
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

vertical axe in a Horizontal bar graph

Post by SNSSEC » Wed Nov 29, 2006 12:59 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 29, 2006 1:22 pm

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;
		}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

SNSSEC
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Post by SNSSEC » Wed Nov 29, 2006 2:08 pm

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.
Last edited by SNSSEC on Thu Nov 30, 2006 10:42 am, edited 1 time in total.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Nov 29, 2006 2:12 pm

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?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

SNSSEC
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Post by SNSSEC » Wed Nov 29, 2006 3:57 pm

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

SNSSEC
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Post by SNSSEC » Wed Dec 13, 2006 9:12 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Dec 13, 2006 9:39 am

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;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

SNSSEC
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Post by SNSSEC » Wed Dec 13, 2006 9:58 am

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Dec 13, 2006 10:23 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

SNSSEC
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Post by SNSSEC » Wed Dec 13, 2006 10:31 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Dec 13, 2006 1:10 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

SNSSEC
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Post by SNSSEC » Wed Dec 13, 2006 2:21 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Dec 13, 2006 2:35 pm

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?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

SNSSEC
Newbie
Newbie
Posts: 10
Joined: Fri Nov 15, 2002 12:00 am

Post by SNSSEC » Thu Dec 14, 2006 7:44 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Thu Dec 14, 2006 9:43 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply