Index: Core/Components/src/Core.Components.OxyPlot/BaseChart.cs
===================================================================
diff -u -rbc5cd9c379afef6f6f3fc02f8a890f240fd3fe65 -r4ea1323ca52ee52133113dbc01bae0429946d0d4
--- Core/Components/src/Core.Components.OxyPlot/BaseChart.cs (.../BaseChart.cs) (revision bc5cd9c379afef6f6f3fc02f8a890f240fd3fe65)
+++ Core/Components/src/Core.Components.OxyPlot/BaseChart.cs (.../BaseChart.cs) (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -1,4 +1,5 @@
-using Core.Components.OxyPlot.Properties;
+using Core.Components.OxyPlot.Data;
+using Core.Components.OxyPlot.Properties;
using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.WindowsForms;
@@ -40,28 +41,32 @@
{
Title = Resources.BaseChart_XAxisTitle,
Position = AxisPosition.Bottom,
- TickStyle = TickStyle.None
+ TickStyle = TickStyle.None,
+ ExtraGridlines = new[] { 0.0 },
+ ExtraGridlineThickness = 1
};
yAxis = new LinearAxis
{
Title = Resources.BaseChart_YAxisTitle,
- TickStyle = TickStyle.None
+ TickStyle = TickStyle.None,
+ ExtraGridlines = new[] { 0.0 },
+ ExtraGridlineThickness = 1
};
Model.Axes.Add(xAxis);
Model.Axes.Add(yAxis);
}
///
- /// Add to the .
+ /// Add to the .
///
///
- public void AddData(ChartData data)
+ public void AddData(IChartData data)
{
data.AddTo(Model);
}
///
- /// Remove all the that has been added to the .
+ /// Remove all the that has been added to the .
///
public void ClearData()
{
Fisheye: Tag 4ea1323ca52ee52133113dbc01bae0429946d0d4 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/ChartData.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj
===================================================================
diff -u -rbc5cd9c379afef6f6f3fc02f8a890f240fd3fe65 -r4ea1323ca52ee52133113dbc01bae0429946d0d4
--- Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj (.../Core.Components.OxyPlot.csproj) (revision bc5cd9c379afef6f6f3fc02f8a890f240fd3fe65)
+++ Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj (.../Core.Components.OxyPlot.csproj) (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -60,7 +60,10 @@
Component
-
+
+
+
+
True
Index: Core/Components/src/Core.Components.OxyPlot/Data/AreaData.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.OxyPlot/Data/AreaData.cs (revision 0)
+++ Core/Components/src/Core.Components.OxyPlot/Data/AreaData.cs (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Linq;
+using OxyPlot;
+using OxyPlot.Series;
+
+namespace Core.Components.OxyPlot.Data
+{
+ ///
+ /// This class represents data which is represented as an area on .
+ ///
+ public class AreaData : IChartData
+ {
+ private AreaSeries series;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// A of which represent points on a line.
+ /// Thrown when is null.
+ public AreaData(Collection> points)
+ {
+ if (points == null)
+ {
+ throw new ArgumentNullException("points", "A point collection is required when creating ChartData.");
+ }
+ series = new AreaSeries
+ {
+ MarkerType = MarkerType.Cross,
+ MarkerStroke = OxyColors.Black
+ };
+ foreach (var p in points)
+ {
+ series.Points.Add(Mapping(p));
+ }
+ //series.Points2.Add(Mapping(points.First()));
+ }
+
+ private DataPoint Mapping(Tuple point)
+ {
+ return new DataPoint(point.Item1, point.Item2);
+ }
+
+ ///
+ /// Adds the information in the as a series of the .
+ ///
+ /// The to add a series to.
+ /// Thrown when is null.
+ public void AddTo(PlotModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException("model", "A model is required to add points to.");
+ }
+ model.Series.Add(series);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot/Data/CollectionData.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.OxyPlot/Data/CollectionData.cs (revision 0)
+++ Core/Components/src/Core.Components.OxyPlot/Data/CollectionData.cs (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -0,0 +1,30 @@
+using System.Collections.ObjectModel;
+using OxyPlot;
+
+namespace Core.Components.OxyPlot.Data
+{
+ ///
+ /// This class represents a collection of data which can be added to a .
+ ///
+ public class CollectionData : IChartData
+ {
+ readonly Collection dataCollection = new Collection();
+
+ public void AddTo(PlotModel model)
+ {
+ foreach (IChartData data in dataCollection)
+ {
+ data.AddTo(model);
+ }
+ }
+
+ ///
+ /// Add new data to the .
+ ///
+ /// The data to add to the .
+ public void Add(IChartData data)
+ {
+ dataCollection.Add(data);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot/Data/IChartData.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.OxyPlot/Data/IChartData.cs (revision 0)
+++ Core/Components/src/Core.Components.OxyPlot/Data/IChartData.cs (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -0,0 +1,18 @@
+using System;
+using OxyPlot;
+
+namespace Core.Components.OxyPlot.Data
+{
+ ///
+ /// This interface describes the data which can be added to the .
+ ///
+ public interface IChartData {
+
+ ///
+ /// Adds the information in the as a series of the .
+ ///
+ /// The to add a series to.
+ /// Thrown when is null.
+ void AddTo(PlotModel model);
+ }
+}
\ No newline at end of file
Index: Core/Components/src/Core.Components.OxyPlot/Data/LineData.cs
===================================================================
diff -u
--- Core/Components/src/Core.Components.OxyPlot/Data/LineData.cs (revision 0)
+++ Core/Components/src/Core.Components.OxyPlot/Data/LineData.cs (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.ObjectModel;
+using OxyPlot;
+using OxyPlot.Series;
+
+namespace Core.Components.OxyPlot.Data
+{
+ ///
+ /// This class represents data which is represented as a line on .
+ ///
+ public class LineData : IChartData
+ {
+ private readonly LineSeries series;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// A of which represent points on a line.
+ /// Thrown when is null.
+ public LineData(Collection> points)
+ {
+ if (points == null)
+ {
+ throw new ArgumentNullException("points", "A point collection is required when creating ChartData.");
+ }
+ series = new LineSeries
+ {
+ ItemsSource = points,
+ Mapping = point => new DataPoint(((Tuple)point).Item1, ((Tuple)point).Item2)
+ };
+ }
+
+ ///
+ /// Adds the information in the as a series of the .
+ ///
+ /// The to add a series to.
+ /// Thrown when is null.
+ public void AddTo(PlotModel model)
+ {
+ if (model == null)
+ {
+ throw new ArgumentNullException("model", "A model is required to add points to.");
+ }
+ model.Series.Add(series);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 4ea1323ca52ee52133113dbc01bae0429946d0d4 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/ChartDataTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj
===================================================================
diff -u -rbc5cd9c379afef6f6f3fc02f8a890f240fd3fe65 -r4ea1323ca52ee52133113dbc01bae0429946d0d4
--- Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj (.../Core.Components.OxyPlot.Test.csproj) (revision bc5cd9c379afef6f6f3fc02f8a890f240fd3fe65)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj (.../Core.Components.OxyPlot.Test.csproj) (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -60,7 +60,9 @@
-
+
+
+
Index: Core/Components/test/Core.Components.OxyPlot.Test/Data/AreaDataTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.OxyPlot.Test/Data/AreaDataTest.cs (revision 0)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Data/AreaDataTest.cs (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Core.Components.OxyPlot.Data;
+using NUnit.Framework;
+using OxyPlot;
+using OxyPlot.Series;
+
+namespace Core.Components.OxyPlot.Test.Data
+{
+ [TestFixture]
+ public class AreaDataTest
+ {
+ [Test]
+ public void Constructor_NullPoints_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new AreaData(null);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Constructor_WithEmptyPoints_CreatesNewICharData()
+ {
+ // Setup
+ var points = new Collection>();
+
+ // Call
+ var data = new AreaData(points);
+
+ // Assert
+ Assert.IsInstanceOf(data);
+ }
+
+ [Test]
+ public void Constructor_WithPoints_CreatesNewICharData()
+ {
+ // Setup
+ var points = CreateTestPoints();
+
+ // Call
+ var data = new AreaData(points);
+
+ // Assert
+ Assert.IsInstanceOf(data);
+ }
+
+ [Test]
+ public void AddTo_NoModel_ThrowsArgumentNullException()
+ {
+ // Setup
+ var points = CreateTestPoints();
+ var testData = new AreaData(points);
+
+ // Call
+ TestDelegate test = () => testData.AddTo(null);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void AddTo_Model_DataAddedToModelAsSeries()
+ {
+ // Setup
+ var points = CreateTestPoints();
+ var testData = new AreaData(points);
+ var model = new PlotModel();
+
+ // Call
+ testData.AddTo(model);
+
+ // Assert
+ Assert.AreEqual(1, model.Series.Count);
+ Assert.IsInstanceOf(model.Series.First());
+
+ var series = (AreaSeries)model.Series.First();
+ Assert.AreSame(points, series.ItemsSource);
+ }
+
+ private Collection> CreateTestPoints()
+ {
+ return new Collection>
+ {
+ new Tuple(0.0, 1.1),
+ new Tuple(1.0, 2.1),
+ new Tuple(1.6, 1.6)
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.OxyPlot.Test/Data/CollectionDataTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.OxyPlot.Test/Data/CollectionDataTest.cs (revision 0)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Data/CollectionDataTest.cs (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.ObjectModel;
+using Core.Components.OxyPlot.Data;
+using NUnit.Framework;
+
+namespace Core.Components.OxyPlot.Test.Data
+{
+ [TestFixture]
+ public class CollectionDataTest
+ {
+ [Test]
+ public void DefaultConstructor_NewInstanceOfIChartData()
+ {
+ // Call
+ var data = new CollectionData();
+
+ // Assert
+ Assert.IsInstanceOf(data);
+ }
+
+ [Test]
+ [TestCase(0)]
+ [TestCase(1)]
+ [TestCase(11)]
+ public void GivenANumberOfChartData_WhenAddedToChart_AddsSameNumberOfSeriesToModel(int numberOfSeries)
+ {
+ // Given
+ var chart = new BaseChart();
+ var data = new CollectionData();
+ for (int i = 0; i < numberOfSeries; i++)
+ {
+ data.Add(new LineData(new Collection>()));
+ }
+
+ // When
+ chart.AddData(data);
+
+ // Assert
+ Assert.AreEqual(numberOfSeries, chart.Model.Series.Count);
+ }
+ }
+}
\ No newline at end of file
Index: Core/Components/test/Core.Components.OxyPlot.Test/Data/LineDataTest.cs
===================================================================
diff -u
--- Core/Components/test/Core.Components.OxyPlot.Test/Data/LineDataTest.cs (revision 0)
+++ Core/Components/test/Core.Components.OxyPlot.Test/Data/LineDataTest.cs (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -0,0 +1,93 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Linq;
+using Core.Components.OxyPlot.Data;
+using NUnit.Framework;
+using OxyPlot;
+using OxyPlot.Series;
+
+namespace Core.Components.OxyPlot.Test.Data
+{
+ [TestFixture]
+ public class LineDataTest
+ {
+ [Test]
+ public void Constructor_NullPoints_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new LineData(null);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void Constructor_WithEmptyPoints_CreatesNewICharData()
+ {
+ // Setup
+ var points = new Collection>();
+
+ // Call
+ var data = new LineData(points);
+
+ // Assert
+ Assert.IsInstanceOf(data);
+ }
+
+ [Test]
+ public void Constructor_WithPoints_CreatesNewICharData()
+ {
+ // Setup
+ var points = CreateTestPoints();
+
+ // Call
+ var data = new LineData(points);
+
+ // Assert
+ Assert.IsInstanceOf(data);
+ }
+
+ [Test]
+ public void AddTo_NoModel_ThrowsArgumentNullException()
+ {
+ // Setup
+ var points = CreateTestPoints();
+ var testData = new LineData(points);
+
+ // Call
+ TestDelegate test = () => testData.AddTo(null);
+
+ // Assert
+ Assert.Throws(test);
+ }
+
+ [Test]
+ public void AddTo_Model_DataAddedToModelAsSeries()
+ {
+ // Setup
+ var points = CreateTestPoints();
+ var testData = new LineData(points);
+ var model = new PlotModel();
+
+ // Call
+ testData.AddTo(model);
+
+ // Assert
+ Assert.AreEqual(1, model.Series.Count);
+ Assert.IsInstanceOf(model.Series.First());
+
+ var series = (LineSeries)model.Series.First();
+ Assert.AreSame(points, series.ItemsSource);
+ }
+
+ private Collection> CreateTestPoints()
+ {
+ return new Collection>
+ {
+ new Tuple(0.0, 1.1),
+ new Tuple(1.0, 2.1),
+ new Tuple(1.6, 1.6)
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Core/Plugins/src/Core.Plugins.OxyPlot/Forms/ChartDataView.cs
===================================================================
diff -u -rbc5cd9c379afef6f6f3fc02f8a890f240fd3fe65 -r4ea1323ca52ee52133113dbc01bae0429946d0d4
--- Core/Plugins/src/Core.Plugins.OxyPlot/Forms/ChartDataView.cs (.../ChartDataView.cs) (revision bc5cd9c379afef6f6f3fc02f8a890f240fd3fe65)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/Forms/ChartDataView.cs (.../ChartDataView.cs) (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -1,14 +1,21 @@
using System.Windows.Forms;
using Core.Common.Controls.Views;
using Core.Components.OxyPlot;
+using Core.Components.OxyPlot.Data;
namespace Core.Plugins.OxyPlot.Forms
{
+ ///
+ /// This class represents a simple view with a chart, to which data can be added.
+ ///
public class ChartDataView : UserControl, IView
{
private readonly BaseChart baseChart;
- private ChartData data;
+ private IChartData data;
+ ///
+ /// Creates an instance of with just a on it.
+ ///
public ChartDataView()
{
baseChart = new BaseChart
@@ -27,7 +34,7 @@
set
{
baseChart.ClearData();
- data = (ChartData) value;
+ data = (IChartData) value;
if (data != null)
{
baseChart.AddData(data);
Index: Core/Plugins/src/Core.Plugins.OxyPlot/OpenChartViewCommand.cs
===================================================================
diff -u -rbc5cd9c379afef6f6f3fc02f8a890f240fd3fe65 -r4ea1323ca52ee52133113dbc01bae0429946d0d4
--- Core/Plugins/src/Core.Plugins.OxyPlot/OpenChartViewCommand.cs (.../OpenChartViewCommand.cs) (revision bc5cd9c379afef6f6f3fc02f8a890f240fd3fe65)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/OpenChartViewCommand.cs (.../OpenChartViewCommand.cs) (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -1,7 +1,7 @@
using System;
using System.Collections.ObjectModel;
using Core.Common.Gui;
-using Core.Components.OxyPlot;
+using Core.Components.OxyPlot.Data;
namespace Core.Plugins.OxyPlot
{
@@ -26,13 +26,25 @@
public void Execute(params object[] arguments)
{
- ChartData line = new ChartData(new Collection>
+ var line = new LineData(new Collection>
{
new Tuple(0.0, 1.1),
new Tuple(1.0, 2.1),
new Tuple(1.6, 1.6)
});
- Gui.DocumentViewsResolver.OpenViewForData(line);
+ var area = new AreaData(new Collection>
+ {
+ new Tuple(0.0, 1.1),
+ new Tuple(1.0, 2.1),
+ new Tuple(1.6, 1.6),
+ new Tuple(1.6, 0.5),
+ new Tuple(0.0, 0.5),
+ new Tuple(0.0, 1.1)
+ });
+ var data = new CollectionData();
+ data.Add(area);
+ data.Add(line);
+ Gui.DocumentViewsResolver.OpenViewForData(data);
}
}
}
\ No newline at end of file
Index: Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs
===================================================================
diff -u -rb7ca402d4388054a86a27c5f76fc81d53afc2461 -r4ea1323ca52ee52133113dbc01bae0429946d0d4
--- Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs (.../OxyPlotGuiPlugin.cs) (revision b7ca402d4388054a86a27c5f76fc81d53afc2461)
+++ Core/Plugins/src/Core.Plugins.OxyPlot/OxyPlotGuiPlugin.cs (.../OxyPlotGuiPlugin.cs) (revision 4ea1323ca52ee52133113dbc01bae0429946d0d4)
@@ -2,7 +2,7 @@
using Core.Common.Gui;
using Core.Common.Gui.Forms;
using Core.Common.Gui.Plugin;
-using Core.Components.OxyPlot;
+using Core.Components.OxyPlot.Data;
using Core.Plugins.OxyPlot.Forms;
using Core.Plugins.OxyPlot.Properties;
@@ -22,7 +22,7 @@
public override IEnumerable GetViewInfoObjects()
{
- yield return new ViewInfo
+ yield return new ViewInfo
{
Image = Resources.ChartIcon,
GetViewName = (v, o) => "Diagram"