예제 #1
0
        private void plotData(Collection <StockData> list, Brush pen, String Description, ChartPlotter graph)
        {
            if (propertyChanger.Graphs.Any(x => x.Description.Full.Equals(Description)))
            {
                return;
            }

            IPointDataSource point = null;
            LineGraph        line;


            EnumerableDataSource <StockData> _edsSPP;

            _edsSPP = new EnumerableDataSource <StockData>(list);


            _edsSPP.SetXMapping(p => dateAxis.ConvertToDouble(p.date));
            _edsSPP.SetYMapping(p => p.value);
            point = _edsSPP;

            line             = new LineGraph(point);
            line.LinePen     = new Pen(pen, 2);
            line.Description = new PenDescription(Description);

            line.Visibility = Visibility.Hidden;

            propertyChanger.Graphs.Add(line);

            graph.Children.Add(line);
            graph.FitToView();
        }
예제 #2
0
        /// <summary>
        /// Adds one dimensional graph.
        /// </summary>
        /// <param name="pointSource">The point source.</param>
        /// <param name="description">The description.</param>
        /// <returns></returns>
        public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, string description)
        {
            LineGraph graph = AddLineGraph(plotter, pointSource);

            graph.Description = new PenDescription(description);
            return(graph);
        }
예제 #3
0
        public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, Pen linePen, Description description)
        {
            if (pointSource == null)
            {
                throw new ArgumentNullException("pointSource");
            }
            if (linePen == null)
            {
                throw new ArgumentNullException("linePen");
            }

            LineGraph graph = new LineGraph
            {
                DataSource = pointSource,
                LinePen    = linePen
            };

            if (description != null)
            {
                NewLegend.SetDescription(graph, description.Brief);
                graph.Description = description;
            }
            // graph.Filters.Add(new InclinationFilter());
            graph.Filters.Add(new FrequencyFilter());
            plotter.Children.Add(graph);
            return(graph);
        }
예제 #4
0
		private void DetachDataSource(IPointDataSource source)
		{
			if (source != null)
			{
				source.DataChanged -= OnDataChanged;
			}
		}
예제 #5
0
        public bool Tap(CGPoint tapContentLocation, IChartView chartView, IPointDataSource pointDataSource, IPointHighlightHandler highlightHandler, IXAxis xAxis, IYAxis yAxis)
        {
            double sourcePositionStart = xAxis.GetSourceValue(tapContentLocation.X - TapDistance);

            var sourcePositionEnd = xAxis.GetSourceValue(tapContentLocation.X + TapDistance);

            var entriesInTapRange = pointDataSource
                                    .GetEntriesInRange(sourcePositionStart, sourcePositionEnd)
                                    .Select((IPointEntry entry) => new { Entry = entry, Distance = GetDistance(tapContentLocation, entry, xAxis, yAxis) })
                                    .Where((t) => t.Distance <= TapDistance)
                                    .OrderBy(p => p.Distance);

            var entryNearestToTap = entriesInTapRange.FirstOrDefault();

            if (entryNearestToTap != null)
            {
                highlightHandler.TapOnEntries(Multiselect ? entriesInTapRange.Select(t => t.Entry) : new List <IPointEntry> {
                    entryNearestToTap.Entry
                });
            }
            else
            {
                highlightHandler.TapOnNoEntry();
            }

            return(entryNearestToTap != null);
        }
