Hi,
I'm adjusting my XY chart margins to make room for the legend below the graph surface. However, with many traces on the chart the legend box is now several rows. How (or when) can I adjust margins? What I've attempted is the following after all data series have been added:
// Chart created and series added here...
// Adjust margin on bottom area to allow legend + cursor enough room to avoid overlapping (the legend is in
// front which we don't want).
System.Drawing.Rectangle legendRect = Chart1.ViewXY.LegendBox.GetRenderedRect();
Chart1.ViewXY.Margins = new Thickness(Chart1.ViewXY.Margins.Left,
Chart1.ViewXY.Margins.Top,
Chart1.ViewXY.Margins.Right,
Chart1.ViewXY.Margins.Bottom + legendRect.Height + 10);
// Update complete.
Chart1.EndUpdate();
However, GetRenderedRect() is 0,0,0,0; not very useful. I see no other clear chance to adjust the margin before rendering the chart. Obviously I don't want to render it once with the wrong margin then redo. Suggestions?
Paul T.
LegendBox
Moderator: Queue Moderators
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: LegendBox
Hi Paul,
probably making a special handling in AfterRendering event.
probably making a special handling in AfterRendering event.
Code: Select all
bool m_bFirstTime = true;
void m_chart_AfterRendering(LightningChartUltimate.LightningChartUltimate chart)
{
if (m_bFirstTime)
{
System.Drawing.Rectangle legendRect = m_chart.ViewXY.LegendBox.GetRenderedRect();
m_chart.ViewXY.Margins = new Thickness(m_chart.ViewXY.Margins.Left,
m_chart.ViewXY.Margins.Top,
m_chart.ViewXY.Margins.Right,
m_chart.ViewXY.Margins.Bottom + legendRect.Height + 10);
m_bFirstTime = false;
m_chart.InvalidateVisual();
}
}
LightningChart Support Team, PT
Re: LegendBox
Yes, that worked.
Thanks,
Paul T.
Thanks,
Paul T.