示例#1
0
        void OptionPricePlotView_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            for (int i = 0; i < plotter.Children.Count; i++)
            {
                if (plotter.Children[i].GetType() == typeof(LineGraph))
                {
                    plotter.Children.RemoveAt(i);
                    i--;
                }
            }
            foreach (List <double> linePlot in PlotsItemsControl.Items)
            {
                RingArray <OptionPricePoint> pricePoints = new RingArray <OptionPricePoint>(linePlot.Count);
                for (int t = 0; t < linePlot.Count; t++)
                {
                    pricePoints.Add(new OptionPricePoint(t, linePlot[t]));
                }
                EnumerableDataSource <OptionPricePoint> linePlotData = new EnumerableDataSource <OptionPricePoint>(pricePoints);
                linePlotData.SetXMapping(x => x.Time);
                linePlotData.SetYMapping(y => y.Price);

                plotter.AddLineGraph(linePlotData);
            }
            plotter.LegendVisible = false;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < animatedX.Length; i++)
            {
                animatedX[i] = 2 * Math.PI * i / animatedX.Length;
                animatedY[i] = Math.Sin(animatedX[i]);
            }
            EnumerableDataSource <double> xSrc = new EnumerableDataSource <double>(animatedX);

            xSrc.SetXMapping(x => x);
            animatedDataSource = new EnumerableDataSource <double>(animatedY);
            animatedDataSource.SetYMapping(y => y);

            // Adding graph to plotter
            plotter.AddLineGraph(new CompositeDataSource(xSrc, animatedDataSource),
                                 new Pen(Brushes.Magenta, 3),
                                 new PenDescription("Sin(x + phase)"));

            timer.Interval  = TimeSpan.FromMilliseconds(10);
            timer.Tick     += AnimatedPlot_Timer;
            timer.IsEnabled = true;

            // Force evertyhing plotted to be visible
            plotter.FitToView();
        }
		private EnumerableDataSource<CurrencyInfo> CreateCurrencyDataSource(List<CurrencyInfo> rates)
		{
			EnumerableDataSource<CurrencyInfo> ds = new EnumerableDataSource<CurrencyInfo>(rates);
			ds.SetXMapping(ci => dateAxis.ConvertToDouble(ci.Date));
			ds.SetYMapping(ci => ci.Rate);
			return ds;
		}
        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();
        }
示例#5
0
        void RefreshPeaksGraph()
        {
            Part_Plotter.Children.Remove(m_peaksGraph);
            m_peaksGraph = null;

            var data = this.ViewModel.CurrentDataItem?.DataItem;

            if (data != null && data.LocatedPeaks != null)
            {
                EnumerableDataSource <PeakInfo> locatedPeaksDS = new EnumerableDataSource <PeakInfo>(data.LocatedPeaks);

                locatedPeaksDS.SetXMapping((item) => item.Pos.X);
                locatedPeaksDS.SetYMapping((item) => item.Pos.Y);

                m_peaksGraph = new ElementMarkerPointsGraph(locatedPeaksDS)
                {
                    Marker = new PeaksMarker()
                    {
                        Size = 10, Fill = Brushes.Yellow, ContextMenu = this.TryFindResource("PeakMarkerContextMenu") as ContextMenu
                    }
                    //Marker = new CircleElementPointMarker() { Size = 10, Fill = Brushes.Yellow, ToolTipText = "Jouda" }
                };

                locatedPeaksDS.AddMapping(PeaksMarker.ToolTipTextProperty, (peakInfo) => peakInfo.ArtifactPeakSample.ToString());
                locatedPeaksDS.AddMapping(PeaksMarker.DataContextProperty, (peakInfo) => peakInfo);

                Part_Plotter.Children.Add(m_peaksGraph);
            }

            RefreshSelectedPeakGraph();
            RefreshCalculatedThresholdGraph();

            OrderGraphs();
        }
示例#6
0
    private void CreateCurrencyDataSource() {
      if (IsPlotterInitialised) return;
      dateAxis.MayorLabelProvider = null;
      var ticksProvider = ((Microsoft.Research.DynamicDataDisplay.Charts.TimeTicksProviderBase<System.DateTime>)(dateAxis.TicksProvider));
      ticksProvider.Strategy = new Microsoft.Research.DynamicDataDisplay.Charts.Axes.DateTime.Strategies.DelegateDateTimeStrategy(GetDifference);
      dateAxis.LabelProvider.SetCustomFormatter(info => {
        DifferenceIn differenceIn = (DifferenceIn)info.Info;
        if (differenceIn == DifferenceIn.Hour) {
          return info.Tick.ToString("H:");
        }
        return null;
      });
      dateAxis.LabelProvider.SetCustomView((li, uiElement) => {
        FrameworkElement element = (FrameworkElement)uiElement;
        element.LayoutTransform = new RotateTransform(-90, 0, 0);
      });
      var a = FindName("PART_AdditionalLabelsCanvas");

      #region Plotter
      IsPlotterInitialised = true;
      plotter.Children.RemoveAt(0);
      var verticalAxis = plotter.Children.OfType<VerticalAxis>().First();
      verticalAxis.FontSize = 10;
      verticalAxis.ShowMinorTicks = false;
      innerPlotter.Children.Remove(innerPlotter.Children.OfType<VerticalAxis>().Single());
      plotter.Children.OfType<VerticalAxis>().First().Placement = AxisPlacement.Right;
      #endregion

      #region Add Main Graph
      {

        EnumerableDataSource<DateTime> xSrc = new EnumerableDataSource<DateTime>(animatedTimeX);

        EnumerableDataSource<double> animatedDataSource1 = new EnumerableDataSource<double>(animatedPrice1Y);
        animatedDataSource1.SetYMapping(y => y);
        plotter.AddLineGraph(new CompositeDataSource(xSrc, animatedDataSource1), Colors.DarkGray, 1, "")
          .Description.LegendItem.Visibility = Visibility.Collapsed;

        xSrc.SetXMapping(x => dateAxis.ConvertToDouble(x));
        animatedDataSource = new EnumerableDataSource<double>(animatedPriceY);
        animatedDataSource.SetYMapping(y => y);
        this.PriceLineGraph = plotter.AddLineGraph(new CompositeDataSource(xSrc, animatedDataSource), priceLineGraphColorAsk, 1, "");
        this.PriceLineGraph.Description.LegendItem.Visibility = System.Windows.Visibility.Collapsed;

        if (true) {
          animatedDataSourceBid = new EnumerableDataSource<double>(animatedPriceBidY);
          animatedDataSourceBid.SetYMapping(y => y);
          this.PriceLineGraphBid = plotter.AddLineGraph(new CompositeDataSource(xSrc, animatedDataSourceBid), priceLineGraphColorBid, 1, "");
          this.PriceLineGraphBid.Description.LegendItem.Visibility = Visibility.Collapsed;
        }
      }
      //var ticksLineGraph = plotter.AddLineGraph(Ticks.AsDataSource(), Colors.Black, 1, "1M").Description.LegendItem.Visibility = Visibility.Collapsed;
      #endregion

      plotter.KeyDown += new KeyEventHandler(plotter_KeyDown);




    }
示例#7
0
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = this;

            Comm_Port_Names.Items.Clear();
            string[] ports = SerialPort.GetPortNames();
            foreach (string port in ports)
            {
                Comm_Port_Names.Items.Add(port);
            }
            Connect_btn.Content = "Connect";

            updateCollectionTimer          = new DispatcherTimer();
            updateCollectionTimer.Interval = TimeSpan.FromMilliseconds(0.0001);
            updateCollectionTimer.Tick    += new EventHandler(updateCollectionTimer_Tick);

            updateCollectionTimer2          = new DispatcherTimer();
            updateCollectionTimer2.Interval = TimeSpan.FromMilliseconds(1);
            updateCollectionTimer2.Tick    += new EventHandler(updateCollectionTimer2_Tick);
            voltagePointCollection          = new VoltagePointCollection();
            var ds1 = new EnumerableDataSource <VoltagePoint>(voltagePointCollection);

            ds1.SetXMapping(x => x.time);
            ds1.SetYMapping(y => y.Voltage);

            plotter.AddLineGraph(ds1, Colors.Green, 2, "Raw  Signal");
        }
