I don't want to change the y-axis range of a parallel chart by scrolling.

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

kihoon_sung
Posts: 5
Joined: Fri Jul 02, 2021 8:01 am

I don't want to change the y-axis range of a parallel chart by scrolling.

Post by kihoon_sung » Fri Jul 02, 2021 8:12 am

I want to prevent the Y axis from being scrolled and changing the range of the parallel chart. Is there no way?
AxisY axisYWeight = new AxisY(_chart.ViewXY);
axisYWeight.SetRange((double)min, (double)max);
axisYWeight.Title.Text = Prop.ITEM_NM;
axisYWeight.Title.VerticalAlign = YAxisTitleAlignmentVertical.Top;
axisYWeight.Position = _chart.ViewXY.YAxes.Count * positionInterval;

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

Re: I don't want to change the y-axis range of a parallel chart by scrolling.

Post by Arction_LasseP » Fri Jul 02, 2021 9:03 am

Hello,

There are several properties controlling axis scrolling and other actions that modify axis range.

-AllowScrolling - when disabled, user cannot scroll the axis by dragging it with mouse.
-AllowScaling - when disabled, user cannot rescale the axis by dragging the scale nibs at the ends of the axis.
-ZoomingEnabled - determines if zooming actions affect this axis.
-PanningEnabled - determines if panning affects this axis

There is also RangeChanged -event which allows you to define various limits for the axis. For example, prevent axis minimum going below zero. It is also possible to stop all axis range changes inside the event.

Code: Select all

_chart.ViewXY.YAxes[0].AllowScrolling = false;
_chart.ViewXY.YAxes[0].AllowScaling = false;
_chart.ViewXY.YAxes[0].ZoomingEnabled = false;
_chart.ViewXY.YAxes[0].PanningEnabled = false;

_chart.ViewXY.YAxes[0].RangeChanged += YAxis_RangeChanged;

        private void YAxis_RangeChanged(object sender, RangeChangedEventArgs e)
        {
            // Axis range never changes
            if (e.NewMax != 10)
                _chart.ViewXY.YAxes[0].Maximum = 10;
            if (e.NewMin != 0)
                _chart.ViewXY.YAxes[0].Minimum = 0;
        }
Best regards,
Lasse