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();
        }
Exemple #2
0
        public WellView()
        {
            InitializeComponent();
            DataContextChanged += new DependencyPropertyChangedEventHandler(WellView_DataContextChanged);
            Loaded             += new RoutedEventHandler(WellView_Loaded);

            SelectedPoint.SetXMapping(var => dateAxis.ConvertToDouble(var.Time));
            SelectedPoint.SetYMapping(var => var.Value);

            ObsGraph.MouseLeftButtonDown += new MouseButtonEventHandler(g_MouseLeftButtonDown);

            ObsGraph.AddLineGraph(SelectedPoint, null, new CircleElementPointMarker {
                Size  = 10,
                Brush = Brushes.Red,
                Fill  = Brushes.Orange
            }
                                  , null);

            pens = new Pen[6];

            pens[0] = new Pen(Brushes.Black, 3);
            pens[1] = new Pen(Brushes.Red, 3);
            pens[2] = new Pen(Brushes.Blue, 3);
            pens[3] = new Pen(Brushes.Green, 3);
            pens[4] = new Pen(Brushes.Yellow, 3);
            pens[5] = new Pen(Brushes.Brown, 3);
        }
        private ObservableDataSource <TimeParam> InitSource()
        {
            var source = new ObservableDataSource <TimeParam>();

            source.SetXMapping(x => timeSpanAxis.ConvertToDouble(x.Time));
            source.SetYMapping(y => y.y);
            return(source);
        }
		void EditPlotter()
		{
			_source = new ObservableDataSource<Trade>();
			_source.SetXMapping(x => x.Counter);
			_source.SetYMapping(y => y.Price);

			var line = plotter.AddLineGraph(_source,
					new Pen(Brushes.Gold, 3),
					new PenDescription("Sin(x + phase)"));
		}
        void EditPlotter()
        {
            _source = new ObservableDataSource <Trade>();
            _source.SetXMapping(x => x.Counter);
            _source.SetYMapping(y => y.Price);

            var line = plotter.AddLineGraph(_source,
                                            new Pen(Brushes.Gold, 3),
                                            new PenDescription("Sin(x + phase)"));
        }
        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 MainWindow()
        {
            InitializeComponent();
            FillTestData();

            y_valuesDataSource = new ObservableDataSource<int>(y_values);
            y_valuesDataSource.SetYMapping(y => y);

            x_valuesDataSource = new ObservableDataSource<int>(x_values);
            x_valuesDataSource.SetXMapping(x => x);

            var compositeDataSource = new CompositeDataSource(x_valuesDataSource, y_valuesDataSource);

            //chartPlotter.AddLineGraph(compositeDataSource);

            //chartPlotter.Viewport.FlowDirection = FlowDirection.RightToLeft;
            //chartPlotter.Viewport.FitToView();
        }
Exemple #8
0
        public DataHandler(Multimeter refer)
        {
            s            = new Stopwatch();
            g            = new Stopwatch();
            multimeter   = refer;
            currentMeter = "DMM " + (multimeter.Index + 1).ToString();

            totalStopWatch = new Stopwatch();
            totalLogTimer  = new DispatcherTimer(new TimeSpan(0, 0, 1), DispatcherPriority.Normal, delegate
            {
                multimeter.overview.ElapsedTimeDisplay.Text = String.Format("{0:hh\\:mm\\:ss}", totalStopWatch.Elapsed);
            }, Application.Current.Dispatcher);

            HorizontalDateTimeAxis axis = multimeter.dynamicChart.HorizontalAxis as HorizontalDateTimeAxis;

            loggedValues = new ObservableDataSource <DatePoint>();
            loggedValues.SetXMapping(p => axis.ConvertToDouble(p.X));
            loggedValues.SetYMapping(p => p.Y);
            graph = multimeter.dynamicChart.AddLineGraph(loggedValues, Colors.Blue, 2, currentMeter);
        }
Exemple #9
0
        private void AddNewTab(int index = 1)
        {
            TabItem t = new TabItem();

            MultimeterTabs.Items.Insert(index, t);
            Multimeter multimeter = new Multimeter(this, t, MultimeterTabs, multimeters.Count);

            multimeters.Add(multimeter);
            t.Content = multimeter;
            MultimeterTabs.SelectedIndex = index;

            HorizontalDateTimeAxis           axis   = dynamicChart.HorizontalAxis as HorizontalDateTimeAxis;
            ObservableDataSource <DatePoint> values = new ObservableDataSource <DatePoint>();

            values.SetYMapping(p => p.Y);
            values.SetXMapping(p => axis.ConvertToDouble(p.X));
            points.Add(values);
            graphs.Add(dynamicChart.AddLineGraph(values, 2, multimeter.handler.currentMeter));
            multimeter.graph = graphs.Last <LineGraph>();
        }