示例#8
0
        public PolarWindow()
        {
            InitializeComponent();

            grid.Children.Add(plotter);

            const int N    = 100;
            var       rs   = Enumerable.Range(0, N).Select(i => (double)1);
            var       phis = Enumerable.Range(0, N).Select(i => (i * (360.0 / (N - 1)).DegreesToRadians()));

            EnumerableDataSource <double> xs = new EnumerableDataSource <double>(rs);

            xs.SetXMapping(x => x);
            EnumerableDataSource <double> ys = new EnumerableDataSource <double>(phis);

            ys.SetYMapping(y => y);
            CompositeDataSource ds = new CompositeDataSource(xs, ys);

            LineGraph line = new LineGraph();

            line.DataTransform   = new CompositeDataTransform(new PolarToRectTransform(), new RotateDataTransform(0.5, new Point(3, 0)));
            line.Stroke          = Brushes.Blue;
            line.StrokeThickness = 1;
            line.DataSource      = ds;
            plotter.Children.Add(line);
        }
        private void CreateLinearGraphOnRightYAxis(ChartPlotter plotter)
        {
            EnumerableDataSource <TPoint> edsLinear = new EnumerableDataSource <TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                                                 new TPoint
            {
                X = DateTime.Now.AddYears(-20).AddDays(s),
                Y = s
            }
                                                 ).ToList());

            edsLinear.SetXMapping(s => xAxis.ConvertToDouble(s.X));
            edsLinear.SetYMapping(s => s.Y);

            double minData, maxData, M, B;

            GetMinAndMaxForEDS(edsLinear, out minData, out maxData);
            Get_M_and_B(minData, maxData, out M, out B);

            Func <double, double> ConvertToDouble   = s => M * s + B;
            Func <double, double> ConvertFromDouble = t => (t - B) / M;
            Func <Point, Point>   DataToViewport    = s => new Point(s.X, ConvertToDouble(s.Y));
            Func <Point, Point>   ViewportToData    = t => new Point(t.X, ConvertFromDouble(t.Y));

            Brush          brushLinear   = new SolidColorBrush(Colors.Blue);
            Pen            linePenLinear = new Pen(brushLinear, 2.0);
            PenDescription descLinear    = new PenDescription("f(x) = x");
            LineGraph      lg            = plotter.AddLineGraph(edsLinear, linePenLinear, descLinear);

            lg.DataTransform             = new LambdaDataTransform(DataToViewport, ViewportToData);
            yAxisRight.ConvertFromDouble = ConvertFromDouble;
            yAxisRight.ConvertToDouble   = ConvertToDouble;
        }
示例#10
0
        public ObsLLPointDataSource()
        {
            Data = new LinkedList<Point>();
            DataSource = new EnumerableDataSource<Point>(Data);

            DataSource.SetXYMapping(p => p);
        }
示例#11
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Model M = DataContext as Model;

            int i = index;

            EnumerableDataSource <Element> x = new EnumerableDataSource <Element>(M.Elements.Where(var => var.Z.HasValue));

            x.SetXMapping(var => (var.PrintData.Values[i]["PAIR"] + var.PrintData.Values[i]["PSATW"]) / var.PrintData.Values[i]["P"]);
            x.SetYMapping(var => var.Z.Value);
            var lg = Fig1.AddLineGraph(x, 3, "t = " + ((int)Math.Pow(10, i)) + "s");

            graphs.Add(lg);
            Fig1.UpdateLayout();


            EnumerableDataSource <Element> x2 = new EnumerableDataSource <Element>(M.Elements.Where(var => var.Z.HasValue));

            x2.SetXMapping(var => - var.Z.Value);
            x2.SetYMapping(var => var.PrintData.Values[i]["P"] - 101300);
            var lg2 = Fig3.AddLineGraph(x2, 3, "t = " + ((int)Math.Pow(10, i)) + "s");

            graphs.Add(lg2);
            Fig3.UpdateLayout();

            index++;
        }
示例#12
0
        internal void showColumnChart()
        {
            ClearLines();


            List <int>    xAxisSource = new List <int>();
            List <double> yAxisSource = new List <double>();

            int i = 0;

            foreach (JointData joint in this.examData.Data)
            {
                //xAxisSource[i] = joint.DataTime;
                xAxisSource.Add(i);
                yAxisSource.Add(joint.Y);
                i++;
            }

            var xEnumSrc = new EnumerableDataSource <int>(xAxisSource);
            var yEnumSrc = new EnumerableDataSource <double>(yAxisSource);

            //set the mappings

            xEnumSrc.SetXMapping(x => x);
            yEnumSrc.SetYMapping(y => y);

            //combine into CompositeDataSource
            CompositeDataSource compositeSource = new CompositeDataSource(xEnumSrc, yEnumSrc);

            //draw the graph

            plotter.AddLineGraph(compositeSource);
        }
示例#13
0
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            #region Data preparation
            const int N = 200;

            int[] thiknesses = new int[10];

            for (int i = 0; i < 10; i++)
            {
                thiknesses[i] = i + 1;
            }

            Point[] points = new Point[N];
            double  step   = 10 / (double)N;

            for (int i = 0; i < N; i++)
            {
                points[i].X = -5 + i * step;
                points[i].Y = Math.Exp(points[i].X);
            }

            EnumerableDataSource <Point> dataSource = points.AsDataSource <Point>();
            dataSource.SetXYMapping(point => point);
            #endregion

            graph = new LineGraph(dataSource, "Graph Description");
            graph.LineThickness = 3;
            graph.LineColor     = Colors.Red;


            MainPlotter.Children.Add(graph);
            MainPlotter.FitToView();

            TextBoxDescription.Text = graph.Description;
        }
示例#14
0
        private void DrawChart()
        {
            var xpoints = new int[_visitedPoints.Count];
            var ypoints = new int[_visitedPoints.Count];
            var times = new int[_visitedPoints.Count];
            for (int i = 0; i < times.Length; i++)
            {
                times[i] = i;
                xpoints[i] = (int) _visitedPoints[i].Position.X;
                ypoints[i] = (int) _visitedPoints[i].Position.Y;
            }

            var timesDataSource = new EnumerableDataSource<int>(times);
            timesDataSource.SetXMapping(x => timeAxis.ConvertToDouble(x));

            var xPointsDataSource = new EnumerableDataSource<int>(xpoints);
            xPointsDataSource.SetYMapping(y => Convert.ToInt32(y));

            var yPointsDataSource = new EnumerableDataSource<int>(ypoints);
            yPointsDataSource.SetYMapping(y => Convert.ToInt32(y));

            var compositeDataSource1 = new CompositeDataSource(xPointsDataSource, timesDataSource);
            var compositeDataSource2 = new CompositeDataSource(yPointsDataSource, timesDataSource);

            plotter.AddLineGraph(compositeDataSource1,
                                 new Pen(Brushes.GreenYellow, 2),
                                 new CirclePointMarker {Size = 10.0, Fill = Brushes.Red},
                                 new PenDescription("x/t"));
            plotter.AddLineGraph(compositeDataSource2,
                                 new Pen(Brushes.Gold, 2),
                                 new CirclePointMarker {Size = 10.0, Fill = Brushes.DodgerBlue},
                                 new PenDescription("y/t"));

            plotter.Viewport.FitToView();
        }
