Hello Pasi,
how can I make the chart automatically adjust to the height of the Legend box?
ViewXY: Legend Box Layout
Moderator: Queue Moderators
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: ViewXY: Legend Box Layout
You can utilize LegendBox.GetRenderedRect() which tells the screen coordinates of the LegendBox. Adjust margins based on that.
In chart initialization, set chart.AxisLayout.AutoAdjustMargins = false.
In LegendBox.MovedByMouse and chart.SizeChanged event handler, use the following approach to adjust the margins. Here, top margin is adjusted based on legend box, others are at their fixed values.
Rectangle r = m_chart.ViewXY.LegendBox.GetRenderedRect();
m_chart.ViewXY.Margins = new Padding(100, r.Top + r.Height, 50, 30);
In chart initialization, set chart.AxisLayout.AutoAdjustMargins = false.
In LegendBox.MovedByMouse and chart.SizeChanged event handler, use the following approach to adjust the margins. Here, top margin is adjusted based on legend box, others are at their fixed values.
Rectangle r = m_chart.ViewXY.LegendBox.GetRenderedRect();
m_chart.ViewXY.Margins = new Padding(100, r.Top + r.Height, 50, 30);
LightningChart Support Team, PT