Exemple #1
0
        /// <summary>
        /// 创建直线源
        /// </summary>
        /// <param name="name"></param>线条标示
        /// <param name="lineColor"></param>线条颜色 eg: Brushs.red
        /// <param name="lineWidth"></param>线条宽度
        /// <param name="pointColor"></param>关键点颜色
        /// <param name="pointSize"></param>关键点大小
        /// <returns></returns>
        public s_Line AddLine(string name, SolidColorBrush lineColor, uint lineWidth, SolidColorBrush pointColor, uint pointSize)
        {
            s_Line line = new s_Line();

            ObservableDataSource <Point> dataSource = new ObservableDataSource <Point>();

            LineAndMarker <ElementMarkerPointsGraph> chart = new LineAndMarker <ElementMarkerPointsGraph>();


            chart = Plot.AddLineGraph(dataSource,
                                      new Pen(lineColor, lineWidth),
                                      new CircleElementPointMarker
            {
                Size  = pointSize,
                Brush = pointColor,
                Fill  = pointColor
            },
                                      new PenDescription(name));


            line.chart  = chart;
            line.source = dataSource;

            return(line);
        }
Exemple #2
0
        public MainWindow()
        {
            _configFilename = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "RoboConfig.xml");
            Configuration.Load(_configFilename);
            InitializeComponent();
            cursorCoordinateGraph.Visibility = System.Windows.Visibility.Hidden;
            plotter.Children.Add(cursorCoordinateGraph);

            var lRegressionGraph = plotter.AddLineGraph(ViewModel.RegressionData, new Pen(Brushes.LightGreen, 2), new PenDescription("L.Regression"));
            var stepsGraph       = plotter.AddLineGraph(ViewModel.StepsData, new Pen(Brushes.Orange, 2), new PenDescription("Steps by Clustering"));

            _editableGraph = plotter.AddLineGraph(ViewModel.ActualData,
                                                  new Pen(Brushes.Violet, 2),
                                                  new CirclePointMarker
            {
                Size = 6,
                Fill = Brushes.Violet,
                Pen  = new Pen(Brushes.BlueViolet, 2),
            },
                                                  new PenDescription("Sync Difference"));
            var baselineGraph = plotter.AddLineGraph(ViewModel.BaselineData, new Pen(Brushes.DodgerBlue, 2), new PenDescription("Baseline"));

            stepsGraph.SetBinding(LineGraph.VisibilityProperty, new Binding("ShowStepGraph")
            {
                Converter = new BooleanToVisibilityConverter()
            });
            lRegressionGraph.SetBinding(LineGraph.VisibilityProperty, new Binding("ShowLinearRegressionGraph")
            {
                Converter = new BooleanToVisibilityConverter()
            });
            baselineGraph.SetBinding(LineGraph.VisibilityProperty, new Binding("ShowBaselineGraph")
            {
                Converter = new BooleanToVisibilityConverter()
            });
        }
