ViewXY - GetMarginsRectangle

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
ahe
Posts: 51
Joined: Tue Aug 11, 2015 4:33 pm
Location: Düsseldorf, DE

ViewXY - GetMarginsRectangle

Post by ahe » Tue Nov 24, 2015 12:38 pm

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?

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: ViewXY - GetMarginsRectangle

Post by ArctionPasi » Wed Nov 25, 2015 4:50 pm

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 :shock:

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(); 
        }
LightningChart Support Team, PT

ahe
Posts: 51
Joined: Tue Aug 11, 2015 4:33 pm
Location: Düsseldorf, DE

Re: ViewXY - GetMarginsRectangle

Post by ahe » Thu Nov 26, 2015 10:58 am

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?

jval
Posts: 40
Joined: Mon May 04, 2015 1:46 pm

Re: ViewXY - GetMarginsRectangle

Post by jval » Mon Nov 30, 2015 9:03 am

Hello,

Where it is possible to download the LightningChart Ultimate version 6.5.5 with TweakDisablePresent and TweakEnabledPresent methods?

Thanks

ahe
Posts: 51
Joined: Tue Aug 11, 2015 4:33 pm
Location: Düsseldorf, DE

Re: ViewXY - GetMarginsRectangle

Post by ahe » Mon Nov 30, 2015 1:34 pm

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

Post Reply