public void TestMarkerFill() { MarkerType[] filledMarkers = new MarkerType[4] { MarkerType.FilledCircle, MarkerType.FilledDiamond, MarkerType.FilledSquare, MarkerType.FilledTriangle }; MarkerType[] nonFilledMarkers = new MarkerType[] { MarkerType.Circle, MarkerType.Cross, MarkerType.Diamond, MarkerType.None, MarkerType.Plus, MarkerType.Square, MarkerType.Star, MarkerType.Triangle }; object[] x = new object[5] { 0d, 1d, 2d, 3d, 4d }; object[] y = new object[5] { 0d, 0d, 1d, 2d, 2d }; Line line = new Line(LineType.Solid, LineThickness.Normal); foreach (MarkerType markerType in filledMarkers) { Marker marker = new Marker(markerType, MarkerSize.Normal, 1); BoxWhiskerSeries series = new BoxWhiskerSeries("Title", Color.Green, true, x, y, line, marker, "", ""); BoxPlotSeries oxySeries = (BoxPlotSeries)exporter.Export(series, AxisLabelCollection.Empty()).Result; // Because marker type is "filled", series should be filled with colour. Assert.AreEqual(OxyColors.Green, oxySeries.Fill); } foreach (MarkerType markerType in nonFilledMarkers) { Marker marker = new Marker(markerType, MarkerSize.Normal, 1); BoxWhiskerSeries series = new BoxWhiskerSeries("Title", Color.Green, true, x, y, line, marker, "", ""); BoxPlotSeries oxySeries = (BoxPlotSeries)exporter.Export(series, AxisLabelCollection.Empty()).Result; // Because marker type is "filled", series should be filled with colour. // todo // Assert.AreEqual(OxyColors.Transparent, oxySeries.Fill); } }
/// <summary> /// Create a series with the given System.Drawing.Color and marker type, /// then convert to an oxyplot series and ensure that the generated series' /// marker colour matches the given colour. /// </summary> /// <param name="inputColour">Colour to use when creating the series.</param> /// <param name="markerType">Marker type for the created series.</param> /// <param name="expectedOutput">Expected colour of the output series.</param> private void TestMarkerColour(Color inputColour, MarkerType markerType, OxyColor expectedOutput) { // Create an apsim series with the given inputs. IEnumerable <object> x = Enumerable.Empty <object>(); IEnumerable <object> y = Enumerable.Empty <object>(); Line line = new Line(LineType.None, LineThickness.Thin); Marker marker = new Marker(markerType, MarkerSize.Normal, 1); LineSeries inputSeries = new LineSeries("", inputColour, true, x, y, line, marker, "", ""); // Convert the series to an oxyplot series. Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result; Assert.NotNull(output); Assert.True(output is OxyLineSeries); OxyLineSeries series = (OxyLineSeries)output; Assert.AreEqual(expectedOutput, series.MarkerFill); }
/// <summary> /// Convert an apsim marker type into an oxyplot marker type. /// </summary> /// <param name="marker">Marker type.</param> public static OxyPlot.MarkerType ToOxyPlotMarkerType(this MarkerType marker) { switch (marker) { case MarkerType.Circle: case MarkerType.FilledCircle: return(OxyPlot.MarkerType.Circle); case MarkerType.Cross: return(OxyPlot.MarkerType.Cross); case MarkerType.Diamond: case MarkerType.FilledDiamond: return(OxyPlot.MarkerType.Diamond); case MarkerType.None: return(OxyPlot.MarkerType.None); case MarkerType.Plus: return(OxyPlot.MarkerType.Plus); case MarkerType.Square: case MarkerType.FilledSquare: return(OxyPlot.MarkerType.Square); case MarkerType.Star: return(OxyPlot.MarkerType.Star); case MarkerType.Triangle: case MarkerType.FilledTriangle: return(OxyPlot.MarkerType.Triangle); default: throw new NotImplementedException($"Unknown marker type: {marker}"); } }
public void TestMarkerTypeConversion(MarkerType input, OxyPlot.MarkerType expectedOutput) { Assert.AreEqual(expectedOutput, input.ToOxyPlotMarkerType()); }