Page 1 of 1

y-axis scroll mouse drag movement failure.

Posted: Thu Apr 09, 2020 11:22 am
by hkhm16
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.

Re: y-axis scroll mouse drag movement failure.

Posted: Tue Apr 14, 2020 3:48 pm
by ArctionKestutis
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.