Page 1 of 1

Align Legend with Left Axis

Posted: Mon Mar 09, 2009 1:43 pm
by 13048070
Hi,

I'm trying to align the left hand side of the chart legend with the left axes of my chart (- I say left axes because actually there is more than one stacked on top of eachother but their position is where the default left axis would be I presume?). I've set the legend.customposition property to true and if I hard code a value for the legends.left property (e.g. 20) it appears in the correct position but I'd like to align it relative to the axis position instead rather than hardcoding a value but it always appears way over to the left (e.g. looks like .left is being set to 0).

Thanks,

Norman

Posted: Tue Mar 10, 2009 2:55 pm
by narcis
Hi Norman,

Yes, you can do something like this:

Code: Select all

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

		private void InitializeChart()
		{
			Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
			bar1.FillSampleValues();

			tChart1.Legend.CustomPosition = true;
			tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
			tChart1.Draw();
		}

		void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			tChart1.Legend.Left = tChart1.Axes.Left.Position;
			tChart1.Legend.Top = tChart1.Axes.Left.IStartPos;
		}