Skip to content

Commit

Permalink
restore tool tip support for annotations
Browse files Browse the repository at this point in the history
* restore the AnnotationTrackController that was removed in efee33c
* but in a way that is compatible with the current ExampleLibrary (without modifications)
  • Loading branch information
janusw committed Nov 28, 2023
1 parent 36c0544 commit e44e2db
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Source/OxyplotMauiSample/Pages/PlotViewPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using ExampleLibrary;
using ExampleLibrary.Utilities;
using OxyPlot.Maui.Skia.Core;
using OxyPlot;

namespace OxyplotMauiSample
{
Expand All @@ -16,6 +18,29 @@ public PlotViewPage()
this.Unloaded += PlotViewPage_Unloaded;
}

private IPlotController CreateAnnotationTrackController()
{
var controller = new OxyPlot.Maui.Skia.PlotController();
controller.UnbindTouchDown();

var snapTrackTouch = new DelegatePlotCommand<OxyTouchEventArgs>((view, c, args) =>
c.AddTouchManipulator(view, new OxyPlot.Maui.Skia.Manipulators.TouchTrackerManipulator(view)
{
Snap = true,
PointsOnly = true,
LockToInitialSeries = false,
IsTrackAnnotations = true
}, args));

var cmd = new CompositeDelegateViewCommand<OxyTouchEventArgs>(
snapTrackTouch,
OxyPlot.Maui.Skia.PlotCommands.PanZoomByTouch
);
controller.BindTouchDown(cmd);

return controller;
}

private void PlotViewPage_Loaded(object sender, EventArgs e)
{
this.Title = ExampleInfo.Category + " - " + ExampleInfo.Title;
Expand All @@ -29,6 +54,11 @@ private void PlotViewPage_Loaded(object sender, EventArgs e)
{
PlotView.Controller = ExampleInfo.PlotController;
}
else if (ExampleInfo.Tags.Contains("Annotations"))
{
// make the annotation tooltip work
PlotView.Controller = CreateAnnotationTrackController();
}
}

private void PlotViewPage_Unloaded(object sender, EventArgs e)
Expand Down

0 comments on commit e44e2db

Please sign in to comment.