示例#15
0
        public Window1()
        {
            InitializeComponent();

            Content = plot;

            plot.MainHorizontalAxis = axis;

            const int N = 10;

            double[]   x    = new double[N];
            double[]   y    = new double[N];
            DateTime[] date = new DateTime[N];

            for (int i = 0; i < N; i++)
            {
                x[i]    = i * 0.1;
                y[i]    = Math.Sin(x[i]);
                date[i] = DateTime.Now.AddMinutes(-N + i);
            }

            EnumerableDataSource <double> xs = new EnumerableDataSource <double>(x);

            xs.SetYMapping(_x => _x);
            EnumerableDataSource <DateTime> ys = new EnumerableDataSource <DateTime>(date);

            ys.SetXMapping(axis.ConvertToDouble);

            CompositeDataSource ds = new CompositeDataSource(xs, ys);

            plot.AddLineGraph(ds);
        }
示例#16
0
        void LogYWindow_Loaded(object sender, RoutedEventArgs e)
        {
            ChartPlotter plotter = new ChartPlotter();

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

            plotter.DataTransform = new Log10YTransform();
            VerticalAxis axis = new VerticalAxis
            {
                TicksProvider = new LogarithmNumericTicksProvider(10),
                LabelProvider = new UnroundingLabelProvider()
            };

            plotter.MainVerticalAxis = axis;

            plotter.AxisGrid.DrawVerticalMinorTicks = true;

            const int count = 500;

            double[] xs = Enumerable.Range(1, count).Select(x => x * 0.01).ToArray();
            EnumerableDataSource <double> xDS = xs.AsXDataSource();

            var pows        = xs.Select(x => Math.Pow(10, x));
            var linear      = xs.Select(x => x);
            var logXs       = Enumerable.Range(101, count).Select(x => x * 0.01);
            var logarithmic = logXs.Select(x => Math.Log10(x));

            plotter.AddLineGraph(pows.AsYDataSource().Join(xDS), "f(x) = 10^x");
            plotter.AddLineGraph(linear.AsYDataSource().Join(xDS), "f(x) = x");
            plotter.AddLineGraph(logarithmic.AsYDataSource().Join(logXs.AsXDataSource()), "f(x) = log(x)");

            Content = plotter;
        }
示例#17
0
        private void Initialize()
        {
            _dataTable = new DataTable();
            _dataTable.Columns.Add("x");
            _dataTable.Columns.Add("f(x)");

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

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

                dataPoints.Add(new Point(_data.ElementAt(i).Key, _data.ElementAt(i).Value));
            }

            dataGrid.ItemsSource = _dataTable.DefaultView;
            ClearLines();

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

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

            LineGraph line = new LineGraph(eds);

            line.LinePen = new Pen(Brushes.Black, 2);
            plotter.Children.Add(line);
            plotter.FitToView();
        }
示例#18
0
        void RefreshStimuliStartsGraph()
        {
            Part_Plotter.Children.Remove(m_stimuliStartsGraph);
            m_stimuliStartsGraph = null;

            var data = this.ViewModel.CurrentDataItem?.DataItem;

            if (data != null && data.Sweeps != null)
            {
                EnumerableDataSource <Sweep> peaksDS = new EnumerableDataSource <Sweep>(data.Sweeps);

                peaksDS.SetXMapping((item) => item.StimulusInfo.Start.X);
                peaksDS.SetYMapping((item) => item.StimulusInfo.Start.Y);

                m_stimuliStartsGraph = new ElementMarkerPointsGraph(peaksDS)
                {
                    Marker = new RectElementPointMarker()
                    {
                        Size = 10, Pen = new Pen(Brushes.Violet, 1)
                    }
                };

                Part_Plotter.Children.Add(m_stimuliStartsGraph);

                OrderGraphs();
            }
        }
示例#19
0
        void PlantView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            foreach (var g in _extGraphs)
            {
                ExtGraph.Children.Remove(g);
            }
            _extGraphs.Clear();

            foreach (var g in _wells)
            {
                ExtGraph.Children.Remove(g);
            }
            _wells.Clear();



            PlantViewModel P = e.NewValue as PlantViewModel;

            if (P != null)
            {
                EnumerableDataSource <Time.Core.TimestampValue> ds = new EnumerableDataSource <TimestampValue>(P.plant.Extractions.AsTimeStamps);
                ds.SetXMapping(var => dateAxis.ConvertToDouble(var.Time));
                ds.SetYMapping(var => var.Value);
                _extGraphs.Add(ExtGraph.AddLineGraph(ds, new Pen(Brushes.Black, 3), new PenDescription("Groundwater")));

                if (P.plant.SurfaceWaterExtrations.Items.Count > 0)
                {
                    EnumerableDataSource <Time.Core.TimestampValue> ds2 = new EnumerableDataSource <TimestampValue>(P.plant.SurfaceWaterExtrations.AsTimeStamps);
                    ds2.SetXMapping(var => dateAxis.ConvertToDouble(var.Time));
                    ds2.SetYMapping(var => var.Value);
                    _extGraphs.Add(ExtGraph.AddLineGraph(ds2, new Pen(Brushes.Red, 3), new PenDescription("Surface water")));
                }
            }
            ZoomToTimeScale();
        }
示例#20
0
        private void CreatePowGraphOnLeftYAxis(ChartPlotter plotter)
        {
            EnumerableDataSource <TPoint> edsPow = new EnumerableDataSource <TPoint>(
                Enumerable.Range(1, 2000).Select(s =>
                                                 new TPoint
            {
                X = DateTime.Now.AddYears(-20).AddDays(s),
                Y = Math.Pow(10, s / 700.0)
            }
                                                 ).ToList());

            edsPow.SetXMapping(s => xAxis.ConvertToDouble(s.X));
            edsPow.SetYMapping(s => s.Y);

            double minData, maxData, M, B;

            GetMinAndMaxForEDS(edsPow, out minData, out maxData);
            Get_M_and_B(Math.Floor(Math.Log10(minData)), Math.Ceiling(Math.Log10(maxData)), out M, out B);

            Func <double, double> ConvertToDouble = s => M *Math.Log10(s) + B;

            Func <double, double> ConvertFromDouble = t => Math.Pow(10.0, (t - B) / M);
            Func <Point, Point>   DataToViewport    = s => new Point(s.X, ConvertToDouble(s.Y));
            Func <Point, Point>   ViewportToData    = t => new Point(t.X, ConvertFromDouble(t.Y));

            Brush          brushPow   = new SolidColorBrush(Colors.Green);
            Pen            linePenPow = new Pen(brushPow, 2.0);
            PenDescription descPow    = new PenDescription("f(x) = 10 ^ x");
            LineGraph      lg         = plotter.AddLineGraph(edsPow, linePenPow, descPow);

            lg.DataTransform            = new LambdaDataTransform(DataToViewport, ViewportToData);
            yAxisLeft.ConvertFromDouble = ConvertFromDouble;
            yAxisLeft.ConvertToDouble   = ConvertToDouble;
        }
示例#21
0
        //DispatcherTimer updateCollectionTimer;

        public MainWindow()
        {
            //var kkkj = NewDate(1536953206336);
            //var kkkj1 = NewDate(1537245622622);
            //var kkkj2 = NewDate(1537245622828);

            InitializeComponent();
            this.WindowState = System.Windows.WindowState.Maximized;
            this.DataContext = this;

            generalPointCollection = new VoltagePointCollection();
            historyPointCollection = new VoltagePointCollection();
            //updateCollectionTimer = new DispatcherTimer();
            //updateCollectionTimer.Interval = TimeSpan.FromMilliseconds(100);
            //updateCollectionTimer.Tick += new EventHandler(updateCollectionTimer_Tick);
            //updateCollectionTimer.Start();

            var ds = new EnumerableDataSource <VoltagePoint>(generalPointCollection);

            ds.SetXMapping(x => generaldateAxis.ConvertToDouble(x.Date));
            ds.SetYMapping(y => y.Voltage);
            generalplotter.AddLineGraph(ds, Colors.Green, 2, "Volts");// to use this method you need "using Microsoft.Research.DynamicDataDisplay;"

            MaxVoltage = -2;
            MinVoltage = -2;

            var ds1 = new EnumerableDataSource <VoltagePoint>(historyPointCollection);

            ds1.SetXMapping(x => historydateAxis.ConvertToDouble(x.Date));
            ds1.SetYMapping(y => y.Voltage);
            historyplotter.AddLineGraph(ds1, Colors.Green, 2, "Volts");
        }
