y-axis scroll mouse drag movement failure.

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
hkhm16
Posts: 1
Joined: Mon Mar 16, 2020 4:47 am

y-axis scroll mouse drag movement failure.

Post by hkhm16 » Thu Apr 09, 2020 11:22 am

I do not work normally when I move to the y-axis scroll mouse drag.

The value below is suspected. (In the example, the Rangechange function of scroll provided was modified. )

m_chart.VerticalScrollBars[0].Value = ???

Can you explain the rules?

I implemented as follows.


private void AxisYRangeChanged(object sender, RangeChangedEventArgs e)
{
if (e.NewMin < yMin)
{
double newRange = e.NewMax - e.NewMin;
if ((newRange + yMin) <= yMax)
m_chart.ViewXY.YAxes[0].SetRange(yMin, yMin + newRange);
}
else
{
m_chart.ViewXY.YAxes[0].SetRange(yMin, yMax);
}
}
else if (e.NewMax > m_yMax)
{
double newRange = e.NewMax - e.NewMin;
if (newRange <= m_yMax)
{
m_chart.ViewXY.YAxes[0].SetRange(yMax - newRange, yMax);

else
{
m_chart.ViewXY.YAxes[0].SetRange(m_yMin, m_yMax);
}
}
else
{
double newRange = e.NewMax - e.NewMin;

m_chart.BeginUpdate();

m_chart.VerticalScrollBars[0].LargeChange = (ulong)(newRange);
m_chart.VerticalScrollBars[0].Value = (ulong) (m_yMax - e.NewMax ); // ????

m_chart.EndUpdate();

m_сurrentYRange = (ulong)(newRange);
}
}

setrange in another way and scroll ratio and position move normally.
But I scroll mouse drag and it works strangely.

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

Re: y-axis scroll mouse drag movement failure.

Post by ArctionKestutis » Tue Apr 14, 2020 3:48 pm

Hi,

ScrollBars.Value defines position of scrollbar-thumb. It should be between ScrollBars.Minimum and ScrollBars.Maximum. Relative position is calculated by ratio of those properties.

Usaully on the Chart we want ScrollBars and AxisRange being synchronized. Therefore, LightningChart uses event handlers to achieve that: ScrollBar.Scroll and Axis.RangeChanged.

You have been looking at YAxis.RangeChanged event handler. The question marks is where we use new Axis.Maximum to set new relative position of ScrollBar,

Hope this helps.

Post Reply