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);
            }
        }
예제 #2
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;
        }
예제 #3
0
        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;
        }
예제 #4
0
 /// <summary>
 /// this is the constructor of this class.
 /// </summary>
 /// <param name="_planeLocations"></param>
 /// <param name="_plotter"></param>
 public TelnetServer(ObservableDataSource <Point> _planeLocations, ChartPlotter _plotter)
 {
     this.s         = null;
     planeLocations = _planeLocations;
     plotter        = _plotter;
     isConnected    = false;
 }
예제 #5
0
 private void plotter_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     ChartPlotter chart = sender as ChartPlotter;
     Point        p     = e.GetPosition(this).ViewportToData(chart.Transform);
     string       x     = p.X.ToString();
     string       y     = p.Y.ToString();
 }
        public void TestViewportContentBounds()
        {
            ChartPlotter        plotter = new ChartPlotter();
            TempIPlotterElement element = new TempIPlotterElement();

            plotter.Children.Add(element);
            plotter.PerformLoad();
            plotter.Viewport.ClipToBoundsEnlargeFactor = 1.0;

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

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

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

            plotter.Children.Remove(element);

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

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

            Viewport2D.SetIsContentBoundsHost(element, false);
            Assert.AreEqual(new DataRect(0, 0, 1, 1), plotter.Visible);
        }
예제 #7
0
        public void setControls(TextBlock tb, ChartPlotter cp)
        {
            textBlock = tb;
            plotter   = cp;

            InitializeBackgroundWorker();
        }
예제 #8
0
        public void TestAllElementsAddRemove()
        {
            ChartPlotter plotter = new ChartPlotter();

            var types = GetAllCharts();

            var plotterElements = new List <IPlotterElement>();

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

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

            plotter.Children.Clear();

            foreach (var item in plotterElements)
            {
                Assert.IsNull(item.Plotter, item.ToString());
            }
        }
예제 #9
0
        public Basechart(Dispatcher p, ChartPlotter newchart, Dictionary <string, string> packagelist)
        {
            //Init variables
            colorpool.Add(Colors.Blue);
            colorpool.Add(Colors.Red);
            colorpool.Add(Colors.Green);
            colorpool.Add(Colors.Yellow);
            colorpool.Add(Colors.Pink);
            disp      = p;
            chart     = newchart;
            msr.Width = 300;
            this.chart.Viewport.Restrictions.Add(msr);
            //chart.MainVerticalAxis.
            chart.FitToView();
            //chart.Legend.LegendLeft = 10.0;
            chart.MouseMove       += new MouseEventHandler(chart_MouseMove);
            chart.MouseLeave      += new MouseEventHandler(chart_MouseLeave);
            chart.LegendVisibility = Visibility.Hidden;
            //pkglist = packagelist;
            //datalist = new Dictionary<string, ObservableDataSource<Point>>();
            ThreadStart ts = new ThreadStart(asyncProcData);

            newThread = new Thread(ts);
            newThread.Start();
        }
예제 #10
0
파일: Graphic.cs 프로젝트: sm-g/weatherlog
        private static ChartPlotter SamplePlot()
        {
            ChartPlotter           plotter  = new ChartPlotter();
            HorizontalDateTimeAxis dateAxis = new HorizontalDateTimeAxis();

            plotter.HorizontalAxis = dateAxis;

            // chart.Children.Add(plotter);

            int    size   = 15;
            Random random = new Random();

            DateTime[] dates   = new DateTime[size];
            int[]      values1 = new int[size];
            int[]      values2 = new int[size];

            for (int i = 0; i < size; ++i)
            {
                dates[i]   = DateTime.Today.AddDays(i);
                values1[i] = random.Next(0, 10);
                values2[i] = random.Next(5, 15);
            }

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

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

            var numberOpenDataSource = new EnumerableDataSource <int>(values1);

            numberOpenDataSource.SetYMapping(y => y);

            var numberOpenDataSource2 = new EnumerableDataSource <int>(values2);

            numberOpenDataSource2.SetYMapping(y => y);

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

            datesDataSource2.SetXMapping(x => dateAxis.ConvertToDouble(((DateTime)x).AddDays(2)));

            CompositeDataSource compositeDataSource1 = new CompositeDataSource(datesDataSource, numberOpenDataSource);
            CompositeDataSource compositeDataSource2 = new CompositeDataSource(
                datesDataSource2,
                numberOpenDataSource2);
            LinearPalette pal = new LinearPalette(Colors.Crimson, Colors.DarkBlue);

            plotter.AddLineGraph(compositeDataSource1,
                                 new Pen(Brushes.Blue, 2),
                                 new CirclePointMarker {
                Size = 10.0, Fill = Brushes.Red
            },
                                 new PenDescription("1n"));
            plotter.AddLineGraph(compositeDataSource2,
                                 new Pen(Brushes.Cyan, 1),
                                 new TrianglePointMarker {
                Size = 5.0
            },
                                 new PenDescription("2n"));

            return(plotter);
        }