Exemple #3
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();
        }
        public void EditGraph()
        {
            ObservableDataSource <Trade> source = new ObservableDataSource <Trade>(_listOfTrade);

            source.SetXMapping(c => c.Counter);
            source.SetYMapping(d => d.Price);

            ObservableDataSource <Trade> sourceMarker = new ObservableDataSource <Trade>(_listMarker);

            sourceMarker.SetXMapping(c => c.Counter);
            sourceMarker.SetYMapping(d => d.Price);

            plotter.AddLineGraph(source, new Pen(Brushes.Gold, 3), new PenDescription("chart"));

            LineAndMarker <MarkerPointsGraph> chartMarkerBuy = plotter.AddLineGraph(
                sourceMarker,
                new Pen(Brushes.Red, 3),
                new TrianglePointMarker {
                Size = 5, Fill = Brushes.Blue
            },
                new PenDescription("marker"));

            //chartMarkerBuy.LineGraph.DataSource = null;

            plotter.Viewport.FitToView();
        }
        private void BtnLineLengthStart_Click(object sender, RoutedEventArgs e)            //线长检测开始
        {
            plotter.Children.Remove(graph);
            data      = LoadData();
            ArgShort  = Convert.ToDouble(textBoxShort.Text);    //短趋势时间参数
            ArgLong   = Convert.ToDouble(textBoxLong.Text);     //长趋势时间参数
            ArgDetect = Convert.ToDouble(textBoxDetect.Text);   //阈值

            double inter = data[1, 0] - data[0, 0];

            shortNum = (int)(ArgShort / inter);
            longNum  = (int)(ArgLong / inter);
            start    = longNum;

            detecflag = 1;                                    //检测方式标志置1

            timer.Interval  = TimeSpan.FromMilliseconds(1);
            timer.Tick     += new EventHandler(AnimatedPlot); //连续执行AnimatedPlot 事件实时绘制新坐标点
            timer.IsEnabled = true;
            timer.Start();

            graph  = plotter.AddLineGraph(dataSource, Colors.Green, 2, "data curves");
            graph1 = plotter.AddLineGraph(dataSource1,
                                          new Pen(Brushes.Red, 0),
                                          new CirclePointMarker {
                Size = 3.0, Fill = Brushes.Red
            },
                                          new PenDescription("LineLength"));
            plotter.Legend.Remove();
            plotter.Viewport.FitToView();
        }
 public void initChart(Pen pen, string desp)
 {
     lm = chart1st.AddLineGraph(dtsChart1st,
                                pen,
                                new CirclePointMarker {
         Size = 2.0, Fill = pen.Brush
     },
                                new PenDescription(desp));
     //chart1st.Viewport.Visible = new Rect(new System.Windows.Point(400, 4096), new System.Windows.Point(1020, 0));
 }
 public void initChart(string desp)
 {
     //chart1st.AddLineGraph(dtsChart1st, Colors.DeepSkyBlue, 2, "Sin");
     lm = chart1st.AddLineGraph(dtsChart1st,
                                new System.Windows.Media.Pen(Brushes.Yellow, 2),
                                new CirclePointMarker {
         Size = 2.0, Fill = Brushes.Yellow
     },
                                new PenDescription(desp));
     //chart1st.Viewport.Visible = new Rect(new System.Windows.Point(400, 4096), new System.Windows.Point(1020, 0));
 }
Exemple #8
0
        /// <summary>
        /// add new line graph
        /// </summary>
        /// <param name="name">line graph name</param>
        /// <param name="datasource">graph data source </param>
        /// <param name="pen">pen color</param>
        /// <param name="isShow">is show at beginning</param>
        public void AddLineGraph(string name, TwoDimensionViewPointCollection datasource, Pen pen, bool isShow)
        {
            CheckBox newCheckBox = new CheckBox();

            newCheckBox.Content    = name;
            newCheckBox.IsChecked  = isShow;
            newCheckBox.Foreground = pen.Brush;
            lb_main.Items.Add(newCheckBox);

            LineAndMarker <ElementMarkerPointsGraph> line = AppendLineGraph(datasource, pen, name);
            Binding binding = new Binding("IsChecked")
            {
                Converter = new BoolToVisibilityConverter(),
                Mode      = BindingMode.OneWay,
                Source    = newCheckBox
            };

            line.LineGraph.SetBinding(LineGraph.VisibilityProperty, binding);
            line.MarkerGraph.SetBinding(LineGraph.VisibilityProperty, binding);
        }
Exemple #9
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();
        }
		public Window1()
		{
			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
			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();
		}
        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
            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();
        }
        private void BtnBandPassStart_Click(object sender, RoutedEventArgs e)       //带通检测开始
        {
            plotter.Children.Remove(graph);
            data = LoadData();
            //读取文本框参数

            tmin      = 1 / Convert.ToDouble(textBoxMaxFre.Text);   //半波的最小周期,对应最大频率Maximum Frequency
            tmax      = 1 / Convert.ToDouble(textBoxMinFre.Text);   //半波的最大周期,对应最小频率Minimum Frequency
            minAmpPer = Convert.ToDouble(textBoxMinAmp.Text) / 100; //最小的有效幅值百分比,对应Minimum Amplitude(% of full scale)
            durBp     = Convert.ToDouble(textMiniDurBp.Text);       //计算带通的时长,对应Minimum Duration

            double inter = data[1, 0] - data[0, 0];

            longNum  = (int)(durBp / inter);
            shortNum = longNum / 2;

            detecflag = 3;                                    //检测方式标志置3

            timer.Interval = TimeSpan.FromMilliseconds(1);

            timer.Tick += new EventHandler(AnimatedPlot);    //连续执行AnimatedPlot 事件实时绘制新坐标点
            graph       = plotter.AddLineGraph(dataSource, Colors.Green, 2, "data curves");


            graph3 = plotter.AddLineGraph(dataSource3,
                                          new Pen(Brushes.Yellow, 0),
                                          new CirclePointMarker {
                Size = 3.0, Fill = Brushes.Yellow
            },
                                          new PenDescription("BandPass"));

            timer.IsEnabled = true;

            plotter.Legend.Remove();

            plotter.Viewport.FitToView();
            timer.Start();
        }
