Index: Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj
===================================================================
diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj (.../Core.Components.Charting.csproj) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21)
+++ Core/Components/src/Core.Components.Charting/Core.Components.Charting.csproj (.../Core.Components.Charting.csproj) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -45,7 +45,10 @@
+
+
+
Index: Core/Components/src/Core.Components.Charting/Data/ChartAreaData.cs
===================================================================
diff -u -r1dd7affebae1187cb96778e85d021f7dc5ac9e50 -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/src/Core.Components.Charting/Data/ChartAreaData.cs (.../ChartAreaData.cs) (revision 1dd7affebae1187cb96778e85d021f7dc5ac9e50)
+++ Core/Components/src/Core.Components.Charting/Data/ChartAreaData.cs (.../ChartAreaData.cs) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
+using Core.Components.Charting.Styles;
namespace Core.Components.Charting.Data
{
@@ -39,5 +40,10 @@
/// Thrown when is
/// null or only whitespace.
public ChartAreaData(IEnumerable> points, string name) : base(points, name) {}
+
+ ///
+ /// The style of the chart area.
+ ///
+ public ChartAreaStyle Style { get; set; }
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Charting/Data/ChartPointData.cs
===================================================================
diff -u -r1dd7affebae1187cb96778e85d021f7dc5ac9e50 -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/src/Core.Components.Charting/Data/ChartPointData.cs (.../ChartPointData.cs) (revision 1dd7affebae1187cb96778e85d021f7dc5ac9e50)
+++ Core/Components/src/Core.Components.Charting/Data/ChartPointData.cs (.../ChartPointData.cs) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
+using Core.Components.Charting.Styles;
namespace Core.Components.Charting.Data
{
@@ -39,5 +40,10 @@
/// Thrown when is
/// null or only whitespace.
public ChartPointData(IEnumerable> points, string name) : base(points, name) {}
+
+ ///
+ /// The style of the point.
+ ///
+ public ChartPointStyle Style { get; set; }
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Charting/Styles/ChartAreaStyle.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Charting/Styles/ChartAreaStyle.cs (revision 0)
+++ Core/Components/src/Core.Components.Charting/Styles/ChartAreaStyle.cs (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -0,0 +1,59 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+
+namespace Core.Components.Charting.Styles
+{
+ ///
+ /// This class represents styling of a area on a chart.
+ ///
+ public class ChartAreaStyle
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The fill color of the area.
+ /// The stroke color of the area.
+ /// The width of the area border.
+ public ChartAreaStyle(Color fillColor, Color strokeColor, int width)
+ {
+ FillColor = fillColor;
+ StrokeColor = strokeColor;
+ Width = width;
+ }
+
+ ///
+ /// Gets the area fill color.
+ ///
+ public Color FillColor { get; private set; }
+
+ ///
+ /// Gets the area stroke color.
+ ///
+ public Color StrokeColor { get; private set; }
+
+ ///
+ /// Gets the area border width.
+ ///
+ public int Width { get; private set; }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.Charting/Styles/ChartPointStyle.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Charting/Styles/ChartPointStyle.cs (revision 0)
+++ Core/Components/src/Core.Components.Charting/Styles/ChartPointStyle.cs (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -0,0 +1,59 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+
+namespace Core.Components.Charting.Styles
+{
+ ///
+ /// This class represents styling of a point on a chart.
+ ///
+ public class ChartPointStyle
+ {
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The color of the point.
+ /// The size of the point.
+ /// The symbol of the point.
+ public ChartPointStyle(Color color, int size, ChartPointSymbol symbol)
+ {
+ Color = color;
+ Size = size;
+ Symbol = symbol;
+ }
+
+ ///
+ /// Gets the point color.
+ ///
+ public Color Color { get; private set; }
+
+ ///
+ /// Gets the point size.
+ ///
+ public double Size { get; private set; }
+
+ ///
+ /// Gets the point symbol.
+ ///
+ public ChartPointSymbol Symbol { get; private set; }
+ }
+}
Index: Core/Components/src/Core.Components.Charting/Styles/ChartPointSymbol.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.Charting/Styles/ChartPointSymbol.cs (revision 0)
+++ Core/Components/src/Core.Components.Charting/Styles/ChartPointSymbol.cs (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -0,0 +1,35 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+namespace Core.Components.Charting.Styles
+{
+ ///
+ /// All symbols supported by .
+ ///
+ public enum ChartPointSymbol
+ {
+ None,
+ Circle,
+ Square,
+ Diamond,
+ Triangle
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ChartAreaDataConverter.cs
===================================================================
diff -u -r8aa11a9aa48733a5b5b72c58c71674472825b26c -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/src/Core.Components.OxyPlot/Converter/ChartAreaDataConverter.cs (.../ChartAreaDataConverter.cs) (revision 8aa11a9aa48733a5b5b72c58c71674472825b26c)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ChartAreaDataConverter.cs (.../ChartAreaDataConverter.cs) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -21,6 +21,7 @@
using System.Collections.Generic;
using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
using OxyPlot.Series;
namespace Core.Components.OxyPlot.Converter
@@ -45,7 +46,20 @@
{
series.Points2.Add(series.Points[0]);
}
+
+ CreateStyle(series, data.Style);
+
return new List { series };
}
+
+ private void CreateStyle(AreaSeries series, ChartAreaStyle style)
+ {
+ if (style != null)
+ {
+ series.Fill = ChartDataHelper.Convert(style.FillColor);
+ series.Color = ChartDataHelper.Convert(style.StrokeColor);
+ series.StrokeThickness = style.Width;
+ }
+ }
}
}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ChartDataHelper.cs
===================================================================
diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/src/Core.Components.OxyPlot/Converter/ChartDataHelper.cs (.../ChartDataHelper.cs) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ChartDataHelper.cs (.../ChartDataHelper.cs) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -20,8 +20,10 @@
// All rights reserved.
using System;
+using System.Drawing;
using System.Drawing.Drawing2D;
using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
using OxyPlot;
namespace Core.Components.OxyPlot.Converter
@@ -62,5 +64,48 @@
}
return lineStyle;
}
+
+ ///
+ /// Converts to .
+ ///
+ /// The to convert.
+ /// The converted .
+ /// Thrown when
+ /// cannot be converted.
+ public static MarkerType Convert(ChartPointSymbol symbol)
+ {
+ MarkerType markerType;
+ switch (symbol)
+ {
+ case ChartPointSymbol.None:
+ markerType = MarkerType.None;
+ break;
+ case ChartPointSymbol.Circle:
+ markerType = MarkerType.Circle;
+ break;
+ case ChartPointSymbol.Square:
+ markerType = MarkerType.Square;
+ break;
+ case ChartPointSymbol.Diamond:
+ markerType = MarkerType.Diamond;
+ break;
+ case ChartPointSymbol.Triangle:
+ markerType = MarkerType.Triangle;
+ break;
+ default:
+ throw new NotSupportedException();
+ }
+ return markerType;
+ }
+
+ ///
+ /// Converts to .
+ ///
+ /// The to convert.
+ /// The converted .
+ public static OxyColor Convert(Color color)
+ {
+ return OxyColor.FromArgb(color.A, color.R, color.G, color.B);
+ }
}
-}
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ChartLineDataConverter.cs
===================================================================
diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/src/Core.Components.OxyPlot/Converter/ChartLineDataConverter.cs (.../ChartLineDataConverter.cs) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ChartLineDataConverter.cs (.../ChartLineDataConverter.cs) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -40,8 +40,7 @@
ItemsSource = data.Points.ToArray(),
Mapping = TupleToDataPoint,
IsVisible = data.IsVisible,
- Tag = data,
- Title = data.Name
+ Tag = data
};
CreateStyle(series, data.Style);
@@ -53,7 +52,7 @@
{
if (style != null)
{
- series.Color = OxyColor.FromArgb(style.Color.A, style.Color.R, style.Color.G, style.Color.B);
+ series.Color = ChartDataHelper.Convert(style.Color);
series.StrokeThickness = style.Width;
series.LineStyle = ChartDataHelper.Convert(style.Style);
}
Index: Core/Components/src/Core.Components.OxyPlot/Converter/ChartPointDataConverter.cs
===================================================================
diff -u -r8aa11a9aa48733a5b5b72c58c71674472825b26c -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/src/Core.Components.OxyPlot/Converter/ChartPointDataConverter.cs (.../ChartPointDataConverter.cs) (revision 8aa11a9aa48733a5b5b72c58c71674472825b26c)
+++ Core/Components/src/Core.Components.OxyPlot/Converter/ChartPointDataConverter.cs (.../ChartPointDataConverter.cs) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -22,6 +22,7 @@
using System.Collections.Generic;
using System.Linq;
using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
using OxyPlot;
using OxyPlot.Series;
@@ -41,9 +42,22 @@
Mapping = TupleToDataPoint,
LineStyle = LineStyle.None,
MarkerType = MarkerType.Circle,
- Tag = data,
+ Tag = data
};
+
+ CreateStyle(series, data.Style);
+
return new List { series };
}
+
+ private void CreateStyle(LineSeries series, ChartPointStyle style)
+ {
+ if (style != null)
+ {
+ series.MarkerFill = ChartDataHelper.Convert(style.Color);
+ series.MarkerSize = style.Size;
+ series.MarkerType = ChartDataHelper.Convert(style.Symbol);
+ }
+ }
}
}
\ No newline at end of file
Index: Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj
===================================================================
diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj (.../Core.Components.Charting.Test.csproj) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21)
+++ Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj (.../Core.Components.Charting.Test.csproj) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -54,7 +54,9 @@
+
+
Index: Core/Components/test/Core.Components.Charting.Test/Styles/ChartAreaStyleTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.Charting.Test/Styles/ChartAreaStyleTest.cs (revision 0)
+++ Core/Components/test/Core.Components.Charting.Test/Styles/ChartAreaStyleTest.cs (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -0,0 +1,48 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using Core.Components.Charting.Styles;
+using NUnit.Framework;
+
+namespace Core.Components.Charting.Test.Styles
+{
+ [TestFixture]
+ public class ChartAreaStyleTest
+ {
+ [Test]
+ public void Constructor_WithAllParameters_SetsProperties()
+ {
+ // Setup
+ var fillColor = Color.AliceBlue;
+ var strokeColor = Color.Blue;
+ var width = 3;
+
+ // Call
+ var areaStyle = new ChartAreaStyle(fillColor, strokeColor, width);
+
+ // Assert
+ Assert.AreEqual(fillColor, areaStyle.FillColor);
+ Assert.AreEqual(strokeColor, areaStyle.StrokeColor);
+ Assert.AreEqual(width, areaStyle.Width);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.Charting.Test/Styles/ChartLineStyleTest.cs
===================================================================
diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/test/Core.Components.Charting.Test/Styles/ChartLineStyleTest.cs (.../ChartLineStyleTest.cs) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21)
+++ Core/Components/test/Core.Components.Charting.Test/Styles/ChartLineStyleTest.cs (.../ChartLineStyleTest.cs) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -44,6 +44,6 @@
Assert.AreEqual(color, lineStyle.Color);
Assert.AreEqual(width, lineStyle.Width);
Assert.AreEqual(style, lineStyle.Style);
- }
+ }
}
}
\ No newline at end of file
Index: Core/Components/test/Core.Components.Charting.Test/Styles/ChartPointStyleTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.Charting.Test/Styles/ChartPointStyleTest.cs (revision 0)
+++ Core/Components/test/Core.Components.Charting.Test/Styles/ChartPointStyleTest.cs (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -0,0 +1,48 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Lesser General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using Core.Components.Charting.Styles;
+using NUnit.Framework;
+
+namespace Core.Components.Charting.Test.Styles
+{
+ [TestFixture]
+ public class ChartPointStyleTest
+ {
+ [Test]
+ public void Constructor_WithAllParameters_SetsProperties()
+ {
+ // Setup
+ var color = Color.AliceBlue;
+ var width = 3;
+ var symbol = ChartPointSymbol.Circle;
+
+ // Call
+ var pointStyle = new ChartPointStyle(color, width, symbol);
+
+ // Assert
+ Assert.AreEqual(color, pointStyle.Color);
+ Assert.AreEqual(width, pointStyle.Size);
+ Assert.AreEqual(symbol, pointStyle.Symbol);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartAreaDataConverterTest.cs
===================================================================
diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartAreaDataConverterTest.cs (.../ChartAreaDataConverterTest.cs) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartAreaDataConverterTest.cs (.../ChartAreaDataConverterTest.cs) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -22,9 +22,11 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Drawing;
using System.Linq;
using Core.Common.TestUtil;
using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
using Core.Components.Charting.TestUtil;
using Core.Components.OxyPlot.Converter;
using NUnit.Framework;
@@ -130,5 +132,79 @@
// Assert
TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
}
+
+ [Test]
+ [TestCase(KnownColor.AliceBlue)]
+ [TestCase(KnownColor.Azure)]
+ [TestCase(KnownColor.Beige)]
+ public void Convert_WithDifferentFillColors_AppliesStyleToSeries(KnownColor color)
+ {
+ // Setup
+ var converter = new ChartAreaDataConverter();
+ var expectedColor = Color.FromKnownColor(color);
+ var style = new ChartAreaStyle(expectedColor, Color.Red, 3);
+ var data = new ChartAreaData(new Collection>(), "test")
+ {
+ Style = style
+ };
+
+ // Call
+ var series = converter.Convert(data);
+
+ // Assert
+ var areaSeries = ((AreaSeries)series[0]);
+ AssertColors(style.FillColor, areaSeries.Fill);
+ }
+
+ [Test]
+ [TestCase(KnownColor.AliceBlue)]
+ [TestCase(KnownColor.Azure)]
+ [TestCase(KnownColor.Beige)]
+ public void Convert_WithDifferentStrokeColors_AppliesStyleToSeries(KnownColor color)
+ {
+ // Setup
+ var converter = new ChartAreaDataConverter();
+ var expectedColor = Color.FromKnownColor(color);
+ var style = new ChartAreaStyle(Color.Red, expectedColor, 3);
+ var data = new ChartAreaData(new Collection>(), "test")
+ {
+ Style = style
+ };
+
+ // Call
+ var series = converter.Convert(data);
+
+ // Assert
+ var areaSeries = ((AreaSeries)series[0]);
+ AssertColors(style.StrokeColor, areaSeries.Color);
+ }
+
+ [Test]
+ [TestCase(1)]
+ [TestCase(5)]
+ [TestCase(7)]
+ public void Convert_WithDifferentStrokeWidths_AppliesStyleToSeries(int width)
+ {
+ // Setup
+ var converter = new ChartAreaDataConverter();
+ var style = new ChartAreaStyle(Color.Red, Color.Red, width);
+ var data = new ChartAreaData(new Collection>(), "test")
+ {
+ Style = style
+ };
+
+ // Call
+ var series = converter.Convert(data);
+
+ // Assert
+ var areaSeries = ((AreaSeries)series[0]);
+ Assert.AreEqual(width, areaSeries.StrokeThickness);
+ }
+
+ private void AssertColors(Color color, OxyColor oxyColor)
+ {
+ OxyColor originalColor = OxyColor.FromArgb(color.A, color.R, color.G, color.B);
+ Assert.AreEqual(originalColor, oxyColor);
+ }
}
}
\ No newline at end of file
Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartDataHelperTest.cs
===================================================================
diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartDataHelperTest.cs (.../ChartDataHelperTest.cs) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartDataHelperTest.cs (.../ChartDataHelperTest.cs) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -20,7 +20,9 @@
// All rights reserved.
using System;
+using System.Drawing;
using System.Drawing.Drawing2D;
+using Core.Components.Charting.Styles;
using Core.Components.OxyPlot.Converter;
using NUnit.Framework;
using OxyPlot;
@@ -30,6 +32,8 @@
[TestFixture]
public class ChartDataHelperTest
{
+ #region Convert DashStyle
+
[Test]
public void Convert_Solid_ReturnsDefault()
{
@@ -89,5 +93,82 @@
// Assert
Assert.Throws(call);
}
+
+ #endregion
+
+ #region Convert ChartPointSymbol
+
+ [Test]
+ public void Convert_None_ReturnsNone()
+ {
+ // Call
+ MarkerType markerType = ChartDataHelper.Convert(ChartPointSymbol.None);
+
+ // Assert
+ Assert.AreEqual(MarkerType.None, markerType);
+ }
+
+ [Test]
+ public void Convert_Circle_ReturnsCircle()
+ {
+ // Call
+ MarkerType markerType = ChartDataHelper.Convert(ChartPointSymbol.Circle);
+
+ // Assert
+ Assert.AreEqual(MarkerType.Circle, markerType);
+ }
+
+ [Test]
+ public void Convert_Square_ReturnsSquare()
+ {
+ // Call
+ MarkerType markerType = ChartDataHelper.Convert(ChartPointSymbol.Square);
+
+ // Assert
+ Assert.AreEqual(MarkerType.Square, markerType);
+ }
+
+ [Test]
+ public void Convert_Diamond_ReturnsDiamond()
+ {
+ // Call
+ MarkerType markerType = ChartDataHelper.Convert(ChartPointSymbol.Diamond);
+
+ // Assert
+ Assert.AreEqual(MarkerType.Diamond, markerType);
+ }
+
+ [Test]
+ public void Convert_Triangle_ReturnsTriangle()
+ {
+ // Call
+ MarkerType markerType = ChartDataHelper.Convert(ChartPointSymbol.Triangle);
+
+ // Assert
+ Assert.AreEqual(MarkerType.Triangle, markerType);
+ }
+
+ #endregion
+
+ #region Convert Color
+
+ [Test]
+ [TestCase(KnownColor.Blue)]
+ [TestCase(KnownColor.Red)]
+ [TestCase(KnownColor.Green)]
+ public void Convert_Color_ReturnsOxyColor(KnownColor knownColor)
+ {
+ // Setup
+ Color color = Color.FromKnownColor(knownColor);
+
+ // Call
+ OxyColor oxyColor = ChartDataHelper.Convert(color);
+
+ // Assert
+ OxyColor originalColor = OxyColor.FromArgb(color.A, color.R, color.G, color.B);
+ Assert.AreEqual(originalColor, oxyColor);
+ }
+
+ #endregion
}
}
\ No newline at end of file
Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartLineDataConverterTest.cs
===================================================================
diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartLineDataConverterTest.cs (.../ChartLineDataConverterTest.cs) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartLineDataConverterTest.cs (.../ChartLineDataConverterTest.cs) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -133,22 +133,6 @@
}
[Test]
- public void Convert_DataName_SeriesTitleSameAsDataName()
- {
- // Setup
- var name = "";
- var converter = new ChartLineDataConverter();
- var data = new ChartLineData(new Collection>(), name);
-
- // Call
- var series = converter.Convert(data);
-
- // Assert
- var lineSeries = ((LineSeries)series[0]);
- Assert.AreEqual(name, lineSeries.Title);
- }
-
- [Test]
[TestCase(KnownColor.AliceBlue)]
[TestCase(KnownColor.Azure)]
[TestCase(KnownColor.Beige)]
Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartPointDataConverterTest.cs
===================================================================
diff -u -r0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21 -rebbb56ddd6ef8857548dcbbfa51c0650f0207d86
--- Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartPointDataConverterTest.cs (.../ChartPointDataConverterTest.cs) (revision 0b76c9841bdeef5c3b9fa1ba0d6cb98a63b90c21)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartPointDataConverterTest.cs (.../ChartPointDataConverterTest.cs) (revision ebbb56ddd6ef8857548dcbbfa51c0650f0207d86)
@@ -22,8 +22,10 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Drawing;
using Core.Common.TestUtil;
using Core.Components.Charting.Data;
+using Core.Components.Charting.Styles;
using Core.Components.Charting.TestUtil;
using Core.Components.OxyPlot.Converter;
using NUnit.Framework;
@@ -130,5 +132,80 @@
// Assert
TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage);
}
+
+ [Test]
+ [TestCase(KnownColor.AliceBlue)]
+ [TestCase(KnownColor.Azure)]
+ [TestCase(KnownColor.Beige)]
+ public void Convert_WithDifferentColors_AppliesStyleToSeries(KnownColor color)
+ {
+ // Setup
+ var converter = new ChartPointDataConverter();
+ var expectedColor = Color.FromKnownColor(color);
+ var style = new ChartPointStyle(expectedColor, 3, ChartPointSymbol.Circle);
+ var data = new ChartPointData(new Collection>(), "test")
+ {
+ Style = style
+ };
+
+ // Call
+ var series = converter.Convert(data);
+
+ // Assert
+ var lineSeries = ((LineSeries)series[0]);
+ AssertColors(style.Color, lineSeries.MarkerFill);
+ }
+
+ [Test]
+ [TestCase(1)]
+ [TestCase(5)]
+ [TestCase(7)]
+ public void Convert_WithDifferentWidths_AppliesStyleToSeries(int width)
+ {
+ // Setup
+ var converter = new ChartPointDataConverter();
+ var style = new ChartPointStyle(Color.Red, width, ChartPointSymbol.Circle);
+ var data = new ChartPointData(new Collection>(), "test")
+ {
+ Style = style
+ };
+
+ // Call
+ var series = converter.Convert(data);
+
+ // Assert
+ var lineSeries = ((LineSeries)series[0]);
+ Assert.AreEqual(width, lineSeries.MarkerSize);
+ }
+
+ [Test]
+ [TestCase(ChartPointSymbol.None, MarkerType.None)]
+ [TestCase(ChartPointSymbol.Circle, MarkerType.Circle)]
+ [TestCase(ChartPointSymbol.Square, MarkerType.Square)]
+ [TestCase(ChartPointSymbol.Diamond, MarkerType.Diamond)]
+ [TestCase(ChartPointSymbol.Triangle, MarkerType.Triangle)]
+ public void Convert_WidhtDifferentChartPointSymbols_AppliesStyleToSeries(ChartPointSymbol symbol, MarkerType expectedMarkerType)
+ {
+ // Setup
+ var converter = new ChartPointDataConverter();
+ var style = new ChartPointStyle(Color.Red, 3, symbol);
+ var data = new ChartPointData(new Collection>(), "test")
+ {
+ Style = style
+ };
+
+ // Call
+ var series = converter.Convert(data);
+
+ // Assert
+ var lineSeries = ((LineSeries)series[0]);
+ Assert.AreEqual(expectedMarkerType, lineSeries.MarkerType);
+ }
+
+ private void AssertColors(Color color, OxyColor oxyColor)
+ {
+ OxyColor originalColor = OxyColor.FromArgb(color.A, color.R, color.G, color.B);
+ Assert.AreEqual(originalColor, oxyColor);
+ }
}
}
\ No newline at end of file