예제 #11
0
        public virtual UIElement process(Function f)
        {
            if (f == null)
            {
                return(null);
            }

            ChartPlotter plotter = new ChartPlotter();

            LinkedList <double> x = new LinkedList <double>(), y = new LinkedList <double>();

            Function processedFunction = processFunction(f);

            for (double _x = processedFunction.minX; _x < processedFunction.maxX + processedFunction.step / 2; _x += processedFunction.step)
            {
                x.AddLast(_x);
                y.AddLast(processedFunction.getValue(_x));
            }

            var xDataSource = x.AsXDataSource();
            var yDataSource = y.AsYDataSource();

            CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource);

            plotter.AddLineGraph(compositeDataSource, System.Windows.Media.Colors.Blue, 3, title);

            return((UIElement)plotter);
        }
        public void TestAddingToPlotter()
        {
            HorizontalLine line = new HorizontalLine {
                Value = 0.2
            };
            ChartPlotter plotter = new ChartPlotter();

            plotter.Children.Add(line);

            VerticalLine line2 = new VerticalLine {
                Value = 0.1
            };

            plotter.Children.Add(line2);

            VerticalRange range = new VerticalRange {
                Value1 = 0.1, Value2 = 0.3
            };

            plotter.Children.Add(range);

            RectangleHighlight rect = new RectangleHighlight {
                Bounds = new Rect(0, 0, 1, 1)
            };

            plotter.Children.Add(rect);
        }
        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);
        }
예제 #14
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;
        }
        private void OPTION_POSITIONDataGrid__PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (this.viewModel_.Calculated_)
            {
                ChartPlotter cp = new ChartPlotter();

                this.drowChartPlotter(cp);

                List <OptionViewModel_1928> optionList
                    = this.OPTION_POSITIONDataGrid_.SelectedItems.OfType <OptionViewModel_1928>().ToList();

                //foreach (var item in optionList)
                //{
                //    var xData = item.xData_.AsXDataSource();
                //    var yData = item.yData_.AsYDataSource();

                //    CompositeDataSource compositeDataSource = xData.Join(yData);

                //    LineGraph lineG = new LineGraph(compositeDataSource);

                //    lineG.LinePen = new Pen(item.Brush_, 3);
                //    lineG.Description = new PenDescription(item.Name_);

                //    cp.Children.Add(lineG);


                //}

                int      dataLength = this.viewModel_.xData_.Length;
                double[] sumY       = Enumerable.Repeat <double>(0.0, dataLength).ToArray <double>();

                foreach (var item in optionList)
                {
                    for (int i = 0; i < dataLength; i++)
                    {
                        sumY[i] = sumY[i] + item.yData_[i] / 100000000.0;
                    }
                }

                var xData = this.viewModel_.xData_.AsXDataSource();
                var yData = sumY.AsYDataSource();

                CompositeDataSource compositeDataSource = xData.Join(yData);

                LineGraph lineG = new LineGraph(compositeDataSource);

                lineG.Description = new PenDescription("합계");

                cp.Children.Add(lineG);


                this.chartGrid_.Children.Add(cp);
            }

            else
            {
                MessageBox.Show("Excute Calculation First!");
            }
        }
예제 #16
0
        public Window1()
        {
            InitializeComponent();

#if MULTIPLE
            for (int ix = 0; ix < colNum; ix++)
            {
                content.ColumnDefinitions.Add(new ColumnDefinition());
            }
            for (int iy = 0; iy < rowNum; iy++)
            {
                content.RowDefinitions.Add(new RowDefinition());
            }

            for (int ix = 0; ix < colNum; ix++)
            {
                for (int iy = 0; iy < rowNum; iy++)
                {
                    ChartPlotter plotter = new ChartPlotter();
                    plotter.MainHorizontalAxis = null;
                    plotter.MainVerticalAxis   = null;
                    plotter.BorderThickness    = new Thickness(1);
                    Grid.SetColumn(plotter, ix);
                    Grid.SetRow(plotter, iy);
                    content.Children.Add(plotter);
                    plotter.LegendVisibility       = Visibility.Hidden;
                    plotter.Legend.AutoShowAndHide = false;

                    AnimatedDataSource ds = new AnimatedDataSource();
                    data.Add(ds);

                    LineGraph line = new LineGraph(ds.DataSource);
                    line.Stroke          = BrushHelper.CreateBrushWithRandomHue();
                    line.StrokeThickness = 2;
                    line.Filters.Add(new FrequencyFilter());
                    plotter.Children.Add(line);
                }
            }
#else
            ChartPlotter plotter = new ChartPlotter();
            plotter.HorizontalAxis = null;
            plotter.VerticalAxis   = null;

            content.Children.Add(plotter);
            for (int i = 0; i < rowNum * colNum; i++)
            {
                AnimatedDataSource ds = new AnimatedDataSource();
                data.Add(ds);

                LineGraph line = new LineGraph(ds.DataSource);
                line.LineBrush     = BrushHelper.CreateBrushWithRandomHue();
                line.LineThickness = 1;
                line.Filters.Add(new FrequencyFilter());
                plotter.Children.Add(line);
            }
#endif

            Loaded += new RoutedEventHandler(Window1_Loaded);
        }
