{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "chart-annotationzooming",
  "framework": "maui",
  "type": "registry:component",
  "component": "Chart",
  "variant": "annotationzooming",
  "dependencies": [
    "Syncfusion.Maui.Charts"
  ],
  "description": "Interactive cartesian chart with selection zooming and draggable geometric annotations.",
  "meta": {
    "essentialStudioRelease": "2026 Volume 3 (v35.1.37)",
    "license": "commercial-or-community",
    "licenseNote": "The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md",
    "requiresLicenseKey": true,
    "requiresServerEndpoint": false,
    "platformIndex": "https://ai.syncfusion.com/maui/llms.txt",
    "skillPack": "syncfusion/maui-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/maui/chart-annotationzooming.md"
  },
  "files": [
    {
      "target": "src/components/chart-annotationzooming/Chart.xaml",
      "content": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n<ContentPage xmlns=\"http://schemas.microsoft.com/dotnet/2021/maui\"\n             xmlns:x=\"http://schemas.microsoft.com/winfx/2009/xaml\"\n             xmlns:model=\"clr-namespace:MAUI.Controls.Chart.AnnotationZooming\"\n             xmlns:chart=\"clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts\"\n             x:Class=\"MAUI.Controls.Chart.AnnotationZooming.AnnotationZoomingView\"\n             xmlns:annotation=\"clr-namespace:MAUI.Controls.Chart.AnnotationZooming\">\n\n\n    <chart:SfCartesianChart VerticalOptions=\"Fill\" Margin=\"0,0,5,0\" x:Name=\"Chart\" AnnotationTapped=\"Chart_AnnotationTapped\">\n\n        <chart:SfCartesianChart.ZoomPanBehavior>\n            <chart:ChartZoomPanBehavior EnableSelectionZooming=\"True\"\n                                            EnablePinchZooming=\"False\"/>\n        </chart:SfCartesianChart.ZoomPanBehavior>\n\n        <chart:SfCartesianChart.XAxes>\n            <chart:NumericalAxis Minimum=\"0\" Maximum=\"4\">\n            </chart:NumericalAxis>\n        </chart:SfCartesianChart.XAxes>\n\n        <chart:SfCartesianChart.YAxes>\n            <chart:NumericalAxis Minimum=\"20\" Maximum=\"70\" Interval=\"10\"></chart:NumericalAxis>\n        </chart:SfCartesianChart.YAxes>\n\n        <chart:SfCartesianChart.Annotations>\n\n            <annotation:DraggableVerticalLineAnnotation x:Name=\"verticalLine\" X1=\"2\" LineCap=\"Arrow\" Text=\"Vertical Line\">\n            </annotation:DraggableVerticalLineAnnotation>\n\n            <annotation:DraggableHorizontalLineAnnotation x:Name=\"horizontalLine\" Y1=\"45\" LineCap=\"Arrow\" Text=\"Horizontal Line\">\n            </annotation:DraggableHorizontalLineAnnotation>\n\n            <annotation:DraggableLineAnnotation x:Name=\"lineAnnotation\" X1=\"2.5\" X2=\"3.5\" Y1=\"52\" Y2=\"63\" LineCap=\"Arrow\" Text=\"Line\">\n            </annotation:DraggableLineAnnotation>\n\n            <annotation:DraggableRectangleAnnotation x:Name=\"rectangleAnnotation\" X1=\"0.5\" X2=\"1.5\" Y1=\"25\" Y2=\"35\" Text=\"Rectangle\">\n            </annotation:DraggableRectangleAnnotation>\n\n            <annotation:DraggableEllipseAnnotation x:Name=\"ellipseAnnotation\" X1=\"2.5\" X2=\"3.5\" Y1=\"25\" Y2=\"35\" Text=\"Ellipse\" HorizontalAlignment=\"End\" VerticalAlignment=\"End\">\n            </annotation:DraggableEllipseAnnotation>\n\n            <annotation:DraggableTextAnnotation x:Name=\"textAnnotation\" X1=\"1\" Y1=\"57.5\" Text=\"Text Annotation\">\n            </annotation:DraggableTextAnnotation>\n\n        </chart:SfCartesianChart.Annotations>\n    </chart:SfCartesianChart>\n\n</ContentPage>"
    },
    {
      "target": "src/components/chart-annotationzooming/Chart.xaml.cs",
      "content": "﻿using Syncfusion.Maui.Charts;\n\nnamespace MAUI.Controls.Chart.AnnotationZooming\n{\n    public partial class AnnotationZoomingView : ContentPage\n    {\n        private ChartAnnotation? _selectedAnnotation;\n        private Color _selectedColor = Colors.Blue;\n        private readonly Dictionary<ChartAnnotation, Color> _annotationColors = new();\n\n        public AnnotationZoomingView()\n        {\n            InitializeComponent();\n            verticalLine.Attach(Chart);\n            horizontalLine.Attach(Chart);\n            lineAnnotation.Attach(Chart);\n            rectangleAnnotation.Attach(Chart);\n            ellipseAnnotation.Attach(Chart);\n            textAnnotation.Attach(Chart);\n            verticalLine.SetDragEnabled(true);\n            horizontalLine.SetDragEnabled(true);\n            lineAnnotation.SetDragEnabled(true);\n            rectangleAnnotation.SetDragEnabled(true);\n            ellipseAnnotation.SetDragEnabled(true);\n            textAnnotation.SetDragEnabled(true);\n        }\n\n        private void Chart_AnnotationTapped(object? sender, AnnotationTappedEventArgs e)\n        {\n\n            var annotation = e.Annotation;\n            if (annotation is null)\n                return;\n\n            _selectedAnnotation = annotation;\n\n\n            // Restore the last color used for this annotation after the UI is ready\n            ResetColorSelectionIndicators();\n            if (_annotationColors.TryGetValue(annotation, out var storedColor))\n            {\n                _selectedColor = storedColor;\n                Dispatcher.Dispatch(() => HighlightStoredColor(storedColor));\n            }\n            else\n            {\n                // No prior color — clear any leftover selection\n                _selectedColor = Colors.Blue;\n            }\n        }\n\n        private void ApplyColorToAnnotation()\n        {\n            if (_selectedAnnotation == null)\n            {\n                return;\n            }\n\n            Color color = _selectedColor;\n            SolidColorBrush brush = new(color);\n            if (_selectedAnnotation is DraggableLineAnnotation lineAnn)\n            {\n                lineAnn.Stroke = brush;\n            }\n            else if (_selectedAnnotation is DraggableHorizontalLineAnnotation hLineAnn)\n            {\n                hLineAnn.Stroke = brush;\n            }\n            else if (_selectedAnnotation is DraggableVerticalLineAnnotation vLineAnn)\n            {\n                vLineAnn.Stroke = brush;\n            }\n            else if (_selectedAnnotation is DraggableRectangleAnnotation rectAnn)\n            {\n                rectAnn.Fill = brush;\n            }\n            else if (_selectedAnnotation is DraggableEllipseAnnotation ellipseAnn)\n            {\n                ellipseAnn.Fill = brush;\n            }\n            else if (_selectedAnnotation is DraggableTextAnnotation textAnn)\n            {\n                textAnn.LabelStyle = new ChartAnnotationLabelStyle\n                {\n                    TextColor = color\n                };\n            }\n        }\n\n        private void HighlightStoredColor(Color color)\n        {\n            var paletteGrid = this.FindByName(\"ColorPaletteGrid\") as Grid;\n            if (paletteGrid == null) return;\n\n            foreach (var child in paletteGrid.Children)\n            {\n                if (child is Border border && border.Content is BoxView boxView)\n                {\n                    if (boxView.Color.ToString() == color.ToString())\n                    {\n                        border.Stroke = Colors.Black;\n                        border.StrokeThickness = 2;\n                        break;\n                    }\n                }\n            }\n        }\n\n        private void ResetColorSelectionIndicators()\n        {\n            var paletteGrid = this.FindByName(\"ColorPaletteGrid\") as Grid;\n            if (paletteGrid != null)\n            {\n                foreach (var child in paletteGrid.Children)\n                {\n                    if (child is Border border)\n                    {\n                        border.Stroke = Colors.Transparent;\n                        border.StrokeThickness = 2;\n                    }\n                }\n            }\n        }\n    }\n\n    /// <summary>\n    /// Helper struct to store plot area bounds in axis values.\n    /// </summary>\n    internal struct PlotAreaBounds\n    {\n        public double Left { get; set; }\n        public double Right { get; set; }\n        public double Top { get; set; }\n        public double Bottom { get; set; }\n    }\n\n    /// <summary>\n    /// Helper class for draggable annotation utilities.\n    /// </summary>\n    internal static class DraggableAnnotationHelper\n    {\n        /// <summary>\n        /// Calculates plot area bounds in axis values.\n        /// </summary>\n        public static PlotAreaBounds GetPlotAreaBounds(Syncfusion.Maui.Charts.SfCartesianChart chart, ChartAxis xAxis, RangeAxisBase yAxis)\n        {\n            return new PlotAreaBounds\n            {\n                Left = chart.PointToValue(xAxis, (float)chart.SeriesBounds.Left, (float)chart.SeriesBounds.Top),\n                Right = chart.PointToValue(xAxis, (float)chart.SeriesBounds.Right, (float)chart.SeriesBounds.Top),\n                Top = chart.PointToValue(yAxis, (float)chart.SeriesBounds.Left, (float)chart.SeriesBounds.Top),\n                Bottom = chart.PointToValue(yAxis, (float)chart.SeriesBounds.Left, (float)chart.SeriesBounds.Bottom)\n            };\n        }\n\n        /// <summary>\n        /// Clamps annotation coordinates to plot area bounds.\n        /// </summary>\n        public static void ClampCoordinatesToBounds(ref double x1, ref double x2, ref double y1, ref double y2, PlotAreaBounds bounds)\n        {\n            // Clamp X positions\n            if (x1 < bounds.Left)\n            {\n                var offset = bounds.Left - x1;\n                x1 = bounds.Left;\n                x2 += offset;\n            }\n            if (x2 > bounds.Right)\n            {\n                var offset = x2 - bounds.Right;\n                x2 = bounds.Right;\n                x1 -= offset;\n            }\n\n            // Clamp Y positions\n            if (y1 < bounds.Bottom)\n            {\n                var offset = bounds.Bottom - y1;\n                y1 = bounds.Bottom;\n                y2 += offset;\n            }\n            if (y2 > bounds.Top)\n            {\n                var offset = y2 - bounds.Top;\n                y2 = bounds.Top;\n                y1 -= offset;\n            }\n        }\n\n        /// <summary>\n        /// Converts object value to double, handling multiple numeric types.\n        /// </summary>\n        public static double ToNumeric(object? value)\n        {\n            return value switch\n            {\n                double d => d,\n                float f => f,\n                int i => i,\n                long l => l,\n                string s => double.TryParse(s, out var result) ? result : 0d,\n                _ => 0d\n            };\n        }\n\n        /// <summary>\n        /// Clamps a value between visible min and max with an extend buffer.\n        /// </summary>\n        public static double ClampToVisibleRange(double value, double visibleMin, double visibleMax, double extend)\n        {\n            if (value <= visibleMin)\n                return visibleMin + extend;\n            if (value >= visibleMax)\n                return visibleMax - extend;\n            return value;\n        }\n    }\n\n    public sealed class DraggableLineAnnotation : LineAnnotation\n    {\n        private Syncfusion.Maui.Charts.SfCartesianChart? _chart;\n        private ChartAxis? _xAxis;\n        private RangeAxisBase? _yAxis;\n        private bool _isDragging;\n        private double _previousAxisX;\n        private double _previousAxisY;\n        private bool _isDragEnabled = false;\n\n        public void SetDragEnabled(bool enabled)\n        {\n            _isDragEnabled = enabled;\n        }\n\n        public void Attach(Syncfusion.Maui.Charts.SfCartesianChart chart)\n        {\n            _chart = chart;\n            _xAxis = chart.XAxes.Count > 0 ? chart.XAxes[0] : null;\n            _yAxis = chart.YAxes.Count > 0 ? chart.YAxes[0] : null;\n        }\n\n        protected override void OnTouchDown(float pointX, float pointY)\n        {\n            if (_chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var axisX = _chart.PointToValue(_xAxis, pointX, pointY);\n            var axisY = _chart.PointToValue(_yAxis, pointX, pointY);\n\n            if (double.IsNaN(axisX) || double.IsInfinity(axisX) ||\n                double.IsNaN(axisY) || double.IsInfinity(axisY))\n            {\n                return;\n            }\n\n            _previousAxisX = axisX;\n            _previousAxisY = axisY;\n            _isDragging = _isDragEnabled;\n        }\n\n        protected override void OnTouchMove(float pointX, float pointY)\n        {\n            if (!_isDragging || _chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var axisX = _chart.PointToValue(_xAxis, pointX, pointY);\n            var axisY = _chart.PointToValue(_yAxis, pointX, pointY);\n\n            if (double.IsNaN(axisX) || double.IsInfinity(axisX) ||\n                double.IsNaN(axisY) || double.IsInfinity(axisY))\n            {\n                return;\n            }\n\n            var deltaX = axisX - _previousAxisX;\n            var deltaY = axisY - _previousAxisY;\n\n            ApplyDelta(deltaX, deltaY);\n            _previousAxisX = axisX;\n            _previousAxisY = axisY;\n        }\n\n        protected override void OnTouchUp(float pointX, float pointY)\n        {\n            _isDragging = false;\n        }\n\n        private void ApplyDelta(double deltaX, double deltaY)\n        {\n            if (_chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var newX1 = DraggableAnnotationHelper.ToNumeric(X1) + deltaX;\n            var newX2 = DraggableAnnotationHelper.ToNumeric(X2) + deltaX;\n            var newY1 = Y1 + deltaY;\n            var newY2 = Y2 + deltaY;\n\n            var bounds = DraggableAnnotationHelper.GetPlotAreaBounds(_chart, _xAxis, _yAxis);\n            DraggableAnnotationHelper.ClampCoordinatesToBounds(ref newX1, ref newX2, ref newY1, ref newY2, bounds);\n\n            X1 = newX1;\n            X2 = newX2;\n            Y1 = newY1;\n            Y2 = newY2;\n        }\n    }\n\n    public sealed class DraggableVerticalLineAnnotation : VerticalLineAnnotation\n    {\n        private Syncfusion.Maui.Charts.SfCartesianChart? _chart;\n        private ChartAxis? _xAxis;\n        private bool _isDragging;\n        private bool _isDragEnabled = false;\n\n        public void SetDragEnabled(bool enabled)\n        {\n            _isDragEnabled = enabled;\n        }\n\n        public void Attach(Syncfusion.Maui.Charts.SfCartesianChart chart)\n        {\n            _chart = chart;\n            _xAxis = chart.XAxes.Count > 0 ? chart.XAxes[0] : null;\n        }\n\n        protected override void OnTouchDown(float pointX, float pointY)\n        {\n            if (_chart is null || _xAxis is null)\n            {\n                return;\n            }\n\n            var linePixel = _xAxis.ValueToPoint(Convert.ToDouble(X1));\n            if (double.IsNaN(linePixel))\n            {\n                return;\n            }\n\n            _isDragging = _isDragEnabled;\n        }\n\n        protected override void OnTouchMove(float pointX, float pointY)\n        {\n            if (!_isDragging || _chart is null || _xAxis is null)\n            {\n                return;\n            }\n\n            var newValue = _chart.PointToValue(_xAxis, pointX, pointY);\n            if (double.IsNaN(newValue) || double.IsInfinity(newValue))\n            {\n                return;\n            }\n\n            X1 = DraggableAnnotationHelper.ClampToVisibleRange(newValue, _xAxis.VisibleMinimum, _xAxis.VisibleMaximum, 0.1);\n        }\n\n        protected override void OnTouchUp(float pointX, float pointY)\n        {\n            _isDragging = false;\n        }\n    }\n\n    public sealed class DraggableHorizontalLineAnnotation : HorizontalLineAnnotation\n    {\n        private Syncfusion.Maui.Charts.SfCartesianChart? _chart;\n        private RangeAxisBase? _yAxis;\n        private bool _isDragging;\n        private bool _isDragEnabled = false;\n\n        public void SetDragEnabled(bool enabled)\n        {\n            _isDragEnabled = enabled;\n        }\n\n        public void Attach(Syncfusion.Maui.Charts.SfCartesianChart chart)\n        {\n            _chart = chart;\n            _yAxis = chart.YAxes.Count > 0 ? chart.YAxes[0] : null;\n        }\n\n        protected override void OnTouchDown(float pointX, float pointY)\n        {\n            if (_chart is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var linePixel = _yAxis.ValueToPoint(Y1);\n            if (double.IsNaN(linePixel))\n            {\n                return;\n            }\n\n            _isDragging = _isDragEnabled;\n        }\n\n        protected override void OnTouchMove(float pointX, float pointY)\n        {\n            if (!_isDragging || _chart is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var newValue = _chart.PointToValue(_yAxis, pointX, pointY);\n            if (double.IsNaN(newValue) || double.IsInfinity(newValue))\n            {\n                return;\n            }\n\n            Y1 = DraggableAnnotationHelper.ClampToVisibleRange(newValue, _yAxis.VisibleMinimum, _yAxis.VisibleMaximum, 2);\n        }\n\n        protected override void OnTouchUp(float pointX, float pointY)\n        {\n            _isDragging = false;\n        }\n    }\n\n    public sealed class DraggableRectangleAnnotation : RectangleAnnotation\n    {\n        private Syncfusion.Maui.Charts.SfCartesianChart? _chart;\n        private ChartAxis? _xAxis;\n        private RangeAxisBase? _yAxis;\n        private bool _isDragging;\n        private double _previousAxisX;\n        private double _previousAxisY;\n        private bool _isDragEnabled = false;\n\n        public void SetDragEnabled(bool enabled)\n        {\n            _isDragEnabled = enabled;\n        }\n\n        public void Attach(Syncfusion.Maui.Charts.SfCartesianChart chart)\n        {\n            _chart = chart;\n            _xAxis = chart.XAxes.Count > 0 ? chart.XAxes[0] : null;\n            _yAxis = chart.YAxes.Count > 0 ? chart.YAxes[0] : null;\n        }\n\n        protected override void OnTouchDown(float pointX, float pointY)\n        {\n            if (_chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var axisX = _chart.PointToValue(_xAxis, pointX, pointY);\n            var axisY = _chart.PointToValue(_yAxis, pointX, pointY);\n\n            if (double.IsNaN(axisX) || double.IsInfinity(axisX) ||\n                double.IsNaN(axisY) || double.IsInfinity(axisY))\n            {\n                return;\n            }\n\n            _previousAxisX = axisX;\n            _previousAxisY = axisY;\n            _isDragging = _isDragEnabled;\n        }\n\n        protected override void OnTouchMove(float pointX, float pointY)\n        {\n            if (!_isDragging || _chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var axisX = _chart.PointToValue(_xAxis, pointX, pointY);\n            var axisY = _chart.PointToValue(_yAxis, pointX, pointY);\n\n            if (double.IsNaN(axisX) || double.IsInfinity(axisX) ||\n                double.IsNaN(axisY) || double.IsInfinity(axisY))\n            {\n                return;\n            }\n\n            var deltaX = axisX - _previousAxisX;\n            var deltaY = axisY - _previousAxisY;\n\n            ApplyDelta(deltaX, deltaY);\n            _previousAxisX = axisX;\n            _previousAxisY = axisY;\n        }\n\n        protected override void OnTouchUp(float pointX, float pointY)\n        {\n            _isDragging = false;\n        }\n\n        private void ApplyDelta(double deltaX, double deltaY)\n        {\n            if (_chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var newX1 = DraggableAnnotationHelper.ToNumeric(X1) + deltaX;\n            var newX2 = DraggableAnnotationHelper.ToNumeric(X2) + deltaX;\n            var newY1 = Y1 + deltaY;\n            var newY2 = Y2 + deltaY;\n\n            var bounds = DraggableAnnotationHelper.GetPlotAreaBounds(_chart, _xAxis, _yAxis);\n            DraggableAnnotationHelper.ClampCoordinatesToBounds(ref newX1, ref newX2, ref newY1, ref newY2, bounds);\n\n            X1 = newX1;\n            X2 = newX2;\n            Y1 = newY1;\n            Y2 = newY2;\n        }\n    }\n\n    public sealed class DraggableEllipseAnnotation : EllipseAnnotation\n    {\n        private Syncfusion.Maui.Charts.SfCartesianChart? _chart;\n        private ChartAxis? _xAxis;\n        private RangeAxisBase? _yAxis;\n        private bool _isDragging;\n        private double _previousAxisX;\n        private double _previousAxisY;\n        private bool _isDragEnabled = false;\n\n        public void SetDragEnabled(bool enabled)\n        {\n            _isDragEnabled = enabled;\n        }\n\n        public void Attach(Syncfusion.Maui.Charts.SfCartesianChart chart)\n        {\n            _chart = chart;\n            _xAxis = chart.XAxes.Count > 0 ? chart.XAxes[0] : null;\n            _yAxis = chart.YAxes.Count > 0 ? chart.YAxes[0] : null;\n        }\n\n        protected override void OnTouchDown(float pointX, float pointY)\n        {\n            if (_chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var axisX = _chart.PointToValue(_xAxis, pointX, pointY);\n            var axisY = _chart.PointToValue(_yAxis, pointX, pointY);\n\n            if (double.IsNaN(axisX) || double.IsInfinity(axisX) ||\n                double.IsNaN(axisY) || double.IsInfinity(axisY))\n            {\n                return;\n            }\n\n            _previousAxisX = axisX;\n            _previousAxisY = axisY;\n            _isDragging = _isDragEnabled;\n        }\n\n        protected override void OnTouchMove(float pointX, float pointY)\n        {\n            if (!_isDragging || _chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var axisX = _chart.PointToValue(_xAxis, pointX, pointY);\n            var axisY = _chart.PointToValue(_yAxis, pointX, pointY);\n\n            if (double.IsNaN(axisX) || double.IsInfinity(axisX) ||\n                double.IsNaN(axisY) || double.IsInfinity(axisY))\n            {\n                return;\n            }\n\n            var deltaX = axisX - _previousAxisX;\n            var deltaY = axisY - _previousAxisY;\n\n            ApplyDelta(deltaX, deltaY);\n            _previousAxisX = axisX;\n            _previousAxisY = axisY;\n        }\n\n        protected override void OnTouchUp(float pointX, float pointY)\n        {\n            _isDragging = false;\n        }\n\n        private void ApplyDelta(double deltaX, double deltaY)\n        {\n            if (_chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var newX1 = DraggableAnnotationHelper.ToNumeric(X1) + deltaX;\n            var newX2 = DraggableAnnotationHelper.ToNumeric(X2) + deltaX;\n            var newY1 = Y1 + deltaY;\n            var newY2 = Y2 + deltaY;\n\n            var bounds = DraggableAnnotationHelper.GetPlotAreaBounds(_chart, _xAxis, _yAxis);\n            DraggableAnnotationHelper.ClampCoordinatesToBounds(ref newX1, ref newX2, ref newY1, ref newY2, bounds);\n\n            X1 = newX1;\n            X2 = newX2;\n            Y1 = newY1;\n            Y2 = newY2;\n        }\n    }\n\n    public sealed class DraggableTextAnnotation : TextAnnotation\n    {\n        private Syncfusion.Maui.Charts.SfCartesianChart? _chart;\n        private ChartAxis? _xAxis;\n        private RangeAxisBase? _yAxis;\n        private bool _isDragging;\n        private double _previousAxisX;\n        private double _previousAxisY;\n        private bool _isDragEnabled = false;\n\n        public void SetDragEnabled(bool enabled)\n        {\n            _isDragEnabled = enabled;\n        }\n\n        public void Attach(Syncfusion.Maui.Charts.SfCartesianChart chart)\n        {\n            _chart = chart;\n            _xAxis = chart.XAxes.Count > 0 ? chart.XAxes[0] : null;\n            _yAxis = chart.YAxes.Count > 0 ? chart.YAxes[0] : null;\n        }\n\n        protected override void OnTouchDown(float pointX, float pointY)\n        {\n            if (_chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var axisX = _chart.PointToValue(_xAxis, pointX, pointY);\n            var axisY = _chart.PointToValue(_yAxis, pointX, pointY);\n\n            if (double.IsNaN(axisX) || double.IsInfinity(axisX) ||\n                double.IsNaN(axisY) || double.IsInfinity(axisY))\n            {\n                return;\n            }\n\n            _previousAxisX = axisX;\n            _previousAxisY = axisY;\n            _isDragging = _isDragEnabled;\n        }\n\n        protected override void OnTouchMove(float pointX, float pointY)\n        {\n            if (!_isDragging || _chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            var axisX = _chart.PointToValue(_xAxis, pointX, pointY);\n            var axisY = _chart.PointToValue(_yAxis, pointX, pointY);\n\n            if (double.IsNaN(axisX) || double.IsInfinity(axisX) ||\n                double.IsNaN(axisY) || double.IsInfinity(axisY))\n            {\n                return;\n            }\n\n            var deltaX = axisX - _previousAxisX;\n            var deltaY = axisY - _previousAxisY;\n\n            ApplyDelta(deltaX, deltaY);\n            _previousAxisX = axisX;\n            _previousAxisY = axisY;\n        }\n\n        protected override void OnTouchUp(float pointX, float pointY)\n        {\n            _isDragging = false;\n        }\n\n        private void ApplyDelta(double deltaX, double deltaY)\n        {\n            if (_chart is null || _xAxis is null || _yAxis is null)\n            {\n                return;\n            }\n\n            double newX1 = DraggableAnnotationHelper.ToNumeric(X1) + deltaX;\n            double newY1 = Y1 + deltaY;\n            X1 = DraggableAnnotationHelper.ClampToVisibleRange(newX1, _xAxis.VisibleMinimum, _xAxis.VisibleMaximum, 0.3);\n            Y1 = DraggableAnnotationHelper.ClampToVisibleRange(newY1, _yAxis.VisibleMinimum, _yAxis.VisibleMaximum, 0.5);\n        }\n    }\n}"
    }
  ]
}