Page 1 of 1
ViewXY - GetMarginsRectangle
Posted: Tue Nov 24, 2015 12:38 pm
by ahe
In order to align the axes of a LightningCharts ViewXY with charts from a different vendor, I am using the following code to determine the minium padding of the chart:
Code: Select all
chart.BeginUpdate();
view.AxisLayout.AutoAdjustMargins = true;
chart.EndUpdate();
var rect = GetMarginRectangle()
chart.BeginUpdate();
view.AxisLayout.AutoAdjustMargins = false;
chart.EndUpdate();
//... calculate common maximum ...
view.Margin = new Padding( ... );
Unfortunately, this invokes an actual update, thus making the chart "twitch".
Is there a similar function, that calculates the needed optimal margins in the background?
Re: ViewXY - GetMarginsRectangle
Posted: Wed Nov 25, 2015 4:50 pm
by ArctionPasi
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();
}
Re: ViewXY - GetMarginsRectangle
Posted: Thu Nov 26, 2015 10:58 am
by ahe
Thank you, this definitely improves the behaviour
But you are right, those are some confusingly named functions.
May I anyway ask for a CalculateMarginRect() as feature request for a future version which does the calculation independently from the rendering?
Re: ViewXY - GetMarginsRectangle
Posted: Mon Nov 30, 2015 9:03 am
by jval
Hello,
Where it is possible to download the LightningChart Ultimate version 6.5.5 with TweakDisablePresent and TweakEnabledPresent methods?
Thanks
Re: ViewXY - GetMarginsRectangle
Posted: Mon Nov 30, 2015 1:34 pm
by ahe
Go to
https://www.chartcontrols.com/, click "login", fill out below "Licensed user login" with your credentials, click "SDK", scroll down to "Assemblies", e.g. "v.6.5.5,assemblies,zip"
Hope that helps, Andreas