Exemple #10
0
        private void ChkItemRecord_OnChecked(object sender, RoutedEventArgs e)
        {
            ToggleButton chkSelecttedItem = (ToggleButton)sender;

            if (chkSelecttedItem.Content != null)
            {
                string nameLine = chkSelecttedItem.Tag.ToString();
                var    source   = new ObservableDataSource <PointsGraph>();
                source.SetXMapping(x => SpanAxis.ConvertToDouble(x.TimeG));
                source.SetYMapping(y => y.PointG);
                var uid = ((string)chkSelecttedItem.Uid).Split('.').Last();
                _lstGraph.Add(new GraphInfo
                {
                    LineGraph = Plotter.AddLineGraph(source, 2, nameLine),
                    Source    = source,
                    Uid       = uid
                });
                AddToLog("Отображен график: " + nameLine);
            }
        }
		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();
		}
        public EssaiChrono(InputOutput io)
        {
            InitializeComponent();
            p.Children.Remove(p.MouseNavigation);
            p.Children.Remove(p.HorizontalAxisNavigation);
            p.Children.Remove(p.VerticalAxisNavigation);
            p.Children.Remove(p.KeyboardNavigation);

            xMin      = d.ConvertToDouble(new TimeSpan(0));
            startXMax = d.ConvertToDouble(new TimeSpan(0, 0, a));
            p.Visible = new Rect {
                X = xMin, Width = startXMax - xMin, Y = startYMin, Height = startYMax - startYMin
            };
            p.AxisGrid.Visibility           = Visibility.Hidden;
            p.MainHorizontalAxis.Visibility = Visibility.Hidden;
            p.MainVerticalAxis.Visibility   = Visibility.Hidden;
            dataSource.SetXMapping(model => d.ConvertToDouble(model.interval));
            dataSource.SetYMapping((model) => { if (model.Value == true)
                                                {
                                                    return(1);
                                                }
                                                else
                                                {
                                                    return(0);
                                                } });

            //Bind the data with the graph
            chrono.DataSource = dataSource;

            //Labels
            if (io.Parent != null)
            {
                Legend.SetDescription(chrono, io.getEtiquette() + "_" + (((io.Parent as Grid).Parent as Canvas).Parent as Gate).outil.getLabel());
            }

            this.io     = io;
            Stop        = true;
            DataContext = this;
        }