예제 #6
0
        /// <summary>
        /// 显示曲线图表
        /// </summary>
        /// <param name="vm"></param>
        private void ShowCurve(WeightCurveViewModel vm)
        {
            DateTime[] dates      = (from r in vm.WeightCurveDataList select DateTime.Parse(r.recordtime)).ToArray();
            decimal[]  weightList = (from r in vm.WeightCurveDataList select r.recorddata).ToArray();

            var xDataSource = new EnumerableDataSource <DateTime>(dates);

            xDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x));

            var yDataSource = new EnumerableDataSource <decimal>(weightList);

            yDataSource.SetYMapping(y => Convert.ToDouble(y));
            yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, Y => String.Format("{0}", Y));

            ds = new CompositeDataSource(xDataSource, yDataSource);
            plotter.Children.RemoveAll(typeof(LineGraph));
            plotter.Children.RemoveAll(typeof(MarkerPointsGraph));
            plotter.Children.RemoveAll(typeof(ElementMarkerPointsGraph));
            plotter.Children.RemoveAll(typeof(Microsoft.Research.DynamicDataDisplay.Charts.Navigation.CursorCoordinateGraph));
            chart = plotter.AddLineGraph(ds,
                                         new Pen(Brushes.LimeGreen, 2),
                                         new CircleElementPointMarker
            {
                Size  = 5,
                Brush = Brushes.Red,
                Fill  = Brushes.Orange,
                Pen   = new Pen(Brushes.Blue, 5)
            },
                                         new PenDescription("重量曲线"));
            plotter.Children.Add(new CursorCoordinateGraph());
            plotter.FitToView();
        }
예제 #7
0
 private void DetachDataSource(IPointDataSource source)
 {
     if (source != null)
     {
         source.DataChanged -= OnDataChanged;
     }
 }
		/// <summary>
		/// Adds one dimensional graph.
		/// </summary>
		/// <param name="pointSource">The point source.</param>
		/// <param name="description">The description.</param>
		/// <returns></returns>
		public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, string description)
		{
			LineGraph graph = AddLineGraph(plotter, pointSource);
			graph.Description = new PenDescription(description);
			NewLegend.SetDescription(graph, description);
			return graph;
		}
		/// <summary>
		/// Adds data part.
		/// </summary>
		/// <param name="dataPart">The data part.</param>
		public void AddDataPart(IPointDataSource dataPart) {
			if (dataPart == null)
				throw new ArgumentNullException("dataPart");

			dataParts.Add(dataPart);
			dataPart.DataChanged += OnPartDataChanged;
		}
예제 #10
0
 private void UpdateBounds(IPointDataSource dataSource)
 {
     if (Plotter2D != null & dataSource != null)
     {
         var  transform = GetTransform();
         Rect bounds    = BoundsHelper.GetViewportBounds(dataSource.GetPoints(), transform.DataTransform);
         ContentBounds = bounds;
     }
 }
예제 #11
0
        /// <summary>
        /// Adds one dimensional graph.
        /// </summary>
        /// <param name="pointSource">The point source.</param>
        /// <param name="lineThickness">The line thickness.</param>
        /// <param name="description">The description.</param>
        /// <returns></returns>
        public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, double lineThickness, string description)
        {
            var res = AddLineGraph(plotter, pointSource,
                                   new Pen(new SolidColorBrush(ColorHelper.CreateRandomHsbColor()), lineThickness),
                                   (PointMarker)null,
                                   new PenDescription(description));

            return(res.LineGraph);
        }
예제 #12
0
        private void VisitEnumerable(IPointDataSource dataSource)
        {
            var xDataPart = dataSource as EnumerableXDataSource <THorizontal>;

            Visit(xDataPart);
            var yDataPart = dataSource as EnumerableYDataSource <TVertical>;

            Visit(yDataPart);
        }
예제 #13
0
 /// <summary>
 /// Create a linegraph using specific datasource and description
 /// </summary>
 /// <param name="pointSource">Data source</param>
 /// <param name="description">Description shown in legend</param>
 public LineGraph(IPointDataSource pointSource, string description)
     : this()
 {
     DataSource = pointSource;
     Settings   = new LineGraphSettings()
     {
         Description = description
     };
 }
