We made a new tweak in the newest version 6.5.5, TweakDisablePresent and TweakEnabledPresent methods. We didn't intend to teach this to our customers to prevent them from getting confused
Here's code that shows how to use them. Note however, that every time you set automatic margins enabled/disabled, it will refresh all the rendering data of the series. So it will have a drastic performance affect if you have a lot of data. Don't call this code every time you add data, use it only now and then, for example when axis ranges are changed or axes are added.
Code: Select all
void m_chart_SizeChanged(object sender, EventArgs e)
{
m_chart.BeginUpdate();
//Special tweak: Let the rendering code run, but don't render
m_chart.TweakDisablePresent();
m_chart.ViewXY.AxisLayout.AutoAdjustMargins = true;
m_chart.EndUpdate();
Rectangle r = m_chart.ViewXY.GetMarginsRect();
m_chart.BeginUpdate();
m_chart.ViewXY.AxisLayout.AutoAdjustMargins = false;
//User left, top and bottom as they were measured by contents of axis labels, but change right margin
m_chart.ViewXY.Margins = new Padding(r.Left, r.Top,
m_chart.ClientSize.Width - r.Right + 30, //Add 30 px
m_chart.ClientSize.Height - r.Bottom);
//Special tweak: enable rendering.
m_chart.TweakEnablePresent();
m_chart.EndUpdate();
}