Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions Source/Examples/ExampleLibrary/Series/PolygonSeriesExamples.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,26 @@ private static DataPoint[] RegularPolygon(DataPoint center, double dimension, in

return res;
}

[Example("WithoutColorAxis")]
[DocumentationExample("Series/PolygonSeries")]
public static PlotModel WithoutColorAxis()
{
var model = new PlotModel { Title = "Without ColorAxis", PlotType = PlotType.Cartesian };

model.Axes.Add(new LinearAxis());

var ps = new PolygonSeries();
var outlines = new List<DataPoint[]>();
for (int i = 0; i < 5; i++)
{
ps.Items.Add(new PolygonItem(RegularPolygon(new DataPoint(i * 5, 0), 2, 3 + i), i));
outlines.Add(RegularPolygon(new DataPoint(i * 5, 5), 2, 3 + i));
}
ps.Items.Add(new PolygonItem(outlines, 10));
model.Series.Add(ps);

return model;
}
}
}
13 changes: 12 additions & 1 deletion Source/OxyPlot/Series/PolygonSeries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public PolygonSeries()
this.LabelFormatString = "0.00";
this.LabelFontSize = 0;
this.Stroke = OxyColors.Undefined;
this.Fill = OxyColors.Undefined;
this.StrokeThickness = 2;
}

Expand Down Expand Up @@ -101,6 +102,12 @@ public PolygonSeries()
/// <value>The stroke.</value>
public OxyColor Stroke { get; set; }

/// <summary>
/// Gets or sets the fill color of the polygon.
/// </summary>
/// <value>The fill color.</value>
public OxyColor Fill { get; set; }

/// <summary>
/// Gets or sets the stroke thickness. The default is <c>2</c>.
/// </summary>
Expand Down Expand Up @@ -214,7 +221,11 @@ protected void RenderPolygons(IRenderContext rc, ICollection<PolygonItem> items)

foreach (var item in items)
{
var polyColor = this.ColorAxis.GetColor(item.Value);
var polyColor = this.Fill.IsUndefined() ?
this.ColorAxis?.GetColor(item.Value) ?? this.PlotModel.GetDefaultColor() :
this.Fill.IsAutomatic() ?
this.PlotModel.GetDefaultColor() :
this.Fill;

foreach (var outline in item.Outlines)
{
Expand Down