Page 1 of 1

Not all series visible in legend when form is small

Posted: Sun Aug 23, 2009 2:48 am
by 13047134
I've noticed that if the form containing TC is quite small and I have a largish number of series in the TC then not all series are shown in the legend. If I resize the form making it bigger the missing series appear in the legend, reducing the size and the series dissapear again. This is dependant upon the font size used for the legend items, smaller font, more items.

I understand that there is a scroll bar option but this wont work for me as I use an export of the image in documents, the export also doesn't show all legend items.

is there some way to determine that not all series are visible in the legend? alternativle is there some way to automatically change the font size for legend items to ensure that all items are visible.

Adrian.

Re: Not all series visible in legend when form is small

Posted: Mon Aug 24, 2009 11:38 am
by narcis
Hi Adrian,

Yes, you can do something like this:

Code: Select all

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

		private void InitializeChart()
		{
			tChart1.Dock = DockStyle.Fill;

			for (int i = 0; i < 10; i++)
			{
				tChart1.Series.Add(new Steema.TeeChart.Styles.Bar());
				tChart1[i].FillSampleValues();
			}

			tChart1.GetLegendRect += new Steema.TeeChart.GetLegendRectEventHandler(tChart1_GetLegendRect);
		}

		void tChart1_GetLegendRect(object sender, Steema.TeeChart.GetLegendRectEventArgs e)
		{
			for (int i = 0; i < tChart1.Legend.Items.Count; i++)
			{
				Point p = new Point(tChart1.Legend.Items[i].Left, tChart1.Legend.Items[i].Top);
				if ((!e.Rectangle.Contains(p)) && (tChart1.Legend.Font.Size>1))
				{
					tChart1.Legend.Font.Size--;
				}
			}
		}