Legend Custom Position

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
amol
Advanced
Posts: 231
Joined: Tue Mar 29, 2005 5:00 am

Legend Custom Position

Post by amol » Thu Feb 08, 2018 3:08 pm

Hi Steema support,

We are facing one problem regarding the legend position on Chart. We are using the Dot Net TChart version 2012.
The problem is that we set the legend position on the chart and then close the chart again we open same chart the legend doesn't show at previous position.
legend1.png
legend1.png (18.55 KiB) Viewed 8071 times
We set the legend position on Resize and GetLegendPos events. In these events we write the below code is as follows:-

double px = XLegendLocation;
double py = YLegendLocation;
if (this.Series.Count > 0)
{
px = this.Series[0].ValuePointToScreenPoint(px, 0).X;
py = this.Series[0].ValuePointToScreenPoint(0, py).Y;
}
this.Legend.Top = Convert.ToInt32(py);
this.Legend.Left = Convert.ToInt32(px);

But when we click on chart the legend position is set to the previous location.
legend2.png
legend2.png (15.46 KiB) Viewed 8073 times
We don't know whether it is a refreshing issue or some other problem. Kindly guide us.

Thanks & regards
Plano research

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Legend Custom Position

Post by Christopher » Fri Feb 09, 2018 9:05 am

amol wrote: We don't know whether it is a refreshing issue or some other problem. Kindly guide us.
Yes, I think that the legend needs to repositioned at every chart repaint and not just when the chart is resized. You can use one of the repaint events shown in this example:
TeeChartNetExamples_2018-02-09_09-57-06.png
TeeChartNetExamples_2018-02-09_09-57-06.png (184.84 KiB) Viewed 8062 times
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Post Reply