Space between Chart Title and Axis Title

A forum dedicated to WinForms version of LightningChart Ultimate.

Space between Chart Title and Axis Title

Postby dwilkins314159 » Wed Mar 20, 2019 9:43 pm

New to LightningChart. When I set the chart title to be on the left and rotated 90 degrees, it is either drawn on top of the y-axis title (chart.ViewXY.AxisLayout.AutoAdjustMargins = true;) OR to the left of the y-axis title (chart.ViewXY.AxisLayout.AutoAdjustMargins = false;) but with 0 space between the axis title and the chart title. How can I make sure there is some space between Chart and Axis titles at runtime (i.e. I don't know the layout at compile time)?
dwilkins314159
 
Posts: 3
Joined: Wed Mar 20, 2019 9:35 pm

Re: Space between Chart Title and Axis Title

Postby ArctionKestutis » Thu Mar 21, 2019 9:57 am

Hello and welcome,

It looks like Chart's Title auto alignment with YAxis is not working properly (e.g. as it does with XAxis). This must be an error, which we try to fix as soon as possible.
If you need 'LeftCenter' or 'RightCenter' align for Chart Title, then probably you need to use manual margins. The difference with AutoAdjustMargins disabled due to ViewXY.Margin.Left = 80 (by default), which just a little bit bigger than auto-margin would be. By increasing ViewXY.Margin.Left you will avoid Chart and Axis title overlap. Other options would be place Chart Title in different location or use Offset property.

Hope this helps.
ArctionKestutis
 
Posts: 355
Joined: Mon Mar 14, 2016 9:22 am

Re: Space between Chart Title and Axis Title

Postby dwilkins314159 » Thu Mar 21, 2019 2:16 pm

Thank you for the quick response. For the time being, AutoAdjustMargins=true is just not going work with the left or right titles, but I'm experimenting with manual margins based on the location and font size of the title. I suspect that this will not be a long term solution and look forward to the fix. Unfortunately, I'm required to allow the end-user to place the title and axes on any side, so I'll go forward with manual margins for now.
dwilkins314159
 
Posts: 3
Joined: Wed Mar 20, 2019 9:35 pm

Re: Space between Chart Title and Axis Title

Postby ArctionKestutis » Thu Mar 21, 2019 2:53 pm

After Chart is rendered (e.g. AfterRendering event is raised) you can use following methods, which help estimating margins:
* read Active Axis area (which includes Axis line itself and labels (title is outside of this area))
Code: Select all
var area = Axes.GetActiveAxisArea();

* read location of Axis title
Code: Select all
var rect = Axes.Title.DrawRectangle;

* measure size of rendered text
Code: Select all
_chart.MeasureText(Text, Font); // [please note that Chart.MeasureText(Text, Font) output in DIP units; use DpiHelper.DipToPx() where needed]


Hope this helps.
ArctionKestutis
 
Posts: 355
Joined: Mon Mar 14, 2016 9:22 am

Re: Space between Chart Title and Axis Title

Postby dwilkins314159 » Thu Mar 21, 2019 3:35 pm

Excellent, thank you!
dwilkins314159
 
Posts: 3
Joined: Wed Mar 20, 2019 9:35 pm


Return to LightningChart Ultimate WinForms

Who is online

Users browsing this forum: No registered users and 3 guests