When I set automatic Y axis layout to Off, the margins aren't updated automatically anymore.
Is there a workaround for this?
Thanks,
Joost
Manual axis layout and automatic margins?
Moderator: Queue Moderators
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Manual axis layout and automatic margins?
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.
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
Re: Manual axis layout and automatic margins?
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?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.
For me it would be even better if I could use AutoAdjustMargins in combination with YAxisAutoPlacement = Off.
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Manual axis layout and automatic margins?
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.
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