Siyh
Siyh

Reputation: 1809

Gaps in Oxyplot Polyline Annotation

Using Nan values in Oxyplot Lineseries creates a break in the plotted line, however using Nan values in the coordinates of PolylineAnnotations does not. Is there any way to achieve an equivalent break in a single polyline annotation?

Example code below.

I'm aware that using a Lineseries or two polyline annotations are options, but thought I'd ask first.

graph

    public class MainViewModel
    {
        public MainViewModel()
        {
            var tmp = new PlotModel { Title = "Simple example", Subtitle = "using OxyPlot" };

            var series1 = new LineSeries { Title = "Series 1", MarkerType = MarkerType.Circle };
            series1.Points.Add(new DataPoint(0, 0));
            series1.Points.Add(new DataPoint(10, 18));
            series1.Points.Add(new DataPoint(20, 12));
            series1.Points.Add(new DataPoint(double.NaN, 12));
            series1.Points.Add(new DataPoint(30, 8));
            series1.Points.Add(new DataPoint(40, 15));
            tmp.Series.Add(series1);

            var polylineAnnotation1 = new PolylineAnnotation();
            polylineAnnotation1.Points.Add(new DataPoint(0, 15));
            polylineAnnotation1.Points.Add(new DataPoint(20, 10));
            polylineAnnotation1.Points.Add(new DataPoint(double.NaN, 10));
            polylineAnnotation1.Points.Add(new DataPoint(30, 8));
            polylineAnnotation1.Points.Add(new DataPoint(40, 4));
            tmp.Annotations.Add(polylineAnnotation1);

            this.Model = tmp;
        }
        public PlotModel Model { get; private set; }
    }

xaml

<Window x:Class="SimpleDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf" 
        xmlns:simpleDemo="clr-namespace:SimpleDemo"
        Title="OxyPlot SimpleDemo" Height="480" Width="640">
    <Window.DataContext>
        <simpleDemo:MainViewModel />
    </Window.DataContext>
    <Grid>
        <oxy:PlotView Model="{Binding Model}" />
    </Grid>
</Window>

xaml.cs

    public partial class MainWindow
    {
        public MainWindow()
        {
            this.InitializeComponent();
        }
   }

Upvotes: 1

Views: 702

Answers (0)

Related Questions