Manual axis layout and automatic margins?

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Arction_LasseP

jrvdboom
Posts: 61
Joined: Thu Apr 10, 2014 1:50 pm

Manual axis layout and automatic margins?

Post by jrvdboom » Mon Apr 20, 2015 11:24 am

When I set automatic Y axis layout to Off, the margins aren't updated automatically anymore.
Is there a workaround for this?

Thanks,
Joost

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

Re: Manual axis layout and automatic margins?

Post by ArctionPasi » Tue Apr 21, 2015 8:17 am

Can you be more specific?

If ViewXY.AxisLayout.AutoAdjustMargins is enabled, it uses automatic margins set by axes. By disabling AutoAdjustMargins, ViewXY.Margins property applies, and ViewXY.AxisLayout.YAxisAutoPlacement repositions the axes but don't change the margins.

If AutoAdjustMargins is enabled, YAxisAutoPlacement adjusts the margins. By setting YAxisAutoPlacement = AllLeft, AllRight, LeftThenRight, RightThenLeft, it adjusts the margins based on the axis labels, ticks and titles. When setting YAxisAutoPlacement = Off, ViewXY.Margins.Left and Right applies.

That is the designed functionality and by testing it seems to work correctly.
LightningChart Support Team, PT

jrvdboom
Posts: 61
Joined: Thu Apr 10, 2014 1:50 pm

Re: Manual axis layout and automatic margins?

Post by jrvdboom » Tue Apr 21, 2015 8:46 am

ArctionPasi wrote: If AutoAdjustMargins is enabled, YAxisAutoPlacement adjusts the margins. By setting YAxisAutoPlacement = AllLeft, AllRight, LeftThenRight, RightThenLeft, it adjusts the margins based on the axis labels, ticks and titles. When setting YAxisAutoPlacement = Off, ViewXY.Margins.Left and Right applies.

That is the designed functionality and by testing it seems to work correctly.
That's exactly what I do, but the margins needed when YAxisAutoPlacement = Off are not known. If I have a Y axis at position 0 (or 100), the required margin to make it look good depends on the tick-labels of the axis as well as the axis title. Is there a way to determine the total width of the axis so that I can use that as input for the margins?

For me it would be even better if I could use AutoAdjustMargins in combination with YAxisAutoPlacement = Off.

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

Re: Manual axis layout and automatic margins?

Post by ArctionPasi » Tue Apr 21, 2015 3:57 pm

It'll need manual calculation of axis space. Approx. like this:

yAxis.AxisThickness + yAxis.MajorDivTickStyle.LineLenght + yAxis.LabelTicksGap + chart.MeasureText(yAxis.Maximum.ToString(), yAxis.LabelFont).X+ yAxis.Title.DistanceToAxis + chart.MeasureText(yAxis.Title.Text).Y / 2.

I didn't try but should be pretty near.

Disable chart.ViewXY.AxisLayout.YAxisTitleAutoPlacement otherwise the title calculation doesn't match.
LightningChart Support Team, PT