예제 #14
0
 private void UpdateBounds(IPointDataSource dataSource)
 {
     if (Plotter2D != null)
     {
         var      transform = GetTransform();
         DataRect bounds    = BoundsHelper.GetViewportBounds(dataSource.GetPoints(), transform.DataTransform);
         Viewport2D.SetContentBounds(this, bounds);
     }
 }
        /// <summary>
        /// Adds data part.
        /// </summary>
        /// <param name="dataPart">The data part.</param>
        public void AddDataPart(IPointDataSource dataPart)
        {
            if (dataPart == null)
            {
                throw new ArgumentNullException("dataPart");
            }

            dataParts.Add(dataPart);
            dataPart.DataChanged += OnPartDataChanged;
        }
예제 #16
0
        protected virtual void OnDataSourceChanged(DependencyPropertyChangedEventArgs args)
        {
            IPointDataSource newDataSource = (IPointDataSource)args.NewValue;

            if (newDataSource != null)
            {
                UpdateBounds(newDataSource);
            }

            Update();
        }
예제 #17
0
        private void Visit(IPointDataSource dataSource)
        {
            if (dataSource == null)
            {
                return;
            }

            CompositeDataSource compositeDS = dataSource as CompositeDataSource;

            Visit(compositeDS);
            VisitEnumerable(dataSource);
        }
예제 #18
0
        protected override void OnChildAdded(IPlotterElement child)
        {
            base.OnChildAdded(child);

            IOneDimensionalChart chart = child as IOneDimensionalChart;

            if (chart != null)
            {
                chart.DataChanged += OnOneDimensionalChart_DataChanged;
                IPointDataSource dataSource = chart.DataSource;
                Visit(dataSource);
            }
        }
예제 #19
0
        private void drawGraphic(List <Point> pointsOfFunction, string description)
        {
            EnumerableDataSource <Point> enumerableDataSource = new EnumerableDataSource <Point>(pointsOfFunction);

            enumerableDataSource.SetXMapping(u => u.X);
            enumerableDataSource.SetYMapping(u => u.Y);
            IPointDataSource iPointDataSource = enumerableDataSource;

            graphic.AddLineGraph(iPointDataSource, new Pen(new SolidColorBrush(Colors.Brown), 1.5), new CirclePointMarker {
                Size = 8.0
            }, new PenDescription(description));
            graphic.FitToView();
        }
예제 #20
0
        private void OnDataSourceReplaced(IPointDataSource prevDataSource, IPointDataSource currDataSource)
        {
            if (prevDataSource != null)
            {
                prevDataSource.DataChanged -= OnDataChanged;
            }

            if (currDataSource != null)
            {
                currDataSource.DataChanged += OnDataChanged;
            }
            Update();
        }
예제 #21
0
		private void Window_Loaded(object sender, RoutedEventArgs e)
		{
			image.Source = d3dimage;
			Initialize();

			EnumerableDataSource<double> xSrc = new EnumerableDataSource<double>(animatedX);
			xSrc.SetXMapping(x => x);
			var yDS = new EnumerableDataSource<double>(animatedY);
			yDS.SetYMapping(y => y);
			animatedDataSource = new CompositeDataSource(xSrc, yDS);

			timer.Interval = TimeSpan.FromMilliseconds(10);
			timer.Tick += new EventHandler(timer_Tick);
			timer.Start();
		}
예제 #22
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            image.Source = d3dimage;
            Initialize();

            EnumerableDataSource <double> xSrc = new EnumerableDataSource <double>(animatedX);

            xSrc.SetXMapping(x => x);
            var yDS = new EnumerableDataSource <double>(animatedY);

            yDS.SetYMapping(y => y);
            animatedDataSource = new CompositeDataSource(xSrc, yDS);

            timer.Interval = TimeSpan.FromMilliseconds(10);
            timer.Tick    += new EventHandler(timer_Tick);
            timer.Start();
        }
예제 #23
0
		public SampleLine()
		{
			EnumerableDataSource<double> xSrc = new EnumerableDataSource<double>(animatedX);
			xSrc.SetXMapping(x => x);
			var yDS = new EnumerableDataSource<double>(animatedY);
			yDS.SetYMapping(y => y);
			animatedDataSource = new CompositeDataSource(xSrc, yDS);

			timer.Interval = TimeSpan.FromMilliseconds(10);
			timer.Tick += new EventHandler(timer_Tick);
			timer.Start();

			camera.FieldOfView = (float)(Math.PI / 4);
			camera.NearPlane = 0.0f;
			camera.FarPlane = 40.0f;
			camera.Location = new Vector3(0.0f, 7.0f, 20.0f);
			camera.Target = Vector3.Zero;
		}
