Plots Overlapping with Segmented layout

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
AlexNovikov
Posts: 2
Joined: Wed Jul 17, 2019 8:45 am

Plots Overlapping with Segmented layout

Post by AlexNovikov » Wed Jul 17, 2019 10:17 am

Hi,
In my chart I have used ViewXY.AxisLayout.YAxesLayout = YAxesLayout.Segmented to draw 5 plots like on Capture1.
Capture1.PNG
Capture1.PNG (18.43 KiB) Viewed 5143 times
But when I try to resize chart to a smaller size, it seems like all plots and legends merges into one segment (see Capture2).
Capture2.PNG
Capture2.PNG (6.66 KiB) Viewed 5143 times
But when I draw chart with the same smaller size in YAxesLayout.Stacked, segments just overlap and don't merge
Capture3.PNG
Capture3.PNG (2.34 KiB) Viewed 5143 times
Could you please help me to allow segments to overlap but not to leave only one segment?

Arction_LasseP
Posts: 141
Joined: Wed Mar 27, 2019 1:05 pm

Re: Plots Overlapping with Segmented layout

Post by Arction_LasseP » Thu Jul 18, 2019 8:11 am

Hello,

The segments automatically merge if the chart sees that there isn't enough space to draw them. This behaviour cannot be completely disabled. However there are several properties in AxisLayout, which you can try to control segments and any Y-axis belonging to them.

Code: Select all

_chart.ViewXY.AxisLayout.AutoShrinkSegmentsGap = true;
_chart.ViewXY.AxisLayout.AutoAdjustMargins = false;
_chart.ViewXY.AxisLayout.AutoAdjustAxisGap = 10;
_chart.ViewXY.AxisLayout.SegmentsGap = 1;
_chart.ViewXY.AxisLayout.YAxisTitleAutoPlacement = false;
_chart.ViewXY.AxisLayout.YAxisAutoPlacement = YAxisAutoPlacement.Off;
Of these SegmentsGap seems to have most impact on this issue. With SegmentsGap value 0 or 1, there pretty much is no merging happening. The problem in this case is that the axis values labels (-2 and 2) overlap each other even with larger chart sizes. Therefore it might be a good idea to change SegmentsGap dynamically via an event for instance.

Code: Select all

_chart.SizeChanged += _chart_SizeChanged;

private void _chart_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (_chart.ViewXY.AxisLayout.SegmentsGap == 10 && e.NewSize.Height < 200)
            {
                _chart.ViewXY.AxisLayout.SegmentsGap = 1;
            }
            else if (_chart.ViewXY.AxisLayout.SegmentsGap == 1 && e.NewSize.Height > 200)
            {
                _chart.ViewXY.AxisLayout.SegmentsGap = 10;
            }
        }
In the example above, SegmentsGap is modified every time the height of the chart goes above or below 200.

Hope this is helpful.
Best regards,
Lasse

AlexNovikov
Posts: 2
Joined: Wed Jul 17, 2019 8:45 am

Re: Plots Overlapping with Segmented layout

Post by AlexNovikov » Thu Jul 18, 2019 11:52 am

Thank you so much, your suggestion helped me well.

Post Reply