Search code examples
c#xamarin.androidoxyplot

OxyPlot: How can I add text to a graph?


I am using OxyPlot.Xamarin.Android to plot irregular polygons (LineSeries), I want also to add near a line it's length. It is possible to add a text in a graph? I also want the zoom in or out to work on the text like on the lines. Thanks.


Solution

  • It is possible to add a text in a graph?

    You could try to use TextAnnotation.
    For example:

            var plotModel = new PlotModel { Title = "OxyPlot Demo" };
    
            ///Other code...
            ///...
            ///...
            ///...
    
            var textAnnotation = new TextAnnotation
            {
                Text = "Text1",
                TextPosition = new DataPoint(1.0, 2.0)
            };
            plotModel.Annotations.Add(textAnnotation);