diff --git a/Source/Examples/ExampleLibrary/Series/PolygonSeriesExamples.cs b/Source/Examples/ExampleLibrary/Series/PolygonSeriesExamples.cs index caf57d01e..4611e346e 100644 --- a/Source/Examples/ExampleLibrary/Series/PolygonSeriesExamples.cs +++ b/Source/Examples/ExampleLibrary/Series/PolygonSeriesExamples.cs @@ -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(); + 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; + } } } diff --git a/Source/OxyPlot/Series/PolygonSeries.cs b/Source/OxyPlot/Series/PolygonSeries.cs index 62d0a2f57..3b89be42f 100644 --- a/Source/OxyPlot/Series/PolygonSeries.cs +++ b/Source/OxyPlot/Series/PolygonSeries.cs @@ -40,6 +40,7 @@ public PolygonSeries() this.LabelFormatString = "0.00"; this.LabelFontSize = 0; this.Stroke = OxyColors.Undefined; + this.Fill = OxyColors.Undefined; this.StrokeThickness = 2; } @@ -101,6 +102,12 @@ public PolygonSeries() /// The stroke. public OxyColor Stroke { get; set; } + /// + /// Gets or sets the fill color of the polygon. + /// + /// The fill color. + public OxyColor Fill { get; set; } + /// /// Gets or sets the stroke thickness. The default is 2. /// @@ -214,7 +221,11 @@ protected void RenderPolygons(IRenderContext rc, ICollection 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) {