示例#22
0
        /// <summary>
        /// 俯视图
        /// </summary>
        public void DrawV()
        {
            var ds = getDisList(LDesignPoint);
            var fs = getDisList(LFlyPoint);

            plotter.RemoveUserElements();

            var yDataSource = new EnumerableDataSource <PolylinePoint>(ds);

            yDataSource.SetYMapping(y => y.Y);
            var xDataSource = new EnumerableDataSource <PolylinePoint>(ds);

            xDataSource.SetXMapping(lx => lx.X);
            CompositeDataSource compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

            var y1DataSource = new EnumerableDataSource <PolylinePoint>(fs);

            y1DataSource.SetYMapping(y => y.Y);
            var x1DataSource = new EnumerableDataSource <PolylinePoint>(fs);

            y1DataSource.SetXMapping(lx => lx.X);

            CompositeDataSource compositeDataSource1 = new CompositeDataSource(x1DataSource, y1DataSource);

            plotter.AddLineGraph(compositeDataSource,
                                 new Pen(Brushes.OrangeRed, 2),
                                 new PenDescription("设计航线"));
            plotter.AddLineGraph(compositeDataSource1,
                                 new Pen(Brushes.GreenYellow, 2),
                                 new PenDescription("实际航线"));
            plotter.FitToView();
        }
示例#23
0
        void RefreshCalculatedThresholdGraph()
        {
            Part_Plotter.Children.Remove(m_peakThresholdGraph);
            m_peakThresholdGraph = null;

            var data = this.ViewModel.CurrentDataItem?.DataItem;

            if (data == null)
            {
                return;
            }

            {
                Point[] signal = new Point[2]
                {
                    new Point(0, data.PeakDetectionSettings.CalculatedThreshold),
                    new Point((data.SamplesCount - 1) * data.Recording.Xscale, data.PeakDetectionSettings.CalculatedThreshold)
                };

                EnumerableDataSource <Point> signalDS = new EnumerableDataSource <Point>(signal);

                signalDS.SetXMapping((item) => item.X);
                signalDS.SetYMapping((item) => item.Y);

                m_peakThresholdGraph = new DXLineGraph()
                {
                    DataSource = signalDS, LineColor = Colors.Brown, Background = null
                };
                Part_Plotter.Children.Add(m_peakThresholdGraph);
                OrderGraphs();
            }
        }
		private void Window_Loaded(object sender, RoutedEventArgs e)
		{
			for (int i = 0; i < animatedX.Length; i++)
			{
				animatedX[i] = 2 * Math.PI * i / animatedX.Length;
				animatedY[i] = Math.Sin(animatedX[i]);
			}
			EnumerableDataSource<double> xSrc = new EnumerableDataSource<double>(animatedX);
			xSrc.SetXMapping(x => x);
			animatedDataSource = new EnumerableDataSource<double>(animatedY);
			animatedDataSource.SetYMapping(y => y);

			// Adding graph to plotter
			
			//todo
			//plotter.AddLineGraph(new CompositeDataSource(xSrc, animatedDataSource),
			//    new Pen(Brushes.Magenta, 3),
			//    new PenDescription("Sin(x + phase)"));

			timer.Interval = TimeSpan.FromMilliseconds(10);
			timer.Tick += AnimatedPlot_Timer;
			timer.IsEnabled = true;

			// Force evertyhing plotted to be visible
			plotter.FitToView();
		}
示例#25
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            wrapper = new OmniDriver.CCoWrapper();
            wrapper.setIntegrationTime(0, 100000);
            txt_intergrationTime.Text = "0.1";
            txt_collectDataTime.Text  = "0.1";
            numberOfSpectrometers     = wrapper.openAllSpectrometers();
            if (numberOfSpectrometers == 0)
            {
                MessageBox.Show("找不到光谱仪");
                textBox1.Text = "0";
                return;
            }
            else
            {
                textBox1.Text   = numberOfSpectrometers.ToString();
                wavelengthArray = (double[])wrapper.getWavelengths(0);
            }
            for (int i = 0; i < 2068; ++i)
            {
                xCoord[i] = i;
                yCoord[i] = 0;
            }
            xDataSource = new EnumerableDataSource <double>(xCoord);
            xDataSource.SetXMapping(x => x);

            datasDataSource = new EnumerableDataSource <double>(yCoord);
            datasDataSource.SetYMapping(y => y);

            compositeDataSource = new CompositeDataSource(xDataSource, datasDataSource);

            plotter.AddLineGraph(compositeDataSource, new Pen(Brushes.Blue, 1), new PenDescription("光谱曲线"));
            plotter.Viewport.FitToView();
            plotter2.AddLineGraph(datapoint, new Pen(Brushes.Red, 2), new PenDescription("亮度变化曲线"));
        }
示例#26
0
    void PlantView_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
    {
      foreach (var g in _extGraphs)
        ExtGraph.Children.Remove(g);
      _extGraphs.Clear();

      foreach (var g in _wells)
        ExtGraph.Children.Remove(g);
      _wells.Clear();

      

      PlantViewModel P = e.NewValue as PlantViewModel;
      if (P != null)
      {
        EnumerableDataSource<Time.Core.TimestampValue> ds = new EnumerableDataSource<TimestampValue>(P.plant.Extractions.AsTimeStamps);
        ds.SetXMapping(var => dateAxis.ConvertToDouble(var.Time));
        ds.SetYMapping(var => var.Value);
        _extGraphs.Add(ExtGraph.AddLineGraph(ds, new Pen(Brushes.Black, 3), new PenDescription("Groundwater")));

        if (P.plant.SurfaceWaterExtrations.Items.Count > 0)
        {
          EnumerableDataSource<Time.Core.TimestampValue> ds2 = new EnumerableDataSource<TimestampValue>(P.plant.SurfaceWaterExtrations.AsTimeStamps);
          ds2.SetXMapping(var => dateAxis.ConvertToDouble(var.Time));
          ds2.SetYMapping(var => var.Value);
          _extGraphs.Add(ExtGraph.AddLineGraph(ds2, new Pen(Brushes.Red, 3), new PenDescription("Surface water")));
        }
      }
      ZoomToTimeScale();
    }
示例#27
0
        private void CreateHistograms()
        {
            EnumerableDataSource<int> x = new EnumerableDataSource<int>(Enumerable.Range(0, 256).ToArray());
            x.SetXMapping(_x => _x);

            Func<int, double> mapping;
            if (check.IsChecked.GetValueOrDefault())
                mapping = logMapping;
            else
                mapping = linearMapping;

            red = new EnumerableDataSource<int>(reds);
            red.SetYMapping(mapping);
            green = new EnumerableDataSource<int>(greens);
            green.SetYMapping(mapping);
            blue = new EnumerableDataSource<int>(blues);
            blue.SetYMapping(mapping);

            CompositeDataSource rDS = new CompositeDataSource(x, red);
            CompositeDataSource gDS = new CompositeDataSource(x, green);
            CompositeDataSource bDS = new CompositeDataSource(x, blue);

            plotter.RemoveAllGraphs();
            plotter.AddLineGraph(rDS, Colors.Red, 1, "Red").FilteringEnabled = false;
            plotter.AddLineGraph(gDS, Colors.Green, 1, "Green").FilteringEnabled = false;
            plotter.AddLineGraph(bDS, Colors.Blue, 1, "Blue").FilteringEnabled = false;
        }