Exemple #13
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();
        }
Exemple #14
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;
		}
Exemple #15
0
        private void OnLineGraphsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case System.Collections.Specialized.NotifyCollectionChangedAction.Add:
            {
                foreach (LinePerturbationViewModel viewModel in e.NewItems)
                {
                    if (viewModel.LineAndMarker)
                    {
                        SolidColorBrush brush = new SolidColorBrush();
                        brush.Color = viewModel.Color;
                        LineAndMarker <MarkerPointsGraph> lineAndMarker = this.AddLineGraph(viewModel.PointDataSource, new Pen(brush, viewModel.Thickness), new CirclePointMarker {
                                Size = 7, Fill = brush
                            }, new PenDescription(viewModel.Name));
                        lineAndMarker.LineGraph.Name = viewModel.Name;
                        this.lineAndMarkerGraphs.Add(lineAndMarker);
                    }
                    else
                    {
                        LineGraph lineGraph = this.AddLineGraph(viewModel.PointDataSource, viewModel.Color, viewModel.Thickness, viewModel.Name);
                        lineGraph.Name = viewModel.Name;
                        this.lineGraphLines.Add(lineGraph);
                    }
                }

                break;
            }

            case System.Collections.Specialized.NotifyCollectionChangedAction.Move:
            {
                break;
            }

            case System.Collections.Specialized.NotifyCollectionChangedAction.Remove:
            {
                break;
            }

            case System.Collections.Specialized.NotifyCollectionChangedAction.Replace:
            {
                bool bTemp = false;
                foreach (LinePerturbationViewModel viewModel in e.NewItems)
                {
                    foreach (LineGraph line in this.lineGraphLines)
                    {
                        if (this.Children.Contains(line) && line.Name == viewModel.Name)
                        {
                            this.Children.Remove(line);
                            this.lineGraphLines.Remove(line);
                            bTemp = true;
                            break;
                        }
                    }

                    foreach (LineAndMarker <MarkerPointsGraph> line in this.lineAndMarkerGraphs)
                    {
                        if (this.Children.Contains(line.LineGraph) && line.LineGraph.Name == viewModel.Name)
                        {
                            this.Children.Remove(line.LineGraph);
                            this.Children.Remove(line.MarkerGraph);
                            this.lineAndMarkerGraphs.Remove(line);
                            bTemp = true;
                            break;
                        }
                    }

                    if (bTemp)
                    {
                        if (viewModel.LineAndMarker)
                        {
                            SolidColorBrush brush = new SolidColorBrush();
                            brush.Color = viewModel.Color;
                            LineAndMarker <MarkerPointsGraph> lineAndMarker = this.AddLineGraph(viewModel.PointDataSource, new Pen(brush, viewModel.Thickness), new CirclePointMarker {
                                    Size = 7, Fill = brush
                                }, new PenDescription(viewModel.Name));
                            lineAndMarker.LineGraph.Name = viewModel.Name;
                            this.lineAndMarkerGraphs.Add(lineAndMarker);
                        }
                        else
                        {
                            LineGraph lineGraph = this.AddLineGraph(viewModel.PointDataSource, viewModel.Color, viewModel.Thickness, viewModel.Name);
                            lineGraph.Name = viewModel.Name;
                            this.lineGraphLines.Add(lineGraph);
                        }

                        bTemp = false;
                    }
                }

                break;
            }

            case System.Collections.Specialized.NotifyCollectionChangedAction.Reset:
            {
                break;
            }
            }
        }