Page 1 of 1

Axis Positioning

Posted: Mon Nov 03, 2008 7:50 am
by 13047002
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?

Posted: Mon Nov 03, 2008 11:03 am
by narcis
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.

Posted: Mon Nov 03, 2008 11:56 am
by 13047002
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

Posted: Mon Nov 03, 2008 12:03 pm
by narcis
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.

Posted: Mon Nov 03, 2008 2:36 pm
by 13047002
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

Posted: Mon Nov 03, 2008 3:54 pm
by narcis
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.

Posted: Mon Nov 03, 2008 3:55 pm
by 13047002
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

Posted: Tue Nov 04, 2008 9:54 am
by narcis
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);
			} 
		}