Exemplo n.º 1
0
		public void TestViewportContentBounds()
		{
			ChartPlotter plotter = new ChartPlotter();
			TempIPlotterElement element = new TempIPlotterElement();
			plotter.Children.Add(element);
			plotter.PerformLoad();
			plotter.Viewport.ClipToBoundsEnlargeFactor = 1.0;

			Assert.AreEqual(new DataRect(0, 0, 1, 1), plotter.Visible);

			Viewport2D.SetContentBounds(element, new DataRect(0, 0, 2, 2));

			Assert.AreEqual(new DataRect(0, 0, 2, 2), plotter.Visible);

			plotter.Children.Remove(element);

			Assert.AreEqual(new DataRect(0, 0, 1, 1), plotter.Visible);

			plotter.Children.Add(element);

			Assert.AreEqual(new DataRect(0, 0, 2, 2), plotter.Visible);

			Viewport2D.SetIsContentBoundsHost(element, false);

			Assert.AreEqual(new DataRect(0, 0, 1, 1), plotter.Visible);
		}
Exemplo n.º 2
0
		static void Main(string[] args)
		{
			ChartPlotter plotter = new ChartPlotter();
			plotter.PerformLoad();
			plotter.Background = Brushes.Transparent;
			plotter.SaveScreenshot("1.png");
		}
Exemplo n.º 3
0
		public LineChartTest()
		{
			chart = new LineChart();
			chart.DataSource = new TestDataSource();

			ChartPlotter plotter = new ChartPlotter();
			plotter.PerformLoad();
			plotter.Children.Add(chart);

			PrivateObject privateObject = new PrivateObject(chart);
			LineChart_Accessor target = new LineChart_Accessor(privateObject);

			canvas = target.canvas;

			paths = canvas.Children.Cast<Path>();
		}
		public void TestAddAndRemoveItems()
		{
			ChartPlotter plotter = new ChartPlotter();
			plotter.PerformLoad();

			DevMarkerChart chart = new DevMarkerChart();
			chart.MarkerBuilder = new EllipseMarker();

			plotter.Children.Add(chart);

			ObservableCollection<Point> source = new ObservableCollection<Point>();
			chart.ItemsSource = source;

			const int count = 10;

			// stage 1
			for (int i = 0; i < count; i++)
			{
				source.Add(new Point());
				Assert.AreEqual(source.Count, chart.Items.Count);
			}

			for (int i = count - 1; i >= 0; i--)
			{
				source.RemoveAt(i);
				Assert.AreEqual(source.Count, chart.Items.Count);
			}


			// stage 2
			for (int i = 0; i < count; i++)
			{
				source.Add(new Point());
				Assert.AreEqual(source.Count, chart.Items.Count);
			}

			Random rnd = new Random();
			for (int i = count - 1; i >= 0; i--)
			{
				int index = rnd.Next(0, source.Count - 1);
				source.RemoveAt(index);
				Assert.AreEqual(source.Count, chart.Items.Count);
			}

			// todo check that all items are visible
		}
Exemplo n.º 5
0
		public void VerticalAxisIsDefaultTest()
		{
			ChartPlotter plotter = new ChartPlotter();
			plotter.PerformLoad();

			VerticalAxis axis = (VerticalAxis)plotter.MainVerticalAxis;
			VerticalAxis axis2 = new VerticalAxis();
			plotter.Children.Add(axis2);

			Assert.AreEqual(plotter.MainVerticalAxis, axis);
			Assert.IsTrue(axis.IsDefaultAxis);

			axis2.IsDefaultAxis = true;
			Assert.AreEqual(plotter.MainVerticalAxis, axis2);
			Assert.IsFalse(axis.IsDefaultAxis);

			axis.IsDefaultAxis = true;
			Assert.AreEqual(plotter.MainVerticalAxis, axis);
			Assert.IsFalse(axis2.IsDefaultAxis);
		}
Exemplo n.º 6
0
		public void HorizontalAxisIsDefaultTest()
		{
			ChartPlotter plotter = new ChartPlotter();
			plotter.PerformLoad();

			HorizontalAxis axis = (HorizontalAxis)plotter.MainHorizontalAxis;
			HorizontalAxis axis2 = new HorizontalAxis();
			plotter.Children.Add(axis2);

			Assert.AreEqual(plotter.MainHorizontalAxis, axis);
			Assert.IsTrue(axis.IsDefaultAxis);
			Assert.AreEqual(2, plotter.Children.OfType<HorizontalAxis>().Count());

			axis2.IsDefaultAxis = true;
			Assert.AreEqual(axis2, plotter.MainHorizontalAxis);
			Assert.IsFalse(axis.IsDefaultAxis);

			axis.IsDefaultAxis = true;
			Assert.AreEqual(plotter.MainHorizontalAxis, axis);
			Assert.IsFalse(axis2.IsDefaultAxis);
		}
Exemplo n.º 7
0
		public void TestAllElementsAddRemove()
		{
			ChartPlotter plotter = new ChartPlotter();
			plotter.PerformLoad();

			var types = GetAllCharts();

			var withoutCtor = from type in types
							  let ctors = type.GetConstructors()
							  let noParameterlessCtor = (from c in ctors
														 let p = c.GetParameters()
														 select p).All(p => p.Length >= 1)
							  where noParameterlessCtor
							  select type;

			var plotterElements = new List<IPlotterElement>();
			plotter.Children.Clear();
			foreach (var type in types)
			{
				IPlotterElement element = (IPlotterElement)Activator.CreateInstance(type);
				plotterElements.Add(element);
				plotter.Children.Add(element);
			}

			foreach (var item in plotterElements)
			{
				Assert.AreEqual(plotter, item.Plotter);
			}

			plotter.Children.Clear();
			plotter.Wait(DispatcherPriority.Background);

			foreach (var item in plotterElements)
			{
				Assert.IsNull(item.Plotter, item.ToString());
			}
		}
Exemplo n.º 8
0
		public void CheckThatSegmentHasProperPlotter()
		{
			ChartPlotter plotter = new ChartPlotter();
			plotter.PerformLoad();
			Segment segment = new Segment();

			plotter.Children.Add(segment);

			Assert.AreEqual(plotter, segment.Plotter);
		}
Exemplo n.º 9
0
		public void CheckThatSegmentHasNullPlotterAfterDisconnection()
		{
			ChartPlotter plotter = new ChartPlotter();
			Segment segment = new Segment();

			plotter.Children.Add(segment);
			plotter.PerformLoad();
			plotter.Wait(DispatcherPriority.Background);

			plotter.Children.Remove(segment);
			plotter.Wait(DispatcherPriority.Background);

			Assert.IsNull(segment.Plotter);
		}
Exemplo n.º 10
0
		public void RemovingWhileViewportChange()
		{
			ChartPlotter plotter = new ChartPlotter();
			HorizontalAxis axis = new HorizontalAxis();
			plotter.Children.Add(axis);

			plotter.PerformLoad();

			plotter.Viewport.Visible = new DataRect(2, 3, 4, 5);
			plotter.Children.Remove(axis);

			plotter.Wait(DispatcherPriority.Background);
		}