示例#28
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < 100; i++)
            {
                animatedX.Add(i);
                animatedY.Add(0);
            }
            EnumerableDataSource <double> xSrc = new EnumerableDataSource <double>(animatedX);

            xSrc.SetXMapping(x => x);
            animatedDataSource = new EnumerableDataSource <double>(animatedY);
            animatedDataSource.SetYMapping(y => y);

            // Adding graph to plotter
            plotter.AddLineGraph(new CompositeDataSource(xSrc, animatedDataSource),
                                 new Pen(Brushes.Magenta, 1),
                                 new PenDescription("Wave"));

            for (int i = 0; i < WaveIn.DeviceCount; i++)
            {
                var deviceInfo = WaveIn.GetCapabilities(i);
                this.label1.Content = String.Format("Device {0}: {1}, {2} channels",
                                                    i, deviceInfo.ProductName, deviceInfo.Channels);
            }

            var waveIn = new WaveIn()
            {
                DeviceNumber = 0, // Default
            };

            waveIn.DataAvailable += WaveIn_DataAvailable;
            waveIn.WaveFormat     = new WaveFormat(sampleRate: 8000, channels: 1);
            waveIn.StartRecording();
        }
示例#29
0
        //Instance of object which contains configuration for sending data.
        //ULoader_JSON config;
        //Instacje of object which sends data.
        //USender uSender;
        public MainWindow()
        {
            InitializeComponent();

            attentionValuesCollection = new DataCollection();

            var attentionDataSource = new EnumerableDataSource<Data>(attentionValuesCollection);
            attentionDataSource.SetXMapping(x => dateAttention.ConvertToDouble(x.Date));
            attentionDataSource.SetYMapping(y => y.Value);
            plotterAttention.AddLineGraph(attentionDataSource, Colors.Red, 2, "Attetion");

            connector = new Connector();
            connector.DeviceConnected += new EventHandler(OnDeviceConnected);
            connector.DeviceConnectFail += new EventHandler(OnDeviceFail);
            connector.DeviceValidating += new EventHandler(OnDeviceValidating);

            connector.ConnectScan("COM3");

            //Stworzenie obiektu typu Random do wyboru losowego słowa ze słownika.
            randomWordNumber = new Random();

            wordNumber = 0;

            attentionComingCounter = 0;
            attentionValueSum = 0;
            puzzlesSolved = 0;
            wordStatList = new List<WordStat>();
            currentWord = "";

            //config = new ULoader_JSON(@"..\..\config.json");
            //uSender = config.GetSender("output1");
        }
示例#30
0
        void RefreshSelectedPeakGraph()
        {
            Part_Plotter.Children.Remove(m_selectedPeakGraph);
            m_selectedPeakGraph = null;

            var peakInfo = this.ViewModel.CurrentDataItem?.SelectedPeakInfo;

            if (peakInfo != null)
            {
                PeakInfo[] point = new PeakInfo[] { peakInfo.PeakInfo };
                EnumerableDataSource <PeakInfo> locatedPeaksDS = new EnumerableDataSource <PeakInfo>(point);

                locatedPeaksDS.SetXMapping((item) => item.Pos.X);
                locatedPeaksDS.SetYMapping((item) => item.Pos.Y);
                locatedPeaksDS.AddMapping(PeaksMarker.DataContextProperty, (peakInfoItem) => peakInfoItem);

                m_selectedPeakGraph = new ElementMarkerPointsGraph(locatedPeaksDS)
                {
                    Marker = new SelectedPeaksMarker()
                    {
                        Size = 10, Pen = new Pen(Brushes.BlanchedAlmond, 1), Fill = Brushes.Transparent, ContextMenu = this.TryFindResource("PeakMarkerContextMenu") as ContextMenu
                    }
                };

                Part_Plotter.Children.Add(m_selectedPeakGraph);
                OrderGraphs();
            }
        }
示例#31
0
		public Window1()
		{
			InitializeComponent();

			Content = plot;

			plot.MainHorizontalAxis = axis;

			const int N = 10;

			double[] x = new double[N];
			double[] y = new double[N];
			DateTime[] date = new DateTime[N];

			for (int i = 0; i < N; i++)
			{
				x[i] = i * 0.1;
				y[i] = Math.Sin(x[i]);
				date[i] = DateTime.Now.AddMinutes(-N + i);
			}

			EnumerableDataSource<double> xs = new EnumerableDataSource<double>(x);
			xs.SetYMapping(_x => _x);
			EnumerableDataSource<DateTime> ys = new EnumerableDataSource<DateTime>(date);
			ys.SetXMapping(axis.ConvertToDouble);

			CompositeDataSource ds = new CompositeDataSource(xs, ys);

			plot.AddLineGraph(ds);
		}
		private void MainWindow_Loaded(object sender, RoutedEventArgs e)
		{
			// Prepare data in arrays
			const int N = 100;
			double[] x = new double[N];
			double[] y = new double[N];

			for (int i = 0; i < N; i++)
			{
				x[i] = i * 0.1;
				y[i] = Math.Cos(x[i]);
			}

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

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

			CompositeDataSource compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

			plotter.Viewport.Restrictions.Add(new PhysicalProportionsRestriction { ProportionRatio = 1 });

			// adding graph to plotter
			plotter.AddLineGraph(compositeDataSource,
				new Pen(Brushes.Goldenrod, 3),
				new SampleMarker(),
				new PenDescription("Cosine"));
		}
示例#33
0
        public MainWindow()
        {
            InitializeComponent();
            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            int waveInDevices = WaveIn.DeviceCount;

            for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
            {
                WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
                Console.WriteLine("Device {0}: {1}, {2} channels",
                                  waveInDevice, deviceInfo.ProductName, deviceInfo.Channels);
            }

            waveIn = new WaveIn();
            waveIn.BufferMilliseconds = 47 * buffersize / 2048;
            waveIn.DeviceNumber       = 0;
            waveIn.WaveFormat         = new WaveFormat(44100, 32, 1);
            waveIn.DataAvailable     += waveIn_DataAvailable;

            try
            {
                waveIn.StartRecording();
            }
            catch (NAudio.MmException e)
            {
                Console.WriteLine(e.ToString() + "\nPlug in a microphone!");
            }

            bin        = new int[buffersize * 2];
            sampledata = new float[buffersize * 2];
            priori     = new double[buffersize * 2];

            channelLabel    = new int[1];
            channelLabel[0] = 1;
            velocity        = new int[1];
            velocity[0]     = 0;
            for (int i = 0; i < buffersize * 2; i++)
            {
                bin[i]        = i;
                sampledata[i] = 0;
                priori[i]     = 0;
            }

            chart1.Viewport.Visible = new DataRect(0, -1.0, buffersize * 2, 2.0);
            chart2.Viewport.Visible = new DataRect(1620, 0, 280, 110);

            bins = new EnumerableDataSource <int>(bin);
            bins.SetXMapping(x => x);

            rawIn = new EnumerableDataSource <float>(sampledata);
            rawIn.SetYMapping(y => y);

            CompositeDataSource comp1 = new CompositeDataSource(bins, rawIn);

            chart1.AddLineGraph(comp1);

            CompositeDataSource comp2 = new CompositeDataSource(bins, rawIn);

            chart2.AddLineGraph(comp2);
        }
示例#34
0
        private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
        {
            for (int i = 0; i < animatedX.Length; i++)
            {
                animatedX[i] = 2 * Math.PI * i / animatedX.Length;
                animatedY[i] = Math.Sin(animatedX[i]);
            }
            EnumerableDataSource <double> xSrc = new EnumerableDataSource <double>(animatedX);

            xSrc.SetXMapping(x => x);
            animatedDataSource = new EnumerableDataSource <double>(animatedY);
            animatedDataSource.SetYMapping(y => y);

            // Adding graph to plotter
            LineGraph graph = new LineGraph(new CompositeDataSource(xSrc, animatedDataSource), "Sin(x + phase)");

            plotter.Children.Add(graph);

            timer.Interval = TimeSpan.FromMilliseconds(10);
            timer.Tick    += AnimatedPlot_Timer;
            timer.Start();

            // Force evertyhing plotted to be visible
            plotter.FitToView();
        }
