Touches on oxyplot linesseries don't work

900 views Asked by At

I'm using oxyplot in my ios project to plot some graphs. I need to handle touches on the graph to add notes on it. I'm using the touch events but it's not working. Actually it works sometimes and other times it doesn't. It was working at the beginning and now it's not anymore. Does anyone know what the bug might be.

Here is the code

myLineChart.series1.TouchStarted += (sender, e) =>
        {
            myLineChart.xCoordinate = e.Position.X;
            myLineChart.yCoordinate = e.Position.Y;
            if(myLineChart.series1.Points != null){
                timer = new System.Timers.Timer ();
                timer.Interval = 400;
                timer.Elapsed += (senderr, er) => {
                    InvokeOnMainThread ( () => {
                        dialog = new DialogView(View,Language.AddNoteLabel,Language.NotesQuestionLabel,Language.YesButton,Language.NoButton); 
                        dialog.Show(); 

                        dialog.firstButton.TouchUpInside += (sender1, e1) => CreateNote ();

                        dialog.secondButton.TouchUpInside += (sender1, e1) => dialog.Dispose ();
                    });
                    timer.Dispose();
                };
                timer.Enabled = true;
            }
            e.Handled = true;
        };
1

There are 1 answers

0
CT CHANG On

You may consider handle the OxyPlot.Model.TouchCompleted event.

private void HookEvents()
{
    this.UnhookEvents();

    if (this.plot != null && this.plot.Model != null)
    {
        this.plot.Model.TouchCompleted += this.PlotModelTouchCompletedHandler;
    }
}

private void UnhookEvents()
{
    if (this.plot != null && this.plot.Model != null)
    {
        this.plot.Model.TouchCompleted -= this.PlotModelTouchCompletedHandler;
    }
}

private void PlotModelTouchCompletedHandler (object sender, OxyTouchEventArgs e)
{
    // Put your logic to add custom node here.
}