Page 1 of 1

Help with Margin on Axis Bottom

Posted: Mon Dec 10, 2007 11:09 pm
by 8878570
I am using TeeChart for .NET Version 2, and am building a financial graph with multiple right axes and a bottom axis. I would like a margin on each side of the bottom axis. I seem to almost be able to accomplish this by setting Axes.Bottom.StartPosition and Axes.Bottom.EndPosition to 2 and 98 respectively, but the problem is that the series are still drawing in the margins that it creates. I am not using Automatic on the Axes, I am setting them with SetMinMax, Automatic will not work for what I am doing.

I would like for the series not to be visible in the gap that I create. Is there a way to do this?

Thanks for any help.

Posted: Tue Dec 11, 2007 9:09 am
by narcis
Hi jjs2002,

Are your series assigned to this bottom axis? The code below works fine for me here using latest TeeChart for .NET v2 release available at the client area. Which version are you using exactly?

Code: Select all

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

			Steema.TeeChart.Styles.Candle candle1 = new Steema.TeeChart.Styles.Candle(tChart1.Chart);
			
			candle1.FillSampleValues();
			candle1.HorizAxis = Steema.TeeChart.Styles.HorizontalAxis.Bottom;

			tChart1.Axes.Bottom.StartPosition = 2;
			tChart1.Axes.Bottom.EndPosition = 98;
		}
If the problem persists, 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.atatchments newsgroup or at our upload page.

Thanks in advance.

Posted: Tue Dec 11, 2007 9:41 pm
by 8878570
I used the code that you pasted in the comment above, and had the same problem. It works great when the graph first loads up, but if you zoom in and drag around you will see that the series draws inside of the margin created between the bottom axis and the vertical axis. I would like for this margin to be empty even when zooming or dragging.

I am using TChart for .NET version 2.0.2586.24039. Thanks for any more help!

Posted: Wed Dec 12, 2007 10:41 am
by narcis
Hi jjs2002,

In that case you can use the ClipRectangle method in the BeforeDrawValues event:

Code: Select all

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

			Steema.TeeChart.Styles.Candle candle1 = new Steema.TeeChart.Styles.Candle(tChart1.Chart);
			
			candle1.FillSampleValues();
			candle1.HorizAxis = Steema.TeeChart.Styles.HorizontalAxis.Bottom;

			tChart1.Axes.Bottom.StartPosition = 2;
			tChart1.Axes.Bottom.EndPosition = 98;

			candle1.BeforeDrawValues += new Steema.TeeChart.PaintChartEventHandler(candle1_BeforeDrawValues);
		}

		void candle1_BeforeDrawValues(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			Steema.TeeChart.Styles.Series s = sender as Steema.TeeChart.Styles.Series;

			int left = s.GetHorizAxis.IStartPos;
			int right = s.GetHorizAxis.IEndPos;
			int top = s.GetVertAxis.IStartPos;
			int bottom = s.GetVertAxis.IEndPos;
			g.ClipRectangle(left, top, right, bottom); 
		}