How to remove OXYPLOT tooltip after clicking ?
Steps to reproduce
plotmodel.MouseUp+= (s, e) =>
{
// some database actions here
pM.InvalidatePlot(false);
e.Handled = true;
};
Platform: .NET version: Visual Studio 2022, Framework 4.7.2
Expected behaviour
I want the datatooltip which shows after clicking to go away or not to show at all....
Actual behaviour
The tooltip stays on the plot.
Feature description
Write a description of the feature. How should it work? How should it look? Include some graphics if this could help!
It should disappear when you release the mouse, so that sounds like a bug: which platform is this? Feels like WinForms or GTK
No, ignore that: if you don't mark the mouse event as handled then it should be fine: note that the DB work will be done on the UI thread which may or may not be desirable.
Alternatively, you can force-close it by calling HideTracker on the PlotView
Thank you.
Maybe it could be happening because I use a separate controller for the mouse down click.
public class DoSomethingWithPointTrackerManipulator : OxyPlot.TrackerManipulator
{
public string Heat;
public DoSomethingWithPointTrackerManipulator(IPlotView plotView) : base(plotView)
{
Snap = true;
PointsOnly = true;
}
public override void Started(OxyMouseEventArgs e)
{
base.Started(e);
DoSomethingWithPoint(e);
}
private void DoSomethingWithPoint(OxyMouseEventArgs e)
{
if (!(PlotView.ActualModel.GetSeriesFromPoint(e.Position) is LineSeries series)) return;
var nearestPoint = series.GetNearestPoint(e.Position, false); // Possible set interpolate parameter to true.
if (nearestPoint == null) return;
var dataPoint = nearestPoint.DataPoint;
//var scatterPoint = series.Points.FirstOrDefault(x => Equals(x.X, dataPoint.X) && Equals(x.Y, dataPoint.Y));
// Do whatever you want with the point.
Heat = dataPoint.ToString();
//PlotView.InvalidatePlot(false);
}
public override void Completed(OxyMouseEventArgs e)
{
// Do nothing to avoid closing the tracker.
}
}
and in my C# code of the main form
const OxyMouseButton mouseButton = OxyMouseButton.Left; // Or whatever button you want the event to be fired with.
var pointtracker = new DoSomethingWithPointTrackerManipulator(plotGrafieken); var delegatePlot = new DelegatePlotCommand<OxyMouseDownEventArgs>((view, controller, args) => controller.AddMouseManipulator(view, pointtracker, args)); myController.BindMouseDown(mouseButton, delegatePlot);
myController.UnbindMouseEnter(); myController.UnbindMouseWheel();
Thanks, HideTracker was a great help !