示例#35
0
        private void CreateHistograms()
        {
            EnumerableDataSource <int> x = new EnumerableDataSource <int>(Enumerable.Range(0, 256).ToArray());

            x.SetXMapping(_x => _x);

            Func <int, double> mapping;

            if (check.IsChecked.GetValueOrDefault())
            {
                mapping = logMapping;
            }
            else
            {
                mapping = linearMapping;
            }

            red = new EnumerableDataSource <int>(reds);
            red.SetYMapping(mapping);
            green = new EnumerableDataSource <int>(greens);
            green.SetYMapping(mapping);
            blue = new EnumerableDataSource <int>(blues);
            blue.SetYMapping(mapping);

            CompositeDataSource rDS = new CompositeDataSource(x, red);
            CompositeDataSource gDS = new CompositeDataSource(x, green);
            CompositeDataSource bDS = new CompositeDataSource(x, blue);

            plotter.RemoveAllGraphs();
            plotter.AddLineGraph(rDS, Colors.Red, 1, "Red").FilteringEnabled     = false;
            plotter.AddLineGraph(gDS, Colors.Green, 1, "Green").FilteringEnabled = false;
            plotter.AddLineGraph(bDS, Colors.Blue, 1, "Blue").FilteringEnabled   = false;
        }
        public static void ApplyAntiSaccadeTextMarkers(ChartPlotter amplitudePlotter, bool isVisible, List <double> arrayX, List <double> arrayY, List <int> IDs, string text)
        {
            for (int i = 0; i < arrayX.Count; i++)
            {
                var xDataSource = new EnumerableDataSource <double>(new double[1] {
                    arrayX[i]
                });
                xDataSource.SetXMapping(x => x);
                var yDataSource = new EnumerableDataSource <double>(new double[1] {
                    arrayY[i]
                });
                yDataSource.SetYMapping(x => x);

                var saccadeStartCompositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

                var marker     = new MarkerPointsGraph(saccadeStartCompositeDataSource);
                var textMarker = new CenteredTextMarker();
                textMarker.Text = $"{text}:A#{IDs[i]}";
                marker.Marker   = textMarker;
                marker.Name     = $"AntiSacc{text}Label";
                if (!isVisible)
                {
                    marker.Visibility = Visibility.Hidden;
                }

                amplitudePlotter.Children.Add(marker);
            }
        }
        public static void ApplyAntiSaccadePointMarkers(ChartPlotter amplitudePlotter, List <EyeMove> antiSaccades)
        {
            var saccadeStartFoundDataSource = new EnumerableDataSource <EyeMove>(antiSaccades.Where(x => x.IsStartFound == true));

            saccadeStartFoundDataSource.SetXMapping(x => x.EyeStartTime);
            saccadeStartFoundDataSource.SetYMapping(x => x.EyeStartCoord);

            var saccadeEndFoundDataSource = new EnumerableDataSource <EyeMove>(antiSaccades.Where(x => x.IsEndFound == true));

            saccadeEndFoundDataSource.SetXMapping(x => x.EyeEndTime);
            saccadeEndFoundDataSource.SetYMapping(x => x.EyeEndCoord);


            var marker  = new MarkerPointsGraph(saccadeStartFoundDataSource);
            var markPen = new TrianglePointMarker();

            markPen.Pen   = new Pen(Brushes.Chartreuse, 1);
            markPen.Size  = 7;
            marker.Name   = "AntiSaccStart";
            markPen.Fill  = Brushes.Chartreuse;
            marker.Marker = markPen;
            amplitudePlotter.Children.Add(marker);


            marker        = new MarkerPointsGraph(saccadeEndFoundDataSource);
            markPen       = new TrianglePointMarker();
            markPen.Pen   = new Pen(Brushes.Gold, 1);
            markPen.Size  = 7;
            marker.Name   = "SaccEnd";
            markPen.Fill  = Brushes.Gold;
            marker.Marker = markPen;
            amplitudePlotter.Children.Add(marker);
        }
示例#38
0
        private void showprogress()
        {
            DBProgressConnect DBProgressConnect_Inst = new DBProgressConnect();
            DataTable ProgressData = new DataTable();
            ProgressData = DBProgressConnect_Inst.Read(globaldata.current_user);
            datagrid1.ItemsSource = ProgressData.DefaultView;
            int data_count = DBProgressConnect_Inst.Count(globaldata.current_user);
            DateTime[] dates = new DateTime[data_count];
            double[] scores = new double[data_count];

            for (int i = 0; i < data_count; i++)
            {
                dates[i] = Convert.ToDateTime(ProgressData.Rows[i][1]);
                scores[i] = Convert.ToDouble(ProgressData.Rows[i][2]);
            }

            var datesDataSource = new EnumerableDataSource<DateTime>(dates);
            datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x));

            var scoreDataSource = new EnumerableDataSource<double>(scores);
            scoreDataSource.SetYMapping(y => y);

            CompositeDataSource compositeDataSource1 = new CompositeDataSource(datesDataSource, scoreDataSource);

            Plotter.AddLineGraph(compositeDataSource1, new Pen(Brushes.Blue, 2), new CirclePointMarker { Size = 10.0, Fill = Brushes.Red }, new PenDescription("Time vs. Score for "+globaldata.current_user+""));

            Plotter.Viewport.FitToView();
        }
示例#39
0
        private void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            DateTime tempDateTime = new DateTime();

            tempDateTime = DateTime.Now;
            vardatetime.Add(tempDateTime);

            numberOpen.Add(random.Next(40));
            numberClosed.Add(random.Next(100));

            i++;

            datesDataSource = new EnumerableDataSource <DateTime>(vardatetime);
            datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x));

            numberOpenDataSource = new EnumerableDataSource <int>(numberOpen);
            numberOpenDataSource.SetYMapping(y => y);

            numberClosedDataSource = new EnumerableDataSource <int>(numberClosed);
            numberClosedDataSource.SetYMapping(y => y);

            compositeDataSource1 = new CompositeDataSource(datesDataSource, numberOpenDataSource);
            compositeDataSource2 = new CompositeDataSource(datesDataSource, numberClosedDataSource);


            plotter.AddLineGraph(compositeDataSource2, Colors.Green, 1, "Percentage2");
            plotter.Viewport.FitToView();


            timer.Interval  = TimeSpan.FromSeconds(1);
            timer.Tick     += new EventHandler(Window1_Loaded);
            timer.IsEnabled = true;
        }