예제 #24
0
        protected virtual void OnDataSourceChanged(DependencyPropertyChangedEventArgs args)
        {
            IPointDataSource newDataSource = (IPointDataSource)args.NewValue;

            if (device != null)
            {
                UpdateBounds(DataSource);

                var vertices = from p in DataSource.GetPoints() select new VertexPosition {
                    Vertex = new Vector3F((float)p.X, (float)p.Y, 0)
                };
                count        = vertices.Count();
                vertexBuffer = BufferHelper.CreateBuffer <VertexPosition>(device, vertices.ToArray());
                deviceContext.IA.SetVertexBuffers(0, new D3DBuffer[] { vertexBuffer }, new uint[] { VertexPosition.Size }, new uint[] { 0 });

                Update();
            }
        }
예제 #25
0
        private void plotBuyEvent(Collection <StockData> list)
        {
            IPointDataSource  point  = null;
            CirclePointMarker marker = new CirclePointMarker();

            EnumerableDataSource <StockData> _edsSPP;

            _edsSPP = new EnumerableDataSource <StockData>(list);
            _edsSPP.SetXMapping(p => dateAxis.ConvertToDouble(p.date));
            _edsSPP.SetYMapping(p => p.value);
            point = _edsSPP;

            BuyMarkerGraph.DataSource = point;

            marker.Size           = 10;
            marker.Fill           = new SolidColorBrush(Colors.Blue);
            marker.Pen            = new Pen(new SolidColorBrush(Colors.Black), 2.0);
            BuyMarkerGraph.Marker = marker;
        }
예제 #26
0
        public void DrawPlot(CGContext context, IPointDataSource dataSource, IEnumerable <IPointEntry> highlightedEntries, IViewPort viewPort, IXAxis xAxis, IYAxis yAxis)
        {
            var visibleSourceRange = VisibleSourceXRange(xAxis, viewPort);

            var visibleSourceRangeStart = Math.Floor(visibleSourceRange.Item1);

            var visibleSourceRangeEnd = Math.Ceiling(visibleSourceRange.Item2);

            if (Style.BezierCurve)
            {//для отображения кривых нужны дополнительные точки для рассчета опорных точек
             //TODO учитывать масштаб
                visibleSourceRangeStart--;
                visibleSourceRangeEnd++;
            }

            var visibleEntries = dataSource.GetEntriesInRange(visibleSourceRangeStart, visibleSourceRangeEnd);

            Draw(context, visibleEntries, highlightedEntries, viewPort, xAxis, yAxis, Style);
        }
예제 #27
0
        public static IEnumerable<Point> GetPoints(IPointDataSource dataSource, DependencyObject context)
        {
            if (dataSource == null)
                throw new ArgumentNullException("dataSource");

            if (context == null)
                context = Context.EmptyContext;

            using (IPointEnumerator enumerator = dataSource.GetEnumerator(context))
            {
                Point p = new Point();
                while (enumerator.MoveNext())
                {
                    enumerator.GetCurrent(ref p);
                    yield return p;
                    p = new Point();
                }
            }
        }
예제 #28
0
        public SampleLine()
        {
            EnumerableDataSource <double> xSrc = new EnumerableDataSource <double>(animatedX);

            xSrc.SetXMapping(x => x);
            var yDS = new EnumerableDataSource <double>(animatedY);

            yDS.SetYMapping(y => y);
            animatedDataSource = new CompositeDataSource(xSrc, yDS);

            timer.Interval = TimeSpan.FromMilliseconds(10);
            timer.Tick    += new EventHandler(timer_Tick);
            timer.Start();

            camera.FieldOfView = (float)(Math.PI / 4);
            camera.NearPlane   = 0.0f;
            camera.FarPlane    = 40.0f;
            camera.Location    = new Vector3(0.0f, 7.0f, 20.0f);
            camera.Target      = Vector3.Zero;
        }
