Skip to content

Commit e44e2db

Browse files
committed
restore tool tip support for annotations
* restore the AnnotationTrackController that was removed in efee33c * but in a way that is compatible with the current ExampleLibrary (without modifications)
1 parent 36c0544 commit e44e2db

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

Source/OxyplotMauiSample/Pages/PlotViewPage.xaml.cs

+30
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using ExampleLibrary;
22
using ExampleLibrary.Utilities;
3+
using OxyPlot.Maui.Skia.Core;
4+
using OxyPlot;
35

46
namespace OxyplotMauiSample
57
{
@@ -16,6 +18,29 @@ public PlotViewPage()
1618
this.Unloaded += PlotViewPage_Unloaded;
1719
}
1820

21+
private IPlotController CreateAnnotationTrackController()
22+
{
23+
var controller = new OxyPlot.Maui.Skia.PlotController();
24+
controller.UnbindTouchDown();
25+
26+
var snapTrackTouch = new DelegatePlotCommand<OxyTouchEventArgs>((view, c, args) =>
27+
c.AddTouchManipulator(view, new OxyPlot.Maui.Skia.Manipulators.TouchTrackerManipulator(view)
28+
{
29+
Snap = true,
30+
PointsOnly = true,
31+
LockToInitialSeries = false,
32+
IsTrackAnnotations = true
33+
}, args));
34+
35+
var cmd = new CompositeDelegateViewCommand<OxyTouchEventArgs>(
36+
snapTrackTouch,
37+
OxyPlot.Maui.Skia.PlotCommands.PanZoomByTouch
38+
);
39+
controller.BindTouchDown(cmd);
40+
41+
return controller;
42+
}
43+
1944
private void PlotViewPage_Loaded(object sender, EventArgs e)
2045
{
2146
this.Title = ExampleInfo.Category + " - " + ExampleInfo.Title;
@@ -29,6 +54,11 @@ private void PlotViewPage_Loaded(object sender, EventArgs e)
2954
{
3055
PlotView.Controller = ExampleInfo.PlotController;
3156
}
57+
else if (ExampleInfo.Tags.Contains("Annotations"))
58+
{
59+
// make the annotation tooltip work
60+
PlotView.Controller = CreateAnnotationTrackController();
61+
}
3262
}
3363

3464
private void PlotViewPage_Unloaded(object sender, EventArgs e)

0 commit comments

Comments
 (0)