Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
255
Moving series data point with mouse
posted

Hi All,

Hope someone can help me. I've got a XamDataChart with multiple scatter line series lines. I want to select a certain datapoint on a series and move that point to the users selected position on the chart with my mouse. Is this possible?

Ive got this code so far to give me my mouse position when the user clicks(Mouse down event):

var x = Chart.Axes.OfType<NumericXAxis>().First();
var y = Chart.Axes.OfType<NumericYAxis>().First();
var viewport = new Rect(0, 0, x.ActualWidth, y.ActualHeight);
var window = gearShiftProfileChart.WindowRect;

var position = e.GetPosition(Chart);

var unscaledX = x.GetUnscaledValue(position.X, window, viewport);
var unscaledY = y.GetUnscaledValue(position.Y, window, viewport);

System.Windows.MessageBox.Show("x: " + unscaledX + ", y:" + unscaledY);

Friendly regards

Roelof

Parents Reply
  • 29105
    Verified Answer
    Offline posted in reply to Roelof

    Hello Roelof,

    The necessary change must be done to the NotifyPropertyChanged method. Simply passing in a string will work for the properties.

    For more details please visit msdn:
    https://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.100).aspx

    eg.

     public class Widget : INotifyPropertyChanged
        {
            private double _ValueX;
            public double ValueX
            {
                get { return this._ValueX; }
                set
                {
                    bool changed = this.ValueX != value;
                    if (changed)
                    {
                        this._ValueX = value;
                        NotifyPropertyChanged("ValueX");
                    }
                }
            }
            private double _ValueY;
            public double ValueY
            {
                get { return this._ValueY; }
                set
                {
                    bool changed = this.ValueY != value;
                    if (changed)
                    {
                        this._ValueY = value;
                        NotifyPropertyChanged("ValueY");
                    }
                }
            }
            public event PropertyChangedEventHandler PropertyChanged;

            private void NotifyPropertyChanged(String info)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(info));
                }
            }

Children