Search code examples
c#wpfcoordinatescoordinate-systemsoxyplot

Circles with a diameter


I have an OxyPlot that looks like this so far:

enter image description here

But I would like to create circles with a hole in the middle and I can give the circles a diameter, how big these should be.

enter image description here

Do not let the picture irritate you, the circles should be the same size

In the end it should look like this. With circles the holes are in the middle and have a certain diameter.

XAML

<oxy:Plot x:Name="oxyPlot" Title="{Binding Title}" Height="279" Canvas.Left="259" Canvas.Top="29" Width="344" Background="#FFD1CFD0">
    <oxy:Plot.Axes>
        <oxy:LinearAxis Position="Bottom" MinimumPadding="0.1" MaximumPadding="0.1"/>
        <oxy:LinearAxis Position="Left" MinimumPadding="0.1" MaximumPadding="0.1"/>
    </oxy:Plot.Axes>
    <oxy:Plot.Series>
        <oxy:LineSeries x:Name="ls" ItemsSource="{Binding Points}" LineStyle="None"  MarkerType="Circle" MarkerSize="5" MarkerFill="Black"/>
    </oxy:Plot.Series>
</oxy:Plot>

Solution

  • You should use a combination of these properties on you LineSeries:

    MarkerStroke="Red" 
    MarkerType="Circle" 
    MarkerStrokeThickness="3" 
    MarkerSize="5" 
    MarkerFill="Transparent"
    

    MarkerSize determines the radius, and MarkerStrokeThickness determines the thickness of the outer line. Note that in order to get an empty circle at the middle, MarkerStrokeThickness should be less than MarkerSize. MarkerFill determines the color of the inner circle and MarkerStroke determines the color of the border.

    More complex shapes can be created by MarkerType="Custom" and setting MarkerOutline property.

    In Code

            ls.MarkerType = MarkerType.Circle;
            ls.MarkerFill = System.Windows.Media.Colors.Transparent;
            ls.MarkerStroke = System.Windows.Media.Colors.Red;
            ls.MarkerSize = 40;
            ls.MarkerStrokeThickness = 3;