Axis Positioning

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Luke
Newbie
Newbie
Posts: 68
Joined: Thu Oct 11, 2007 12:00 am

Axis Positioning

Post by Luke » Mon Nov 03, 2008 7:50 am

How can I make the X axis (bottom) appear at 0 on the Y axis and vice versa, so I want x/y to intersect at 0,0. But for labels for the axis to appear still at the bottom or left of the chart.


Also even when switching automaticmin and max to false. setting min and max has no effect on the chart, does this need to done in a specific order?

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

Post by Narcís » Mon Nov 03, 2008 11:03 am

Hi Luke,
How can I make the X axis (bottom) appear at 0 on the Y axis and vice versa, so I want x/y to intersect at 0,0. But for labels for the axis to appear still at the bottom or left of the chart.
If you want labels to be drawn at the edges of the chart drawing area I recommend you to set axes AxisPen.Visible=false and use ColorLine tool for drawing one vertical and one horizontal line at 0. Otherwise you could do something like what's shown here.
Also even when switching automaticmin and max to false. setting min and max has no effect on the chart, does this need to done in a specific order?
Why don't you try using SetMinMax instead? It will handle everything automatically.
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

Luke
Newbie
Newbie
Posts: 68
Joined: Thu Oct 11, 2007 12:00 am

Post by Luke » Mon Nov 03, 2008 11:56 am

tried setMinMax and doesnt work. The axis properties are updated but still the Axis on the chart shows large min and max than i set

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

Post by Narcís » Mon Nov 03, 2008 12:03 pm

Hi Luke,

Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

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

Luke
Newbie
Newbie
Posts: 68
Joined: Thu Oct 11, 2007 12:00 am

Post by Luke » Mon Nov 03, 2008 2:36 pm

tried

void tChart_AfterDraw(object sender, Graphics3D g)
{
tChart.Axes.Bottom.PositionUnits = PositionUnits.Pixels;
tChart.Axes.Bottom.RelativePosition = tChart.Axes.Bottom.Position - tChart.Axes.Left.CalcYPosValue(0);
}

but axes always flickers between origin 0,0 and bottom of graph where it was before when resizing

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

Post by Narcís » Mon Nov 03, 2008 3:54 pm

Hi Luke,

Sorry but I'm not sure about what you are trying to achieve here. How are your other axes and series set up? An example we can run "as-is" to reproduce the issue here would be very helpful. Also, have you tried using ColorLine tool as I suggested? If so, did you found any problem with that?

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

Luke
Newbie
Newbie
Posts: 68
Joined: Thu Oct 11, 2007 12:00 am

Post by Luke » Mon Nov 03, 2008 3:55 pm

using the shortcut you posted
http://www.teechart.net/support/viewtop ... xis+origin

The axes shifts between the 0 position and actual bottom.


Yep using the colour line, its better behaved. thx

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

Post by Narcís » Tue Nov 04, 2008 9:54 am

Hi Luke,

You can translate that example to the .NET version like the code snippet below which works fine for me here.

Code: Select all

		public Form1()
		{
			InitializeComponent();
			InitializeChart();
		}

		private bool usePercentages;

		private void InitializeChart()
		{
			usePercentages = false;

			tChart1.Aspect.View3D = false;
			tChart1.Dock = DockStyle.Fill;

			Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

			for (int i = -5; i <= 10; i++)
			{
				line1.Add(i,i);
			}

			tChart1.Panel.MarginUnits = Steema.TeeChart.PanelMarginUnits.Pixels;

			tChart1.AfterDraw +=new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
			tChart1.Resize += new EventHandler(tChart1_Resize);
			tChart1.Draw();
		}

		void tChart1_Resize(object sender, EventArgs e)
		{
			tChart1.Draw();
		}	

		void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			if (usePercentages)
			{
				int chartWidth = tChart1.Axes.Right.Position - tChart1.Axes.Left.Position;
				int horizZeroLoc = tChart1.Axes.Bottom.CalcXPosValue(0 - tChart1.Axes.Left.Position);
				int horizPercentLoc = horizZeroLoc / chartWidth * 100;

				tChart1.Axes.Left.PositionUnits = Steema.TeeChart.PositionUnits.Percent;
				tChart1.Axes.Left.RelativePosition = horizPercentLoc;

				int chartHeight = tChart1.Axes.Bottom.Position - tChart1.Axes.Top.Position;
				int vertZeroLoc = tChart1.Axes.Left.CalcYPosValue(0 - tChart1.Axes.Top.Position);
				int vertPercentLoc = vertZeroLoc / chartHeight * 100;

				tChart1.Axes.Bottom.PositionUnits = Steema.TeeChart.PositionUnits.Percent;
				tChart1.Axes.Bottom.RelativePosition = (100 - vertPercentLoc);				
			}
			else
			{
				tChart1.Axes.Left.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
				tChart1.Axes.Left.RelativePosition = tChart1.Axes.Bottom.CalcXPosValue(0) - tChart1.Axes.Left.Position;

				tChart1.Axes.Bottom.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
				tChart1.Axes.Bottom.RelativePosition = tChart1.Axes.Bottom.Position - tChart1.Axes.Left.CalcYPosValue(0);
			} 
		}
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