예제 #29
0
		public TooltipSample()
		{
			InitializeComponent();

			// Prepare data in arrays
			for (int i = 0; i < N; i++)
			{
				x[i] = i * 0.2;
				y[i] = Math.Cos(x[i]);
			}

			// Add data sources:
			yDataSource = new EnumerableDataSource<double>(y);
			yDataSource.SetYMapping(Y => Y);
			yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty,
				Y => String.Format("Value is {0}", Y));

			xDataSource = new EnumerableDataSource<double>(x);
			xDataSource.SetXMapping(X => X);


			ds = new CompositeDataSource(xDataSource, yDataSource);
			// adding graph to plotter
			// todo
			//chart = plotter.AddLineGraph(ds,
			//    new Pen(Brushes.LimeGreen, 3),
			//    new CircleElementPointMarker
			//    {
			//        Size = 10,
			//        Brush = Brushes.Red,
			//        Fill = Brushes.Orange
			//    },
			//    new PenDescription("Cosine"));

			plotter.Children.Add(new CursorCoordinateGraph());

			// Force evertyhing plotted to be visible
			plotter.FitToView();
		}
예제 #30
0
        public TooltipSample()
        {
            InitializeComponent();

            // Prepare data in arrays
            for (int i = 0; i < N; i++)
            {
                x[i] = i * 0.2;
                y[i] = Math.Cos(x[i]);
            }

            // Add data sources:
            yDataSource = new EnumerableDataSource <double>(y);
            yDataSource.SetYMapping(Y => Y);
            yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty,
                                   Y => String.Format("Value is {0}", Y));

            xDataSource = new EnumerableDataSource <double>(x);
            xDataSource.SetXMapping(X => X);


            ds = new CompositeDataSource(xDataSource, yDataSource);
            // adding graph to plotter
            // todo
            //chart = plotter.AddLineGraph(ds,
            //    new Pen(Brushes.LimeGreen, 3),
            //    new CircleElementPointMarker
            //    {
            //        Size = 10,
            //        Brush = Brushes.Red,
            //        Fill = Brushes.Orange
            //    },
            //    new PenDescription("Cosine"));

            plotter.Children.Add(new CursorCoordinateGraph());

            // Force evertyhing plotted to be visible
            plotter.FitToView();
        }
예제 #31
0
        private void dataSource(List <CurrencyInfo> rates)
        {
            EnumerableDataSource <CurrencyInfo> xDataSource = new EnumerableDataSource <CurrencyInfo>(rates);
            EnumerableDataSource <CurrencyInfo> yDataSource = new EnumerableDataSource <CurrencyInfo>(rates);

            yDataSource.SetYMapping(y => y.BidPrice);
            yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, y => String.Format("BidPrice is {0}", y.BidPrice));
            xDataSource.SetXMapping(x => x.CurrentTime);
            ds    = new CompositeDataSource(xDataSource, yDataSource);
            chart = plotter.AddLineGraph(ds,
                                         new Pen(Brushes.LimeGreen, 1),
                                         new CircleElementPointMarker
            {
                Size  = 5,
                Brush = Brushes.Red,
                Fill  = Brushes.Orange
            },
                                         new PenDescription("BidPrice"));

            plotter.Children.Add(new CursorCoordinateGraph());
            plotter.FitToView();
        }
