void bt_Click(object sender, RoutedEventArgs e) { Dictionary <TimeTrend, System.Data.DataTable> tables = new Dictionary <TimeTrend, System.Data.DataTable>(); foreach (TimeTrend trend in Trends) { Archiver.ChannelInfo ci = new Archiver.ChannelInfo(); String[] strs = trend.Channel.Split('.'); ci.PluginId = strs[0]; ci.ChannelName = strs[1]; List <Archiver.ChannelInfo> channels = new List <FreeSCADA.Archiver.ChannelInfo>(); channels.Add(ci); System.Data.DataTable dt = Archiver.ArchiverMain.Current.GetChannelData(_from.SelectedDate.Value, _to.SelectedDate.Value, channels); //System.Data.DataTable dt = new System.Data.DataTable(); trend.ChartData.Clear(); foreach (System.Data.DataRow row in dt.Rows) { DateTime date = new DateTime(); double val = double.NaN; DateTime.TryParse(row["Time"].ToString(), out date); double.TryParse(row["Value"].ToString(), out val); trend.ChartData.Add( new TimeChartData { _time = date, _value = val }); } trend.DataSource.RaiseDataChanged(); } _chart.FitToView(); }
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(); }
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(); }
void Page_Loaded(object sender, RoutedEventArgs e) { //Creating plotter without a legend and button navigation ChartPlotterSettings settings = new ChartPlotterSettings(); settings.IsButtonNavigationPresents = false; settings.IsLegendPresents = false; mainPlotter = new ChartPlotter(settings); RootStackPanel.Children.Add(mainPlotter); //Adding legened to custom location legend = new Legend(mainPlotter); //Wrapper to provide easy usage of the legend if it is too big ScrollWraper wraper = new ScrollWraper(legend); RootStackPanel.Children.Insert(0, wraper); //Adding custom buttons to plotter hovering panel buttonAdd = new Button() { Content = "Add random polynomial" }; buttonAdd.Click += new RoutedEventHandler(ButtonAddClick); buttonClear = new Button() { Content = "Remove all charts" }; buttonClear.Click += new RoutedEventHandler(ButtonClearClick); StackPanel internalStackPanel = new StackPanel() { Orientation = Orientation.Vertical, Margin = new Thickness(5) }; internalStackPanel.Children.Add(buttonAdd); internalStackPanel.Children.Add(buttonClear); mainPlotter.HoveringStackPanel.Children.Add(internalStackPanel); //Adding button navigation to custom location Microsoft.Research.DynamicDataDisplay.Navigation.buttonsNavigation n = new Microsoft.Research.DynamicDataDisplay.Navigation.buttonsNavigation(mainPlotter); RootStackPanel.Children.Add(n); //Adding some data to the plotter for (int i = 0; i < 10; i++) { addRandomPolynomial(); } mainPlotter.FitToView(); }
public Basechart(Dispatcher p,ChartPlotter newchart,Dictionary<string, string> packagelist) { //Init variables disp = p; chart = newchart; chart.FitToView(); datalist = new Dictionary<string, ObservableDataSource<Point>>(); //Set timer timerSine = new DispatcherTimer(); timerSine.Tick += new EventHandler(timerSine_Tick); timerSine.Interval = new TimeSpan(0, 0, 1); //Start draw chart pkglist = packagelist; foreach (KeyValuePair<string, string> pkg in pkglist) { datalist.Add(pkg.Key, new ObservableDataSource<Point>()); chart. chart.AddLineGraph(datalist[pkg.Key], Color.FromRgb(178, 58, 238), 2, pkg.Key); } timerSine.Start(); }
public void funcAmp(double[][] amp, ChartPlotter specPlotter, List <LineGraph>[] ampGraph) { EnumerableDataSource <double> xDataSource; EnumerableDataSource <double> yDataSource; int a = 0; ky = 0.1f; x1 = 0; hx = 0.01f; for (int i = 0; i < amp[0].Length / 2; i++) { List <LineGraph> cds = new List <LineGraph>(); for (int k = 0; k < amp.Length; k++) { double[] x = new double[2]; double[] y = new double[2]; y1 = (float)(amp[k][i]); if (y1 > 0.1) { x[0] = i; x[1] = x[0]; y[0] = 0; y[1] = y1; xDataSource = x.AsXDataSource(); yDataSource = y.AsYDataSource(); CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource); LineGraph graph = new LineGraph(compositeDataSource); Brush brush = new SolidColorBrush(col[k]); graph.LinePen = new Pen(brush, 3); graph.Description = new PenDescription(names[k]); cds.Add(graph); } if (i == 127) { x1 = 0; } } if (cds.Count > 0) { cds.Sort((p, p1) => p1.DataSource.GetPoints().Last().Y.CompareTo(p.DataSource.GetPoints().Last().Y)); ampGraph[i] = cds; foreach (LineGraph lg in cds) { lg.AddToPlotter(specPlotter); } } } specPlotter.FitToView(); }
private void ButtonAddClick(object sender, RoutedEventArgs e) { addRandomPolynomial(); mainPlotter.FitToView(); }