Exemple #13
0
        public void UpdateUi()
        {
            var bar = Context.TargetElement;

            for (var i = plotter.Children.Count - 1; i >= 0; i--)
            {
                if (plotter.Children[i] is LineGraph)
                {
                    plotter.Children.RemoveAt(i);
                }
            }

            if (bar == null)
            {
                return;
            }

            var elementDiscPonits = Context.TargetElement.GetInternalForceDiscretationPoints(Context.SelectedLoadCase).Select(i => i.Xi).ToArray();

            var samples = 100;

            var lst = new List <double>(elementDiscPonits);

            //remove discrete points and add a little before and after

            var eps = 1e-10;

            foreach (var discPonit in elementDiscPonits)
            {
                lst.Add(discPonit - eps);
                lst.Add(discPonit + eps);
            }

            for (int i = 0; i <= samples; i++)
            {
                var c = i * 1.0 / samples;

                var xi = c * 2 - 1;

                lst.Add(xi);
            }

            var l2 = lst.Where(i => i >= -1 && i <= 1).Where(i => !elementDiscPonits.Contains(i)).Distinct().ToArray();

            Array.Sort(l2);

            var pts = new List <Point>();

            var lc = Context.SelectedLoadCase;

            for (var i = 0; i < l2.Length; i++)
            {
                var xi = l2[i];
                var x  = Context.TargetElement.IsoCoordsToLocalCoords(xi)[0];

                Force frc;

                if (Context.Type == BarInternalForceContext.ForceType.Approximate)
                {
                    frc = bar.GetInternalForceAt(xi, lc);
                }
                else
                {
                    frc = bar.GetExactInternalForceAt(xi, lc);
                }

                var y = 0.0;

                switch (Context.Component)
                {
                case BarInternalForceContext.ForceComponent.Fx:
                    y = frc.Fx;
                    break;

                case BarInternalForceContext.ForceComponent.Fy:
                    y = frc.Fy;
                    break;

                case BarInternalForceContext.ForceComponent.Fz:
                    y = frc.Fz;
                    break;

                case BarInternalForceContext.ForceComponent.Mx:
                    y = frc.Mx;
                    break;

                case BarInternalForceContext.ForceComponent.My:
                    y = frc.My;
                    break;

                case BarInternalForceContext.ForceComponent.Mz:
                    y = frc.Mz;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                pts.Add(new Point(x, y, 0));
            }

            var src = new ObservableDataSource <Point>(pts);

            src.SetXMapping(i => i.X);
            src.SetYMapping(i => i.Y);


            var gr = new LineGraph(src);

            gr.Stroke          = Brushes.Black;
            gr.StrokeThickness = 2;
            gr.Name            = Context.Component.ToString();

            plotter.Children.Add(gr);
            //plotter.AddLineGraph(src, Colors.Black, 2, Context.Component.ToString());
            Microsoft.Research.DynamicDataDisplay.Charts.Legend.SetDescription(gr, Context.Component.ToString());
        }
        private void BtnStart_OnClick(object sender, RoutedEventArgs e)
        {
            if (_ping == null)
            {
                Debug.Assert(_plotterChildren == null);
                Debug.Assert(_ds == null);
                try
                {
                    var host = (tbHost.Text ?? string.Empty).Trim();
                    if (string.IsNullOrWhiteSpace(host))
                    {
                        throw new ArgumentException("Host can not be empty.");
                    }
                    var interval = TimeSpan.Parse((tbInterval.Text ?? string.Empty));
                    if (interval <= TimeSpan.Zero)
                    {
                        throw new ArgumentException("Interval must be greater than zero.");
                    }
                    var timeout = TimeSpan.Parse((tbTimeout.Text ?? string.Empty));
                    if (timeout <= TimeSpan.Zero)
                    {
                        throw new ArgumentException("Timeout must be greater than zero.");
                    }
                    _ping = new PingClient(host, interval, timeout);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
                _ds = new ObservableDataSource<PingResult>();
                _ping.PingTick += PingOnPingTick;
                //_ping.PingException += PingOnPingException;
                _ds.SetXMapping(item => dateAxis.ConvertToDouble(item.DateTime));
                _ds.SetYMapping(item => item.TimeCost.TotalMilliseconds);
                _plotterChildren = new IPlotterElement[]
                {
                    new LineGraph(_ds)
                    {
                        LinePen = new Pen(new SolidColorBrush(Colors.Green), 2),
                        Description = new PenDescription(_ping.Host)
                    },
                    new MarkerPointsGraph(_ds) {Marker = new CirclePointMarker {Size = 5}}
                };
                foreach (var child in _plotterChildren)
                {
                    plotter.AddChild(child);
                }

                Header.Content = string.Format("Ping {0}", _ping.Host);
            }
            _ping.Start();

            btnStart.IsEnabled = false;
            btnPause.IsEnabled = true;
            pnSettings.IsEnabled = false;
        }
        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 UpdateUi()
        {
            //plotter.Children.Clear();


            for (var i = plotter.Children.Count - 1; i >= 0; i--)
            {
                if (plotter.Children[i] is LineGraph)
                {
                    plotter.Children.RemoveAt(i);
                }
            }

            if (Min >= Max)
            {
                return;
            }

            if (SamplingCount < 2)
            {
                return;
            }

            if (TargetFunction == null)
            {
                return;
            }

            var vals = new List <double>();

            var delta = (Max - Min) / (SamplingCount - 1);

            for (var i = 0; i < SamplingCount; i++)
            {
                vals.Add(Min + i * delta);
            }

            var pts = new List <Tuple <double, double> >();
            var fnc = TargetFunction;

            foreach (var val in vals)
            {
                pts.Add(Tuple.Create(val, fnc(val)));
            }

            var src = new ObservableDataSource <Tuple <double, double> >(pts);

            src.SetXMapping(i => i.Item1);
            src.SetYMapping(i => i.Item2);

            var thickNess = 2.0;
            var pen       = new Pen(new SolidColorBrush(GraphColor), thickNess);

            if (string.IsNullOrEmpty(VerticalAxisLabel))
            {
                plotter.AddLineGraph(src, GraphColor, thickNess);
            }
            else
            {
                plotter.AddLineGraph(src, pen, new StandardDescription(VerticalAxisLabel == null ? "" : VerticalAxisLabel));
            }


            var src2 = new ObservableDataSource <Tuple <double, double> >(pts);

            src2.SetXMapping(i => i.Item1);
            src2.SetYMapping(i => 0);

            plotter.AddLineGraph(src2);
        }
Exemple #17
0
        void BindingData()
        {
            if (!dtstart.Value.HasValue || !dtend.Value.HasValue)
            {
                return;
            }
            DateTime start = dtstart.Value.Value;
            DateTime end   = dtend.Value.Value;

            if ((end - start).Days > 7)
            {
                end         = start.AddDays(7);
                dtend.Value = end;
            }
            else if (start >= end)
            {
                end         = start.AddDays(1);
                dtend.Value = end;
            }
            HashSet <short> hash = new HashSet <short>();

            foreach (var item in sortlist)
            {
                item.Value.Collection.Clear();
                hash.Add(item.Key);
            }

            foreach (KeyValuePair <short, string> item in chklist.SelectedItems)
            {
                ObservableDataSource <HistoryData> source;
                if (!sortlist.TryGetValue(item.Key, out source))
                {
                    source = new ObservableDataSource <HistoryData>();
                    source.SetXMapping(X => hTimeSpanAxis.ConvertToDouble(X.TimeStamp));
                    source.SetSourceMapping(App.Server[item.Key]);
                    if (comodel.SelectedIndex == 0 ||
                        (comodel.SelectedIndex == 1 && sortlist.Count == 0))
                    //|| (comodel.SelectedIndex == 2 && (sortlist.Count == 0 || chklist.SelectedItems.Count == 1)))
                    {
                        plotterlist[item.Key] = chartPlotter1.AddLineGraph(source, 2, item.Value);
                    }
                    else
                    {
                        var innerPlotter = new InjectedPlotter()
                        {
                            SetViewportBinding = false
                        };
                        var axis = new HorizontalDateTimeAxis();
                        innerPlotter.Children.Add(axis);
                        innerPlotter.MainHorizontalAxis = axis;
                        innerPlotter.Children.Add(new VerticalAxis()
                        {
                            Placement = AxisPlacement.Right
                        });
                        innerPlotter.Children.Add(new VerticalAxisTitle()
                        {
                            Content = item.Value, Placement = AxisPlacement.Right
                        });
                        chartPlotter1.Children.Add(innerPlotter);
                        innerPlotter.AddLineGraph(source, 2, item.Value);
                        plotterlist.Add(item.Key, innerPlotter);
                    }
                    sortlist.Add(item.Key, source);
                }
                hash.Remove(item.Key);
                var data = App.Server.ReadRaw(start, end, item.Key);
                if (data != null)
                {
                    bool first = true;
                    var  temp  = new HistoryData(item.Key, QUALITIES.QUALITY_GOOD, Storage.Empty, start);
                    source.SuspendUpdate();
                    foreach (var p in data)
                    {
                        if (first)
                        {
                            temp.Value = p.Value;
                            source.Collection.Add(temp);
                            first = false;
                        }
                        source.Collection.Add(p);
                    }
                    if (source.Collection.Count == 0)
                    {
                        source.Collection.Add(temp);
                    }
                    temp           = source.Collection[source.Collection.Count - 1];
                    temp.TimeStamp = end;
                    source.Collection.Add(temp);
                    source.ResumeUpdate();
                }
                chartPlotter1.FitToView();
            }
            foreach (short id in hash)
            {
                sortlist.Remove(id);
                IPlotterElement plotter;
                if (plotterlist.TryGetValue(id, out plotter))
                {
                    var chart = plotter as Plotter;
                    if (chart != null)
                    {
                        for (int i = chart.Children.Count - 1; i >= 0; i--)
                        {
                            chart.Children[i].RemoveFromPlotter();
                        }
                    }
                    plotter.RemoveFromPlotter();
                    plotterlist.Remove(id);
                }
            }
        }