예제 #17
0
        public void AddToPlotter(ChartPlotter plotter)
        {
            var ds = new EnumerableDataSource <Point>(_points);

            ds.SetXMapping(p => ((HorizontalDateTimeAxis)plotter.HorizontalAxis).ConvertToDouble(p.Time));
            ds.SetYMapping(p => p.Value);
            _linegraph = plotter.AddLineGraph(ds, _color, 2, _name);
        }
예제 #18
0
        private void FitToView(ChartPlotter port)
        {
            var old = port.Viewport.AutoFitToView;

            port.Viewport.AutoFitToView = true;
            port.Viewport.FitToView();
            port.Viewport.AutoFitToView = old;
        }
        public void TestDeserialization()
        {
            ChartPlotter plotter = new ChartPlotter();

            string xaml = XamlWriter.Save(plotter);

            ChartPlotter plotter2 = (ChartPlotter)XamlReader.Parse(xaml);
        }
예제 #20
0
        public void SetLegendPanelTemplate()
        {
            ChartPlotter plotter = new ChartPlotter();

            var template = plotter.LegendPanelTemplate;

            plotter.LegendPanelTemplate = template;
        }
예제 #21
0
        static void Main(string[] args)
        {
            ChartPlotter plotter = new ChartPlotter();

            plotter.PerformLoad();
            plotter.Background = Brushes.Transparent;
            plotter.SaveScreenshot("1.png");
        }
예제 #22
0
 /// <summary>
 /// this is the constructor of this class.
 /// </summary>
 /// <param name="_planeLocations"></param>
 /// <param name="_plotter"></param>
 public FlightBoardModel(ObservableDataSource <Point> _planeLocations, ChartPlotter _plotter)
 {
     planeLocations = _planeLocations;
     plotter        = _plotter;
     ts             = new TelnetServer(planeLocations, plotter);
     mtc            = new MyTelnetClient();
     ip             = (string)Settings.Default["IP"];
     clientPort     = Int32.Parse((string)Settings.Default["PortClient"]);
     serverPort     = Int32.Parse((string)Settings.Default["PortServer"]);
 }
        public void TestReversibility()
        {
            ChartPlotter plotter        = new ChartPlotter();
            var          genericPlotter = plotter.GetGenericPlotter <double, double>();

            genericPlotter.DataRect = new GenericRect <double, double>(0, 0, 2, 2);

            Assert.IsTrue(plotter.Visible == new DataRect(0, 0, 2, 2));
            Assert.IsTrue(genericPlotter.DataRect == new GenericRect <double, double>(0, 0, 2, 2));
        }
예제 #24
0
        static void Main(string[] args)
        {
            ChartPlotter plotter = new ChartPlotter {
                Width = 200, Height = 200
            };

            plotter.SaveScreenshot("1.png");

            Process.Start("1.png");
        }
        public void HorizontalAxisTest()
        {
            ChartPlotter target   = new ChartPlotter();
            var          expected = new HorizontalAxis();
            GeneralAxis  actual;

            target.MainHorizontalAxis = expected;
            actual = target.MainHorizontalAxis;
            Assert.AreEqual(expected, actual);
        }
        public void VerticalAxisTest()
        {
            ChartPlotter plotter  = new ChartPlotter();
            var          expected = new VerticalAxis();
            GeneralAxis  actual;

            plotter.MainVerticalAxis = expected;
            actual = plotter.MainVerticalAxis;
            Assert.AreEqual(expected, actual);
        }
예제 #27
0
 private void ConfigureYAxisRight(ChartPlotter plotter)
 {
     yAxisRight = new VerticalAxis()
     {
         Placement = AxisPlacement.Right
     };
     plotter.Children.Add(yAxisRight);
     yAxisRight.ConvertFromDouble = s => (s + .5) * 500.0;
     yAxisRight.ConvertToDouble   = s => s / 500.0 - .5;
 }
예제 #28
0
 private void GetXAxisExtents(ChartPlotter plotter)
 {
     tick1 = double.MaxValue;
     tick2 = double.MinValue;
     foreach (LineGraph lg in plotter.Children.OfType <LineGraph>())
     {
         tick1 = smaller(tick1, lg.DataSource.GetPoints().Min(s => s.X));
         tick2 = bigger(tick2, lg.DataSource.GetPoints().Max(s => s.X));
     }
 }
예제 #29
0
        public void Register(HotItem item, ObservableDataSource <ItemProxy> items)
        {
            items.SetYMapping(y => y.SellPrice);
            items.SetXMapping(x => HorizontalAxis.ConvertToDouble(x.DateTime));

            ChartPlotter.AddLineGraph(items, 2.0, item.Name + " S");

            chartItems.Add(item.DataId, items);
            item.PropertyChanged += item_PropertyChanged;
        }
        public void TestScreenRect()
        {
            ChartPlotter plotter = new ChartPlotter {
                Width = 200, Height = 100
            };
            var img = plotter.CreateScreenshot();

            Rect screenRect = plotter.Viewport.Output;

            Assert.IsTrue(screenRect.Width > 0 && screenRect.Height > 0);
        }