Index: Core/Components/src/Core.Components.OxyPlot.Forms/BaseChart.cs =================================================================== diff -u -r18a617da943368e8294aa31528d2e2379d7318cc -r002ceaccea1dc8e92d6e88d41dd39b1f5d7b7e0d --- Core/Components/src/Core.Components.OxyPlot.Forms/BaseChart.cs (.../BaseChart.cs) (revision 18a617da943368e8294aa31528d2e2379d7318cc) +++ Core/Components/src/Core.Components.OxyPlot.Forms/BaseChart.cs (.../BaseChart.cs) (revision 002ceaccea1dc8e92d6e88d41dd39b1f5d7b7e0d) @@ -79,6 +79,7 @@ view.Model.Series.Add(series); } } + view.InvalidatePlot(true); } #region IChart @@ -133,7 +134,6 @@ public void UpdateObserver() { DrawSeries(); - view.InvalidatePlot(true); } #endregion Index: Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs =================================================================== diff -u -r74cd1965818ae9b23da6cad8776b7da2868be4a7 -r002ceaccea1dc8e92d6e88d41dd39b1f5d7b7e0d --- Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs (.../LinearPlotView.cs) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7) +++ Core/Components/src/Core.Components.OxyPlot.Forms/LinearPlotView.cs (.../LinearPlotView.cs) (revision 002ceaccea1dc8e92d6e88d41dd39b1f5d7b7e0d) @@ -1,4 +1,5 @@ -using System.Windows.Forms; +using System; +using System.Windows.Forms; using Core.Components.OxyPlot.Forms.Properties; using OxyPlot; using OxyPlot.Axes; @@ -26,9 +27,24 @@ CreateAxis(Resources.BaseChart_YAxisTitle, AxisPosition.Left) } }; + + Invalidated += OnInvalidated; } + private void OnInvalidated(object sender, EventArgs e) + { + FixateZoom(); + } + /// + /// Performs a 'fake' zoom, so that the view is not updated when series are hidden or shown. + /// + private void FixateZoom() + { + ActualModel.ZoomAllAxes(1.0); + } + + /// /// Creates an axis with default style set. /// /// The title of the . Index: Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj =================================================================== diff -u -r74cd1965818ae9b23da6cad8776b7da2868be4a7 -r002ceaccea1dc8e92d6e88d41dd39b1f5d7b7e0d --- Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj (.../Core.Components.Charting.Test.csproj) (revision 74cd1965818ae9b23da6cad8776b7da2868be4a7) +++ Core/Components/test/Core.Components.Charting.Test/Core.Components.Charting.Test.csproj (.../Core.Components.Charting.Test.csproj) (revision 002ceaccea1dc8e92d6e88d41dd39b1f5d7b7e0d) @@ -50,6 +50,7 @@ + @@ -61,6 +62,10 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + {516EBC95-B8F2-428C-B7F6-733F01BF8FDD} Core.Components.Charting Index: Core/Components/test/Core.Components.Charting.Test/Data/PointBasedChartDataTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.Charting.Test/Data/PointBasedChartDataTest.cs (revision 0) +++ Core/Components/test/Core.Components.Charting.Test/Data/PointBasedChartDataTest.cs (revision 002ceaccea1dc8e92d6e88d41dd39b1f5d7b7e0d) @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using Core.Common.TestUtil; +using Core.Components.Charting.Data; +using NUnit.Framework; + +namespace Core.Components.Charting.Test.Data +{ + public class PointBasedChartDataTest + { + [Test] + public void Constructor_WithoutPoints_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new TestPointBasedChartData(null); + + // Assert + var expectedMessage = "A point collection is required when creating a subclass of Core.Components.Charting.Data.PointBasedChartData."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void Constructor_WithPoints_PropertiesSet() + { + // Setup + var points = new Collection> + { + Tuple.Create(0.0, 1.0), + Tuple.Create(2.5, 1.1) + }; + + // Call + var data = new TestPointBasedChartData(points); + + // Assert + Assert.AreNotSame(points, data.Points); + CollectionAssert.AreEqual(points, data.Points); + Assert.IsTrue(data.IsVisible); + } + } + + public class TestPointBasedChartData : PointBasedChartData + { + public TestPointBasedChartData(IEnumerable> points) : base(points) { } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs =================================================================== diff -u -r27d5f613022c7304f82f755e4e2faefe8c3bbeb0 -r002ceaccea1dc8e92d6e88d41dd39b1f5d7b7e0d --- Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision 27d5f613022c7304f82f755e4e2faefe8c3bbeb0) +++ Core/Components/test/Core.Components.OxyPlot.Forms.Test/LinearPlotViewTest.cs (.../LinearPlotViewTest.cs) (revision 002ceaccea1dc8e92d6e88d41dd39b1f5d7b7e0d) @@ -1,11 +1,9 @@ using System.Linq; using System.Windows.Forms; -using Core.Common.TestUtil; using NUnit.Framework; using OxyPlot; using OxyPlot.Axes; using Core.Components.OxyPlot.Forms.Properties; -using OxyPlot.Series; using OxyPlot.WindowsForms; using TickStyle = OxyPlot.Axes.TickStyle; @@ -38,88 +36,22 @@ } [Test] - public void ZoomToAll_ViewInForm_AxesAreSetToOriginal() + public void ZoomToAll_ViewInForm_InvalidatesView() { // Setup - var view = new LinearPlotView - { - Dock = DockStyle.Fill - }; - view.Model.Series.Add(new LineSeries - { - Points = - { - new DataPoint(0,0), - new DataPoint(10,10) - } - }); + var form = new Form(); + var view = new LinearPlotView(); + form.Controls.Add(view); + var invalidated = 0; + view.Invalidated += (sender, args) => invalidated++; - WindowsFormsTestHelper.Show(view, f => - { - view.Model.ZoomAllAxes(1.2); + form.Show(); - // Preconditions - Assert.Greater(10, view.Model.Axes[0].ActualMaximum); - Assert.Less(0, view.Model.Axes[0].ActualMinimum); - Assert.Greater(10, view.Model.Axes[1].ActualMaximum); - Assert.Less(0, view.Model.Axes[1].ActualMinimum); + // Call + view.ZoomToAll(); - // Call - view.ZoomToAll(); - - // Assert - Assert.AreEqual(10.1, view.Model.Axes[0].ActualMaximum, 1e-3); - Assert.AreEqual(-0.1, view.Model.Axes[0].ActualMinimum, 1e-3); - Assert.AreEqual(10.1, view.Model.Axes[1].ActualMaximum, 1e-3); - Assert.AreEqual(-0.1, view.Model.Axes[1].ActualMinimum, 1e-3); - }); - WindowsFormsTestHelper.CloseAll(); + // Assert + Assert.AreEqual(1, invalidated); } - - [Test] - public void ZoomToAll_ViewInFormSerieVisibilityUpdated_AxesAreUpdated() - { - // Setup - var view = new LinearPlotView - { - Dock = DockStyle.Fill, - Padding = new Padding(0) - }; - var lineSeries = new LineSeries - { - Points = - { - new DataPoint(0, 0), - new DataPoint(5, 5) - } - }; - var lineSeriesToBeUpdated = new LineSeries - { - Points = - { - new DataPoint(5, 5), - new DataPoint(10, 10) - } - }; - view.Model.Series.Add(lineSeries); - view.Model.Series.Add(lineSeriesToBeUpdated); - - WindowsFormsTestHelper.Show(view, f => - { - lineSeriesToBeUpdated.IsVisible = false; - view.InvalidatePlot(true); - view.Refresh(); - - // Call - view.ZoomToAll(); - - // Assert - Assert.AreEqual(5.05, view.Model.Axes[0].ActualMaximum, 1e-3); - Assert.AreEqual(-0.05, view.Model.Axes[0].ActualMinimum, 1e-3); - Assert.AreEqual(5.05, view.Model.Axes[1].ActualMaximum, 1e-3); - Assert.AreEqual(-0.05, view.Model.Axes[1].ActualMinimum, 1e-3); - }); - WindowsFormsTestHelper.CloseAll(); - } } } \ No newline at end of file Index: Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendController.cs =================================================================== diff -u -rfc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8 -r002ceaccea1dc8e92d6e88d41dd39b1f5d7b7e0d --- Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendController.cs (.../LegendController.cs) (revision fc0a61c81da4dcf9f436c8b8bd9c51c6b4d65ef8) +++ Core/Plugins/src/Core.Plugins.OxyPlot/Legend/LegendController.cs (.../LegendController.cs) (revision 002ceaccea1dc8e92d6e88d41dd39b1f5d7b7e0d) @@ -74,7 +74,7 @@ /// /// Updates the data for the if it is open. /// - /// The for which to show data. If null the + /// The for which to show data. If null the /// data will be cleared. public void Update(ChartData data) {