Page 1 of 1

Steema.TeeChart.Tools.NearestPoint Change event doesn't trigger

Posted: Tue Oct 29, 2024 6:59 pm
by 18286055
Steema.TeeChart.Tools.NearestPoint Change event doesn't trigger because the kind parameter is never MouseEventKinds.Move. I clicked and dragged on the chart but it never triggered. Only the down and up events fired.

Code: Select all

    protected internal override void MouseEvent( MouseEventKinds kind, MouseEventArgs e, ref Cursor c)
    {
      if (kind != MouseEventKinds.Move || this._iSeries == null)
        return;
Also please change the Change event signature from

Code: Select all

    public event EventHandler Change;
to

Code: Select all

    public event EventHandler<int> Change;
or

Code: Select all

    public event Action<int> Change;
where the int parameter is the current point index.
Visual Studio 2022 versions.7z
(2.83 KiB) Downloaded 299 times

Re: Steema.TeeChart.Tools.NearestPoint Change event doesn't trigger

Posted: Mon Nov 04, 2024 8:52 am
by Marc
Hello,

Apologies for the delay with this reply, we are investigating and will apply a fix for the next update and are checking if any temporary workaround is possible.

Regards,
Marc Meumann

Re: Steema.TeeChart.Tools.NearestPoint Change event doesn't trigger

Posted: Mon Nov 04, 2024 9:22 am
by Marc
...this has been checked for desktop versions (no problems found) but now notice from other posts you have made, that this issue may be related to Xamarin. Is that correct? ..or MAUI? I see your attached file includes Xamarin installation to the IDE.

With thanks.
Regards,
Marc

Re: Steema.TeeChart.Tools.NearestPoint Change event doesn't trigger

Posted: Tue Nov 05, 2024 3:19 pm
by 18286055
Yes its on MAUI. THe workaround if found was to do the following:

Code: Select all

    protected override void MouseEvent( MouseEventKinds kind, MouseEventArgs e, ref Cursor c )
    {
        if ( _iSeries is null ) { return; }

        Point point = new(e.X, e.Y);
        int   index = GetNearestPoint( point );
        _viewModel.SetCurrentPointIndex( index );
        base.MouseEvent( kind, e, ref c );
    }

Re: Steema.TeeChart.Tools.NearestPoint Change event doesn't trigger

Posted: Wed Nov 13, 2024 9:24 pm
by 18286055
the work around doesn't really work afterall-- it's always at the first point. doesn't change no matter where i click or drag.

Re: Steema.TeeChart.Tools.NearestPoint Change event doesn't trigger

Posted: Thu Nov 14, 2024 10:27 pm
by 18286055
So i found the cause... and it's a few issues from the source code:

Most of it is instead of leaving the value as a double, you are converting it to an int. This is a loss of precision and can greatly affect the developer when trying to figure out which point the end users has pressed. This happens ALOT in the MAUI library and was not the case in Xamarin.Forms. so i consider this a major regression.
  • The when calling DoMouseMove the parameters passed to it are (int) e.TotalX, (int) e.TotalY. After some research and troubleshooting, the TotalX and TotalY are an offset from the start, not the current point, which means that the (x, y) propagated is invalid, and is missing the precision due to the cast to int.

    Code: Select all

        private void PanGestureRecognizer_PanUpdated(object sender, PanUpdatedEventArgs e)
        {
          Cursor c = (Cursor) null;
          MouseEventArgs mouseEventArgs1 = new MouseEventArgs(MouseButtons.Left, 1, (int) e.TotalX, (int) e.TotalY, 0);
          if (e.StatusType == GestureStatus.Completed)
          {
            MouseEventArgs mouseEventArgs2 = new MouseEventArgs(MouseButtons.Left, 1, this.oldTotalX, this.oldTotalY, 0);
          }
          else if (e.StatusType == GestureStatus.Started)
          {
            Microsoft.Maui.Graphics.Point? nullable = new Microsoft.Maui.Graphics.Point?(new Microsoft.Maui.Graphics.Point(this.TranslationX, this.TranslationY));
            Microsoft.Maui.Graphics.Point point = nullable.Value;
            int x = (int) point.X;
            point = nullable.Value;
            int y = (int) point.Y;
            MouseEventArgs mouseEventArgs3 = new MouseEventArgs(MouseButtons.Left, 1, x, y, 0);
          }
          else
          {
            this.oldTotalX = mouseEventArgs1.X;
            this.oldTotalY = mouseEventArgs1.Y;
            this.Chart.DoMouseMove((int) e.TotalX, (int) e.TotalY, ref c);
          }
        }
    
  • When tapped, it works as expected. However i had to add my own TapGestureRecognizer in order for it to work, but I am not missing the precision due to not casting to int.

    Code: Select all

    
        protected virtual void TChart_Tap(object sender, TappedEventArgs e)
        {
          Microsoft.Maui.Graphics.Point? position = e.GetPosition((Element) sender);
          Microsoft.Maui.Graphics.Point point = position.Value;
          int x = (int) point.X;
          point = position.Value;
          int y = (int) point.Y;
          this.Chart.DoMouseDown(false, new MouseEventArgs(MouseButtons.Left, 1, x, y, 0), Keys.None);
        }
    

Re: Steema.TeeChart.Tools.NearestPoint Change event doesn't trigger

Posted: Fri Nov 15, 2024 6:43 am
by Pep
Hello,

many thanks for all your contributions and comments.
We're just working on this area (zoom and panning) in order to improve them, specially on mobile devices. We'll consider all and aill update a new maintenance release that includes this changes.

Thanks again, and if we can be help on something let us know.