示例#40
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Prepare data in arrays
            const int N = 100;
            double[] x = new double[N];
            double[] cs = new double[N];
            double[] sn = new double[N];

            for (int i = 0; i < N; i++)
            {
                x[i] = i * 0.1;
                cs[i] = Math.Sin(x[i]);
                sn[i] = Math.Cos(x[i]);
            }

            // Add data sources:
            // 3 partial data sources, containing each of arrays
            var snDataSource = new EnumerableDataSource<double>(sn);
            snDataSource.SetYMapping(y => y);

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

            var csDataSource = new EnumerableDataSource<double>(cs);
            csDataSource.SetYMapping(y => y);

            var csqDataSource = new EnumerableDataSource<double>(cs);
            csqDataSource.SetYMapping(y => y * y);


            // 2 composite data sources and 2 charts respectively:
            // creating composite data source
            CompositeDataSource compositeDataSource1 = new CompositeDataSource(xDataSource, snDataSource);
            // adding graph to plotter
            plotter.AddLineGraph(compositeDataSource1,
                new Pen(Brushes.DarkGoldenrod, 3),
                new CirclePointMarker { Size = 10, Fill = Brushes.Red },
                new PenDescription("Sin"));

            // creating composite data source for cs values
            CompositeDataSource compositeDataSource2 = new CompositeDataSource(xDataSource, csDataSource);
            // Adding second graph to plotter
            plotter.AddLineGraph(compositeDataSource2,
                new Pen(Brushes.Blue, 3),
                new TrianglePointMarker { Size = 20, Fill = Brushes.Blue },
                new PenDescription("Cos"));

            // creating composite data source for cs^2 values
            CompositeDataSource compositeDataSource3 = new CompositeDataSource(xDataSource, csqDataSource);
            // Adding thirs graph to plotter
            Pen dashed = new Pen(Brushes.Magenta, 3);
            dashed.DashStyle = DashStyles.Dot;
            plotter.AddLineGraph(compositeDataSource3,
                dashed,
                new PenDescription("Cos^2"));

            // Force evertyhing plotted to be visible
            plotter.FitToView();
        }
        public ExperimentalIV_DataSource(List<PointD> data)
        {
            _ExperimentalData = data;
            _ExperimentalDataSource = new EnumerableDataSource<PointD>(_ExperimentalData);
            _ExperimentalDataSource.SetXMapping(x => x.X);
            _ExperimentalDataSource.SetYMapping(y => y.Y);

            dispatcher = Dispatcher.CurrentDispatcher;
        }
 private void CreatePerformanceGraph(string instanceName, string counterName)
 {
     var perfData = new PerformanceData(new PerformanceCounter("Process", counterName, instanceName));
     var filteredData = new FilteringDataSource<PerformanceInfo>(perfData, new MaxSizeFilter());
     var dataSource = new EnumerableDataSource<PerformanceInfo>(filteredData);
     dataSource.SetXMapping(pi => (pi.Time.TimeOfDay.TotalSeconds - (_currentTotal == 0 ? _currentTotal = pi.Time.TimeOfDay.TotalSeconds : _currentTotal)));
     dataSource.SetYMapping(pi => Proc.GetCpuValue(pi.Value));
     Plotter.AddLineGraph(dataSource, 0.8, string.Format("{0} - {1}", counterName, instanceName));
 }
示例#43
0
		/// <summary>
		/// Updates the graph of the histogram with the newly calculated data of the frame
		/// once it is rendered.
		/// </summary>
		public override void Handle(Pipeline.TickRenderedMessage message)
		{
			Data = new EnumerableDataSource<KeyValuePair<int, double>>(
				NodeModel.Data.Select((datum, idx) => new KeyValuePair<int, double>(idx, datum))
			);
			Data.SetXMapping(k => k.Key);
			Data.SetYMapping(k => k.Value);
			NotifyOfPropertyChange(() => Data);
		}
示例#44
0
		private void AddLineGraph(Point startPoint, Point endPoint)
		{
			var ds = new EnumerableDataSource<Point>(new List<Point> {
        new Point { X = startPoint.X, Y = startPoint.Y }, 
        new Point { X = endPoint.X, Y = endPoint.Y } 
      });
			ds.SetXYMapping(pt => pt);

			plotter.AddLineGraph(ds);
		}
示例#45
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // Prepare table. We use standart data table
            DataTable table = new DataTable();
            table.Columns.Add("Sine", typeof(double));
            table.Columns.Add("Time", typeof(DateTime));
            table.Columns.Add("Index", typeof(int));
            table.Columns.Add("Sqrt", typeof(double));

            for (int i = 0; i < 100; i++)
            {
                table.Rows.Add(
                    Math.Sin(i / 10.0),
                    DateTime.Now + new TimeSpan(0, 0, i),
                    i,
                    Math.Sqrt(i));
            }

            // Prepare data source with mapping 
            TableDataSource data = new TableDataSource(table);
            // X is time in seconds
            data.SetXMapping(row => ((DateTime)row["Time"] - (DateTime)table.Rows[0][1]).TotalSeconds);
            // Y is value of "Sine" column
            data.SetYMapping(row => 10 * (double)row["Sine"]);
            // Map HSB color computes from "Index" column to dependency property Brush of marker
            data.AddMapping(ShapePointMarker.FillProperty,
                row => new SolidColorBrush(new HsbColor(3 * (int)row["Index"], 1, 1).ToArgbColor()));
            // Map "Sqrt" based values to marker size
            data.AddMapping(ShapePointMarker.SizeProperty,
                row => 4 + (double)row["Sqrt"]);

            // Plot first graph
            plotter.AddLineGraph(data,
                new Pen(Brushes.Blue, 2),
                new CirclePointMarker(),
                new PenDescription("First series (Sine)"));

            // Prepare data source for second graph. table.Rows is enumerable, 
            // so we can plot its contents as IEnumerable with items of TableRow type
            EnumerableDataSource<DataRow> data2 = new EnumerableDataSource<DataRow>(table.Rows);
            // X is time in seconds again
            data2.SetXMapping(row => ((DateTime)row["Time"] - (DateTime)table.Rows[0][1]).TotalSeconds);
            // Y is value of "Sqrt" column
            data2.SetYMapping(row => (double)row["Sqrt"]);

            // Plot second graph without markers
            plotter.AddLineGraph(data2,
                Colors.Red, 3.0,
                "Second series (Sqrt)");

            // Force evertyhing plotted to be visible
            plotter.Viewport.FitToView();
        }
示例#46
0
		void Window1_Loaded(object sender, RoutedEventArgs e)
		{
			List<WeatherData> data = CreateData(100);

			chart.DataSource = data;

			EnumerableDataSource<WeatherData> dataSource = new EnumerableDataSource<WeatherData>(data);
			dataSource.SetXMapping(weather => weather.Day);
			dataSource.SetYMapping(weather => weather.Temperature);

			var line = plotter.AddLineGraph(dataSource);
		}
示例#47
0
		private LineGraph CreateFilteredPerformanceGraph(string categoryName, string counterName, string instanceName, IFilter<PerformanceInfo> filter)
		{
			PerformanceData data = new PerformanceData(new PerformanceCounter(categoryName, counterName, instanceName));

			var filteredData = new FilteringDataSource<PerformanceInfo>(data, filter);

			var ds = new EnumerableDataSource<PerformanceInfo>(filteredData);
			ds.SetXMapping(pi => pi.Time.TimeOfDay.TotalSeconds);
			ds.SetYMapping(pi => pi.Value);

			LineGraph chart = plotter.AddLineGraph(ds, 2.0, String.Format("{0} - {1}", categoryName, counterName));
			return chart;
		}
示例#48
0
        private void create(float[] sensor, string sensorName, Brush brush, EnumerableDataSource<DateTime> datesDataSource)
        {
            var numbersensordatasource = new EnumerableDataSource<float>(sensor);
            numbersensordatasource.SetYMapping(y => y);

            var compositeSensor1DataSource = new
            CompositeDataSource(datesDataSource, numbersensordatasource);

            plotter.AddLineGraph(compositeSensor1DataSource,
              new Pen(brush, 2),
              new CirclePointMarker { Size = 10.0, Fill = brush },
              new PenDescription(sensorName));
        }
示例#49
0
		private void MainWindow_Loaded(object sender, RoutedEventArgs e)
		{
			// Prepare data in arrays
			const int N = 100;
			double[] x = new double[N];
			double[] y = new double[N];

			for (int i = 0; i < N; i++)
			{
				x[i] = i * 0.1;
				y[i] = Math.Cos(x[i]);
			}

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

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


			CompositeDataSource compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

			Matrix m = Matrix.Identity;
			m.RotateAt(45, 10, 10);
			line = new LineGraph
			{
				Stroke = Brushes.Green,
				StrokeThickness = 2,
				DataTransform =
					//new MatrixDataTransform(m) 
				new RotateDataTransform(45.0.DegreesToRadians())
			};
			line.DataSource = compositeDataSource;
			line.AddToPlotter(plotter);

			plotter.Viewport.Constraints.Add(new PhysicalProportionsConstraint { ProportionRatio = 1 });


			// adding graph to plotter
			plotter.AddLineGraph(compositeDataSource,
				new Pen(Brushes.Goldenrod, 3),
				new SampleMarker(),
				new PenDescription("Cosine"));

			//plotter.Viewport.FitToViewRestrictions.Add(new FollowDataWidthRestriction { Width = 1 });

			plotter.PreviewKeyDown += plotter_KeyDown;
		}
		public AnimatedDataSource()
		{
			// randomize start phase
			phase = rnd.NextDouble() * 3;

			// create data source
			xDS = new EnumerableDataSource<double>(x);
			xDS.SetXMapping(X => X);
			EnumerableDataSource<double> yDS = new EnumerableDataSource<double>(y);
			yDS.SetYMapping(Y => Y);
			Update();

			ds = new CompositeDataSource(xDS, yDS);
		}