예제 #32
0
        private void OnDataSourceChanged(IPointDataSource oldDataSource, IPointDataSource currentDataSource)
        {
            if (oldDataSource != null)
            {
                oldDataSource.Changed -= OnDataSourceChangedEvent;
                INotifyCollectionChanged observableCollection = oldDataSource as INotifyCollectionChanged;
                if (observableCollection != null)
                {
                    observableCollection.CollectionChanged -= observableCollection_CollectionChanged;
                }
            }

            if (currentDataSource != null)
            {
                currentDataSource.Changed += OnDataSourceChangedEvent;
                INotifyCollectionChanged observableCollection = currentDataSource as INotifyCollectionChanged;
                if (observableCollection != null)
                {
                    observableCollection.CollectionChanged += observableCollection_CollectionChanged;
                }
            }

            DependencyObject oldDependencyDataSource     = oldDataSource as DependencyObject;
            DependencyObject currentDependencyDataSource = currentDataSource as DependencyObject;

            hasContinousDataSource = currentDependencyDataSource != null;

            if (oldDependencyDataSource != null && currentDependencyDataSource == null && currentDataSource != null)
            {
                Viewport2D.SetIsContentBoundsHost(this, true);
            }
            else if (oldDependencyDataSource == null && currentDependencyDataSource != null)
            {
                Viewport2D.SetIsContentBoundsHost(this, false);
            }

            UpdateUIRepresentation();
        }
예제 #33
0
        public static IEnumerable <Point> GetPoints(IPointDataSource dataSource, DependencyObject context)
        {
            if (dataSource == null)
            {
                yield break;
            }

            if (context == null)
            {
                context = new DataSource2dContext();
            }

            using (IPointEnumerator enumerator = dataSource.GetEnumerator(context))
            {
                Point p = new Point();
                while (enumerator.MoveNext())
                {
                    enumerator.GetCurrent(ref p);
                    yield return(p);

                    p = new Point();
                }
            }
        }
예제 #34
0
        private void Initialize()
        {
            this.dataTable = new DataTable();
            this.dataTable.Columns.Add("t");
            this.dataTable.Columns.Add("τ(t)");

            for (int i = 0; i < this.data.Count; i++)
            {
                this.dataTable.Rows.Add(new TableRow());
                this.dataTable.Rows[i][0] = string.Format("{0:0.000}", this.data.ElementAt(i).Key);
                this.dataTable.Rows[i][1] = string.Format("{0:0.0000000}", this.data.ElementAt(i).Value);
            }

            this.dataGrid.ItemsSource = this.dataTable.DefaultView;

            List <Point> dataPoints = new List <Point>();

            foreach (var item in this.data)
            {
                dataPoints.Add(new Point(item.Key, item.Value));
            }

            ClearLines();

            EnumerableDataSource <Point> eds = new EnumerableDataSource <Point>(dataPoints);

            eds.SetXMapping(p => p.X);
            eds.SetYMapping(p => p.Y);
            IPointDataSource ipds = eds;

            LineGraph line = new LineGraph(ipds);

            line.LinePen = new Pen(Brushes.Black, 2);
            plotter.Children.Add(line);
            plotter.FitToView();
        }
예제 #35
0
        public static IEnumerable <Point> GetPoints(IPointDataSource dataSource, DependencyObject context)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource");
            }

            if (context == null)
            {
                context = Context.EmptyContext;
            }

            using (IPointEnumerator enumerator = dataSource.GetEnumerator(context))
            {
                Point p = new Point();
                while (enumerator.MoveNext())
                {
                    enumerator.GetCurrent(ref p);
                    yield return(p);

                    p = new Point();
                }
            }
        }
예제 #36
0
        private void dataSource1(List <Record> rates)
        {
            EnumerableDataSource <Record> xDataSource = new EnumerableDataSource <Record>(rates);
            EnumerableDataSource <Record> yDataSource = new EnumerableDataSource <Record>(rates);

            yDataSource.SetYMapping(y => y.BidPrices[0]);
            yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, y => String.Format("BidPrice is {0}", y.BidPrices[0]));
            xDataSource.SetXMapping(x => dateAxisBidP.ConvertToDouble(x.Time));
            xDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, x => String.Format("Time is {0}", x.Time.ToString(CultureInfo.InvariantCulture)));
            ds    = new CompositeDataSource(xDataSource, yDataSource);
            chart = plotter.AddLineGraph(ds,
                                         new Pen(Brushes.LimeGreen, 3),
                                         new CircleElementPointMarker
            {
                Size  = 5,
                Brush = Brushes.Red,
                Fill  = Brushes.Orange
            },

                                         new PenDescription("BidPrice"));

            plotter.Children.Add(new CursorCoordinateGraph());
            //plotter.FitToView();
        }
