Space between Chart Title and Axis Title

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
dwilkins314159
Posts: 4
Joined: Wed Mar 20, 2019 9:35 pm

Space between Chart Title and Axis Title

Post by 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)?

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: Space between Chart Title and Axis Title

Post by 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.

dwilkins314159
Posts: 4
Joined: Wed Mar 20, 2019 9:35 pm

Re: Space between Chart Title and Axis Title

Post by 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.

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: Space between Chart Title and Axis Title

Post by 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.

dwilkins314159
Posts: 4
Joined: Wed Mar 20, 2019 9:35 pm

Re: Space between Chart Title and Axis Title

Post by dwilkins314159 » Thu Mar 21, 2019 3:35 pm

Excellent, thank you!

ArctionKestutis
Posts: 552
Joined: Mon Mar 14, 2016 9:22 am

Re: Space between Chart Title and Axis Title

Post by ArctionKestutis » Wed Jun 05, 2019 12:39 pm

The issue was fixed in the latest (v8.4.2.4001) LightningChart release.
All the best.

dwilkins314159
Posts: 4
Joined: Wed Mar 20, 2019 9:35 pm

Re: Space between Chart Title and Axis Title

Post by dwilkins314159 » Thu Jun 20, 2019 9:40 pm

Thanks very much, it is much better. There is one thing I should make you aware of, however.

With AutoAdjustMargins = true (which Is what we really like), the extra space between the margin and the text (let's call it schmutz) is presentable in most cases. In some cases the schmutz is 0 and there is no room between the outer most text and the border. For instance, using the DemoAppWinForms | Basics | Point line sample:

With
_chart.Title.Align = ChartTitleAlignment.RightCenter;
_chart.Title.Angle = 90;

the schmutz is goo and the title looks nice. But with
_chart.Title.Angle = -90;

the schmutz is 0 and the title looks not so good (up against the border).

We are completely ok with not using -90, so no problem. Just thought you'd like to know. Also, you set of example apps and having source code we can play with is outstanding! Excellent.

Post Reply