示例#51
0
        public LineGraphData(int size, string description)
        {
            // Array for data
            data = new RingArray<DataPoint>(size);

            // Convert to an enumerable data source for line graph
            ds = new EnumerableDataSource<DataPoint>(data);

            // and set mappings
            ds.SetXMapping(x => x.X);
            ds.SetYMapping(y => y.Y);

            ds.AddMapping(ShapeElementPointMarker.ToolTipTextProperty, p => string.Format("{0}, {1}, " + description, p.X, p.Y));
        }
示例#52
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();
		}
    private void checkBox1_Checked(object sender, RoutedEventArgs e)
    {
      if (((CheckBox)sender).IsChecked.Value)
      {
        foreach (var v in listBox1.SelectedItems)
        {
          EnumerableDataSource<TSBrtEntry> x = new EnumerableDataSource<TSBrtEntry>(((Element) v).DetailedTimeSeries);

          x.SetXMapping(var => var.Time.TotalHours);
          x.SetYMapping(var => var.Pressure);
          var lg = Graf1.AddLineGraph(x, 3, "Pressure");
          _graphs.Add(lg);
        }
      }
    }
示例#54
0
        public MainWindow()
        {
            InitializeComponent();



            SensorManager.Init();
            // Create first source
            var source = new EnumerableDataSource<GraphValueUnit>(SensorManager.Gyro_X);
            source.SetXMapping(x => x.X);
            source.SetYMapping(y => y.Y);
            chartPlotterGyro.AddLineGraph(source, Colors.Magenta, 2, "Gyro Roll");

            source = new EnumerableDataSource<GraphValueUnit>(SensorManager.Gyro_Y);
            source.SetXMapping(x => x.X);
            source.SetYMapping(y => y.Y);
            chartPlotterGyro.AddLineGraph(source, Colors.CadetBlue, 2, "Gyro Pitch");

            source = new EnumerableDataSource<GraphValueUnit>(SensorManager.Gyro_Z);
            source.SetXMapping(x => x.X);
            source.SetYMapping(y => y.Y);
            chartPlotterGyro.AddLineGraph(source, Colors.MediumPurple, 2, "Gyro YAW");



            source = new EnumerableDataSource<GraphValueUnit>(SensorManager.Acc_Y);
            source.SetXMapping(x => x.X);
            source.SetYMapping(y => y.Y);
            chartPlotterAcc.AddLineGraph(source, Colors.Magenta, 2, "Acc Roll");

            source = new EnumerableDataSource<GraphValueUnit>(SensorManager.Acc_X);
            source.SetXMapping(x => x.X);
            source.SetYMapping(y => y.Y);
            chartPlotterAcc.AddLineGraph(source, Colors.CadetBlue, 2, "ACC Pitch");

            source = new EnumerableDataSource<GraphValueUnit>(SensorManager.Acc_Z);
            source.SetXMapping(x => x.X);
            source.SetYMapping(y => y.Y);
            chartPlotterAcc.AddLineGraph(source, Colors.MediumPurple, 2, "Acc Z");


            txtVideoConnection.Text = Properties.Settings.Default["VideoConnection"].ToString();
            txtLogFolder.Text = Properties.Settings.Default["LogFolder"].ToString(); //Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

          
            octrlQuadConfiguration.QuadConfigStructure = QuadConfigurationManager.QuadConfigStructure;

        }
		private IPointDataSource CreateSineDataSource(double phase)
		{
			const int N = 100;

			Point[] pts = new Point[N];
			for (int i = 0; i < N; i++)
			{
				double x = i / (N / 10.0) + phase;
				pts[i] = new Point(x, Math.Sin(x - phase));
			}

			var ds = new EnumerableDataSource<Point>(pts);
			ds.SetXYMapping(pt => pt);

			return ds;
		}
示例#56
0
        public void DrawThis(IEnumerable<int> value, IEnumerable<int> time, Brush penBrush, Brush circlePoints)
        {
            var timesDataSource = new EnumerableDataSource<int>(value);
            timesDataSource.SetXMapping(x => timeAxis.ConvertToDouble(x));

            var xPointsDataSource = new EnumerableDataSource<int>(time);
            xPointsDataSource.SetYMapping(y => Convert.ToInt32(y));

            var compositeDataSource = new CompositeDataSource(xPointsDataSource, timesDataSource);

            plotter.AddLineGraph(compositeDataSource,
                                 new Pen(penBrush, 2),
                                 new CirclePointMarker {Size = 8.0, Fill = circlePoints},
                                 new PenDescription(""));

            plotter.Viewport.FitToView();
        }
示例#57
0
        private IPointDataSource CreateSineDataSource(double phase)
        {
            const int N = 100000;

            Point[] pts = new Point[N];
            Random r = new Random();
            for (int i = 0; i < N; i++)
            {
                double x = 10.0* i / N + phase;
                pts[i] = new Point(x, Math.Sin(x - phase) + (r.NextDouble()-0.5)/1000);
            }

            var ds = new EnumerableDataSource<Point>(pts);
            ds.SetXYMapping(pt => pt);

            return ds;
        }
示例#58
0
		private async void GetData()
		{
			var yAxis = new DateTimeAxis();
			byte c = 0;
			foreach (var address in AddressList)
			{
				var i = address.IndexOf('.');
				var deviceAdress = address.Substring(0, i);
				var objectAdress = address.Substring(i + 1, address.Length - i - 1);

				string requestUrl = string.Format("{0}/{1}/{2}/history",
					HistoryUri,
					deviceAdress,
					objectAdress
					);

				var a = await _dataTransport.GetRequestAsync<Dictionary<DateTime, string>>(requestUrl, true, 30000);

				if (a == null || a.Count == 0)
					continue;

				var model = new GraphModel
				{
					Address = address,
					Color = _graphColours[c%_graphColours.Count()],
					Name = UnitsList[c],
					Times = a.Keys.ToList(),
					Values = a.Values.Select(val => double.Parse(val.Replace('.', ','))).ToList()
				};

				var xDs = new EnumerableDataSource<DateTime>(model.Times);
				var yDs = new EnumerableDataSource<double>(model.Values);

				model.MinValue = model.Values.Min() - 1;
				model.MaxValue = model.Values.Max() + 1;

				//set the mappings
				xDs.SetXMapping(x => yAxis.ConvertToDouble(x));
				yDs.SetYMapping(y => y);

				model.PointDataSource = new CompositeDataSource(xDs, yDs);
				Graphs.Add(model);
				c++;
			}
		}
示例#59
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;
		}
示例#60
0
 public MainWindow()
 {
     InitializeComponent();
     foreach (string port in SerialPort.GetPortNames())
         portsComboBox.Items.Add(port);
     portsComboBox.SelectedIndex = 1;
     attentionValuesCollection = new DataCollection();
     var attentionDataSource = new EnumerableDataSource<Data>(attentionValuesCollection);
     attentionDataSource.SetXMapping(x => dateAttention.ConvertToDouble(x.Date));
     attentionDataSource.SetYMapping(y => y.Value);
     plotterAttention.AddLineGraph(attentionDataSource, Colors.Red, 2, "Attention");
     randomWordNumber = new Random();
     wordNumber = 0;
     attentionComingCounter = 0;
     attentionValueSum = 0;
     puzzlesSolved = 0;
     currentWord = "";
     config = new ULoader_JSON("config.json");
     uSender = config.GetSender("output1");
 }