예제 #37
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MarkerPointsGraph"/> class.
		/// </summary>
		/// <param name="dataSource">The data source.</param>
		public ElementMarkerPointsGraph(IPointDataSource dataSource)
		{
			DataSource = dataSource;
		}
예제 #38
0
		/// <summary>
		/// Initializes a new instance of the <see cref="MarkerPointsGraph"/> class.
		/// </summary>
		/// <param name="dataSource">The data source.</param>
		public MarkerPointsGraph(IPointDataSource dataSource)
			: this()
		{
			DataSource = dataSource;
		}
예제 #39
0
 private void UpdateBounds(IPointDataSource dataSource)
 {
     if (Plotter2D != null & dataSource!=null)
     {
         var transform = GetTransform();
         Rect bounds = BoundsHelper.GetViewportBounds(dataSource.GetPoints(), transform.DataTransform);
         ContentBounds = bounds;
     }
 }
예제 #40
0
		private void UpdateBounds(IPointDataSource dataSource)
		{
			if (Plotter2D != null)
			{
				var transform = GetTransform();
				DataRect bounds = BoundsHelper.GetViewportBounds(dataSource.GetPoints(), transform.DataTransform);
				Viewport2D.SetContentBounds(this, bounds);
			}
		}
예제 #41
0
		/// <summary>
		/// Adds one dimensional graph.
		/// </summary>
		/// <param name="pointSource">The point source.</param>
		/// <param name="lineColor">Color of the line.</param>
		/// <param name="lineThickness">The line thickness.</param>
		/// <param name="description">Description of data</param>
		/// <returns></returns>
		public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, Color lineColor, double lineThickness,
			string description)
		{
			return AddLineGraph(plotter, pointSource, new Pen(new SolidColorBrush(lineColor), lineThickness), new PenDescription(description));
		}
예제 #42
0
		/// <summary>
		/// Adds one dimensional graph with random color if line.
		/// </summary>
		/// <param name="pointSource">The point source.</param>
		/// <param name="lineThickness">The line thickness.</param>
		/// <returns></returns>
		public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, double lineThickness)
		{
			return AddLineGraph(plotter, pointSource, ColorHelper.CreateRandomHsbColor(), lineThickness);
		}
예제 #43
0
		/// <summary>
		/// Adds one dimensional graph with specified color of line.
		/// </summary>
		/// <param name="pointSource">The point source.</param>
		/// <param name="lineColor">Color of the line.</param>
		/// <returns></returns>
		public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, Color lineColor)
		{
			return AddLineGraph(plotter, pointSource, lineColor, 1);
		}
예제 #44
0
 /// <summary>
 /// Create a linegraph using specific datasource and settings
 /// </summary>
 /// <param name="pointSource">Data source</param>
 /// <param name="settings">Graph visual settings</param>
 public LineGraph(IPointDataSource pointSource,LineGraphSettings settings)
     : this()
 {
     this.Settings = settings;
     DataSource = pointSource;
 }
예제 #45
0
		/// <summary>
		/// Initializes a new instance of the <see cref="LineGraph"/> class.
		/// </summary>
		/// <param name="pointSource">The point source.</param>
		public LineGraph(IPointDataSource pointSource)
			: this()
		{
			DataSource = pointSource;
		}
예제 #46
0
 /// <summary>
 /// Create a linegraph using specific datasource and settings
 /// </summary>
 /// <param name="pointSource">Data source</param>
 /// <param name="settings">Graph visual settings</param>
 public LineGraph(IPointDataSource pointSource, LineGraphSettings settings)
     : this()
 {
     this.Settings = settings;
     DataSource    = pointSource;
 }
