Page 1 of 1

Legend Custom Position

Posted: Thu Feb 08, 2018 3:08 pm
by 9526439
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 7413 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 7415 times
We don't know whether it is a refreshing issue or some other problem. Kindly guide us.

Thanks & regards
Plano research

Re: Legend Custom Position

Posted: Fri Feb 09, 2018 9:05 am
by Christopher
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 7404 times