예제 #47
0
		/// <summary>
		/// Adds one dimensional graph.
		/// </summary>
		/// <param name="pointSource">The point source.</param>
		/// <param name="lineColor">Color of the line.</param>
		/// <param name="lineThickness">The line thickness.</param>
		/// <returns></returns>
		public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, Color lineColor, double lineThickness)
		{
			return AddLineGraph(plotter, pointSource, new Pen(new SolidColorBrush(lineColor), lineThickness), null);
		}
예제 #48
0
		/// <summary>
		/// Adds one dimensional graph.
		/// </summary>
		/// <param name="pointSource">The point source.</param>
		/// <param name="lineThickness">The line thickness.</param>
		/// <param name="description">The description.</param>
		/// <returns></returns>
		public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, double lineThickness, string description)
		{
			var res = AddLineGraph(plotter, pointSource,
				new Pen(new SolidColorBrush(ColorHelper.CreateRandomHsbColor()), lineThickness),
				(PointMarker)null,
				new PenDescription(description));

			return res.LineGraph;
		}
예제 #49
0
 /// <summary>
 /// Create a linegraph using specific datasource and description
 /// </summary>
 /// <param name="pointSource">Data source</param>
 /// <param name="description">Description shown in legend</param>
 public LineGraph(IPointDataSource pointSource,string description)
     : this()
 {
     DataSource = pointSource;
     Settings = new LineGraphSettings() { Description = description};
 }
예제 #50
0
		public static LineAndMarker<ElementMarkerPointsGraph> AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource,
				Pen linePen, ElementPointMarker marker, Description description)
		{
			if (pointSource == null)
				throw new ArgumentNullException("pointSource");

			var res = new LineAndMarker<ElementMarkerPointsGraph>();



			if (linePen != null) // We are requested to draw line graphs
			{
				LineGraph graph = new LineGraph
				{
					DataSource = pointSource,
					LinePen = linePen
				};
				if (description != null)
				{
					graph.Description = description;
				}
				if (marker == null)
				{
					// Add inclination filter only to graphs without markers
					graph.Filters.Add(new InclinationFilter());
				}

				graph.Filters.Add(new FrequencyFilter());
				//graph.Filters.Add(new CountFilter());

				res.LineGraph = graph;

				plotter.Children.Add(graph);
			}

			if (marker != null) // We are requested to draw marker graphs
			{
				ElementMarkerPointsGraph markerGraph = new ElementMarkerPointsGraph
				{
					DataSource = pointSource,
					Marker = marker
				};

				res.MarkerGraph = markerGraph;

				plotter.Children.Add(markerGraph);
			}

			return res;
		}
예제 #51
0
 public static IEnumerable<Point> GetPoints(IPointDataSource dataSource)
 {
     return GetPoints(dataSource, null);
 }
예제 #52
0
		private void OnDataSourceReplaced(IPointDataSource prevDataSource, IPointDataSource currDataSource)
		{
			if (prevDataSource != null)
			{
				prevDataSource.DataChanged -= OnDataChanged;
			}

			if (currDataSource != null)
			{
				currDataSource.DataChanged += OnDataChanged;
			}
			Update();
		}
예제 #53
0
		public static LineGraph AddLineGraph(this Plotter2D plotter, IPointDataSource pointSource, Pen linePen, Description description)
		{
			if (pointSource == null)
				throw new ArgumentNullException("pointSource");
			if (linePen == null)
				throw new ArgumentNullException("linePen");

			LineGraph graph = new LineGraph
			{
				DataSource = pointSource,
				LinePen = linePen
			};
			if (description != null)
			{
				graph.Description = description;
			}
			graph.Filters.Add(new InclinationFilter());
			graph.Filters.Add(new FrequencyFilter());
			//graph.Filters.Add(new CountFilter());
			plotter.Children.Add(graph);
			return graph;
		}