public void CompositeDataSource() { var xValues = new List<CustomObjectWithStrings> { new CustomObjectWithStrings { X = "2.00000", Text = "Text 1" }, new CustomObjectWithStrings { X = "04", Text = "Text 2" }, new CustomObjectWithStrings { X = "+6.0", Text = "Text 3" }, }; var yValues = new List<CustomObjectWithXY> { new CustomObjectWithXY { MyY = 3, Text = "Text 1" }, new CustomObjectWithXY { MyY = 5, Text = "Text 2" }, new CustomObjectWithXY { MyY = 7, Text = "Text 3" }, }; var dataSource = new CompositeDataSource { XValues = xValues, YValues = yValues, }; var chartDataSource = ChartDataHelper.CreateChartDataSource(dataSource, new PropertyPath("X"), new PropertyPath("MyY"), null, CultureInfo.InvariantCulture, null, null); Assert.AreEqual(3, chartDataSource.Count); Assert.AreEqual(new Point(2, 3), chartDataSource[0].Point); Assert.AreEqual(new Point(4, 5), chartDataSource[1].Point); Assert.AreEqual(new Point(6, 7), chartDataSource[2].Point); Assert.AreEqual(new CompositeData(xValues[0], yValues[0]), chartDataSource[0].DataContext); Assert.AreEqual(new CompositeData(xValues[1], yValues[1]), chartDataSource[1].DataContext); Assert.AreEqual(new CompositeData(xValues[2], yValues[2]), chartDataSource[2].DataContext); }
void Window1_Loaded(object sender, RoutedEventArgs e) { plotter.DataTransform = new Log10Transform(); double[] xArray = new double[] { 15, 14, 16, 48, 50, 51 }; double[] yArray = new double[] { 60, 63, 64, 124, 131, 144 }; var xds = xArray.AsXDataSource(); var yds = yArray.AsYDataSource(); var ds = new CompositeDataSource(xds, yds); plotter.AddLineGraph(ds); // You can try to uncomment the following code /* * HorizontalAxis xAxis = new HorizontalAxis * { * TicksProvider = new LogarithmNumericTicksProvider(10), * LabelProvider = new UnroundingLabelProvider() * }; * plotter.MainHorizontalAxis = xAxis; * * VerticalAxis yAxis = new VerticalAxis * { * TicksProvider = new LogarithmNumericTicksProvider(10), * LabelProvider = new UnroundingLabelProvider() * }; * plotter.MainVerticalAxis = yAxis; */ }
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); }
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); }
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("亮度变化曲线")); }
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; }
private void ReloadData() { if (mainPlotter != null) { mainPlotter.RemoveAllGraphs(); linegraphs.Clear(); string location = (comboboxLocation.SelectedItem as ContentControl).Content as string; AllergologySample.DataProvider dataProvider = new DataProvider(location + ".xml"); mainPlotter.HorizontalAxis = new HorizontalDateTimeAxis(); try { dataProvider.Load(checkBoxGroupAlergens.IsChecked == true); foreach (string alergen in dataProvider.GetAlergens()) { var xs = dataProvider.GetXcomponents(alergen).AsXDataSource(); xs.SetXMapping(d => (mainPlotter.HorizontalAxis as HorizontalDateTimeAxis).ConvertToDouble(d)); var ys = dataProvider.GetYcomponents(alergen).AsYDataSource(); CompositeDataSource dataSource = xs.Join(ys); LineGraph linegraph = new LineGraph(dataSource, alergen); linegraphs.Add(linegraph); mainPlotter.Children.Add(linegraph); break; } mainPlotter.FitToView(); } catch (Exception ex) { MessageBox.Show(ex.Message + " " + ex.StackTrace); } } }
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); }
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 ButtonOpen_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.DefaultExt = ".txt"; dlg.Filter = "wav файлы (*.wav)|*.wav"; Nullable <bool> result = dlg.ShowDialog(); if (result == true) { ReadWav file = new ReadWav(); byte[] data = file.StartReadWav(dlg.FileName); double step = 1.0; var x = Enumerable.Range(0, data.Length).Select(i => i * step).ToArray(); var y = x.Select(v => data[(int)(v / step)] * 1.0).ToArray(); var xDataSource = x.AsXDataSource(); var yDataSource = y.AsYDataSource(); CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource); plotter.AddLineGraph(compositeDataSource, Colors.Goldenrod, 3, "Sine"); plotter.FitToView(); } }
void Page_Loaded(object sender, RoutedEventArgs e) { #region Prepering arrays with data const int N = 200; DateTime[] x = new DateTime[N]; double[] y = new double[N]; TimeSpan step = new TimeSpan(23, 11, 21, 31); x[0] = new DateTime(1990, 1, 1); y[0] = 0; for (int i = 1; i < N; i++) { x[i] = x[i - 1] + step; y[i] = (Int32)(y[i - 1] + Math.E) % 37; } #endregion //Here we replace default numeric axis with DateTime Axis dateAxis = new HorizontalDateTimeAxis(); plotter.HorizontalAxis = dateAxis; //Now we should set xMapping using ConvertToDouble method var xDataSource = x.AsXDataSource(); xDataSource.SetXMapping(d => dateAxis.ConvertToDouble(d)); var yDataSource = y.AsYDataSource(); CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource); LineGraph line = new LineGraph(compositeDataSource, "Graph depends on DateTime"); // plotter.Children.Add(line); plotter.FitToView(); }
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); }
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); } }
/// <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(); }
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); }
void MainWindow_Loaded(object sender, RoutedEventArgs e) { // Prepare data in arrays const int N = 1000; 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.Sin(x[i]); } // Create data sources: var xDataSource = x.AsXDataSource(); var yDataSource = y.AsYDataSource(); CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource); // adding graph to plotter plotter.AddLineGraph(compositeDataSource, Colors.Goldenrod, 3, "Sine"); // Force evertyhing plotted to be visible plotter.FitToView(); }
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; }
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; }
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!"); } }
void Window1_Loaded(object sender, RoutedEventArgs e) { plotter.Children.Add(new HorizontalLine { Value = 0, Stroke = Brushes.DarkGreen.MakeTransparent(0.2) }); plotter.Children.Add(new VerticalLine { Value = 0, Stroke = Brushes.DarkGreen.MakeTransparent(0.2) }); #if old var xs = Enumerable.Range(0, 500).Select(i => (i - 250) * 0.02); var sineYDS = xs.Select(x => Math.Sin(x)).AsYDataSource(); var atanYDS = xs.Select(x => Math.Atan(x)).AsYDataSource(); var sineDS = new CompositeDataSource(xs.AsXDataSource(), sineYDS); var atanDS = new CompositeDataSource(xs.AsXDataSource(), atanYDS); var sineChart = plotter.AddLineGraph(sineDS); var atanChart = plotter.AddLineGraph(atanDS); //sineChart.Filters.Clear(); //atanChart.Filters.Clear(); #else var xs = Enumerable.Range(0, 500).Select(i => (i - 250) * 0.02); var sineDS = xs.Select(x => new Point(x, Math.Sin(x))).AsDataSource(); var atanDS = xs.Select(x => new Point(x, Math.Atan(x))).AsDataSource(); var sincDS = Enumerable.Range(-5000, 10001).Select(i => { double x = Math.PI * i / 1000; double y; if (i == 0) { y = 100; } else { y = Math.Sin(x * 100); } return(new Point(x, y)); }).AsDataSource(); LineChart sincChart = new LineChart { Stroke = ColorHelper.RandomBrush, DataSource = sincDS }; //plotter.Children.Add(sincChart); LineChart sineChart = new LineChart { Stroke = ColorHelper.RandomBrush, DataSource = sineDS }; plotter.Children.Add(sineChart); LineChart atanChart = new LineChart { Stroke = ColorHelper.RandomBrush, DataSource = atanDS }; plotter.Children.Add(atanChart); #endif }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { // Prepare data in arrays const int N = 1000; 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.Restrictions.Add(new PhysicalProportionsRestriction { 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 void funcSin(double[] x, double[] y, Plotter2D ReadSinPlotter, LineGraph readSinGraph) { EnumerableDataSource <double> xDataSource = x.AsXDataSource(); EnumerableDataSource <double> yDataSource = y.AsYDataSource(); CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource); readSinGraph = ReadSinPlotter.AddLineGraph(compositeDataSource, Colors.AliceBlue, 3, "Sin"); ReadSinPlotter.FitToView(); }
private void Visit(CompositeDataSource compositeDS) { if (compositeDS == null) { return; } foreach (var dataPart in compositeDS.DataParts) { VisitEnumerable(dataPart); } }
private void Visit(IPointDataSource dataSource) { if (dataSource == null) { return; } CompositeDataSource compositeDS = dataSource as CompositeDataSource; Visit(compositeDS); VisitEnumerable(dataSource); }
private void Window1_Loaded(object sender, RoutedEventArgs e) { List <BugInfo> bugInfoList = LoadBugInfo("..\\..\\BugInfo.txt"); int[] dates = new int[bugInfoList.Count]; int[] numberOpen = new int[bugInfoList.Count]; int[] numberClosed = new int[bugInfoList.Count]; for (int i = 0; i < bugInfoList.Count; ++i) { dates[i] = bugInfoList[i].date; numberOpen[i] = bugInfoList[i].numberOpen; numberClosed[i] = bugInfoList[i].numberClosed; } var datesDataSource = new EnumerableDataSource <int>(dates); datesDataSource.SetXMapping(x => x); var numberOpenDataSource = new EnumerableDataSource <int>(numberOpen); numberOpenDataSource.SetYMapping(y => y); var numberClosedDataSource = new EnumerableDataSource <int>(numberClosed); numberClosedDataSource.SetYMapping(y => y); CompositeDataSource compositeDataSource1 = new CompositeDataSource(datesDataSource, numberOpenDataSource); CompositeDataSource compositeDataSource2 = new CompositeDataSource(datesDataSource, numberClosedDataSource); plotter.AddLineGraph(compositeDataSource1, new Pen(Brushes.Blue, 2), new CirclePointMarker { Size = 10.0, Fill = Brushes.Red }, new PenDescription("Number bugs open")); plotter.AddLineGraph(compositeDataSource2, new Pen(Brushes.Green, 2), new TrianglePointMarker { Size = 10.0, Pen = new Pen(Brushes.Black, 2.0), Fill = Brushes.GreenYellow }, new PenDescription("Number bugs closed")); plotter.Viewport.FitToView(); } // Window1_Loaded()
private void Window_Loaded(object sender, RoutedEventArgs e) { List <RankingByYear> rankingList = LoadBugInfo(54, 2); //s&d per pielle DateTime[] dates = new DateTime[rankingList.Count]; double[] punteggi = new double[rankingList.Count]; double[] numberClosed = new double[rankingList.Count]; for (int i = 0; i < rankingList.Count; ++i) { dates[i] = new DateTime(rankingList[i].Anno, i + 1, 1); punteggi[i] = rankingList[i].Punteggio; //numberClosed[i] = rankingList[i].numberClosed; } var datesDataSource = new EnumerableDataSource <DateTime>(dates); datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x)); var numberOpenDataSource = new EnumerableDataSource <double>(punteggi); numberOpenDataSource.SetYMapping(y => y); //var numberClosedDataSource = new EnumerableDataSource<int>(numberClosed); //numberClosedDataSource.SetYMapping(y => y); CompositeDataSource compositeDataSource1 = new CompositeDataSource(datesDataSource, numberOpenDataSource); //CompositeDataSource compositeDataSource2 = new // CompositeDataSource(datesDataSource, numberClosedDataSource); plotter.AddLineGraph(compositeDataSource1, new Pen(Brushes.Blue, 2), new CirclePointMarker { Size = 10.0, Fill = Brushes.Red }, new PenDescription("Sword and Dagger")); //plotter.AddLineGraph(compositeDataSource2, // new Pen(Brushes.Green, 2), // new TrianglePointMarker // { // Size = 10.0, // Pen = new Pen(Brushes.Black, 2.0), // Fill = Brushes.GreenYellow // }, // new PenDescription("Number bugs closed")); plotter.Viewport.FitToView(); } // Window1_Loaded()
/// <summary> /// 绘制曲线 /// </summary> private void Curve() { try { int len = _aValues.Length / 2, index = 0; DateTime[] dates = new DateTime[len]; Double[] numberOpen = new Double[len]; Double[] intDate = new Double[len]; for (int i = 0; i < _aValues.Length; ++i) { if (_vValues[i] > 64436 && _aValues[i] > 0) { if (i > 0 && _vValues[i] == _vValues[i - 1]) { continue; } //DateTime dt = Convert.ToDateTime("01/01/000" + (_vValues[i] - 64436)); DateTime dt = Convert.ToDateTime("01/01/000" + (i + 1)); dates[index] = dt; //intDate[index] = (int)_vValues[i]; numberOpen[index] = (Double)_aValues[i]; index++; } } var datesDataSource = new EnumerableDataSource <DateTime>(dates); datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x)); //var datesDataSource = new EnumerableDataSource<Double>(intDate); //datesDataSource.SetXMapping(x => dateAxis.ConvertFromDouble(x)); var numberOpenDataSource = new EnumerableDataSource <Double>(numberOpen); numberOpenDataSource.SetYMapping(y => y); CompositeDataSource compositeDataSource1 = new CompositeDataSource(datesDataSource, numberOpenDataSource); plotter.AddLineGraph(compositeDataSource1, new Pen(Brushes.Red, 2), new CirclePointMarker { Size = 2.0, Fill = Brushes.Blue }, new PenDescription("Number bugs open")); plotter.Viewport.FitToView(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { for (int i = 0; i < count; i++) { xs[i] = i / (double)count; ys[i] = i / (double)count; } ds = new CompositeDataSource(new DataSourcePartCollection( new DataSourcePart(xs, "X"), new DataSourcePart(ys, "Y"))); chart.DataSource = ds; }
/// <summary> /// drawing chart for list of lists of records /// </summary> /// <param name="results">list of list of records</param> public void drawChart(List <List <Record> > results) { List <DateTime> dates = new List <DateTime>(); List <Double> nr = new List <Double>(); String nameOfStock = ""; // int i = 0; foreach (List <Record> re in results) { foreach (Record r in re) { dates.Add(r.DateOfRecord); Double close = (Double)r.Close; nr.Add(close); nameOfStock = r.CompanySymbol; } } var datesDataSource = new EnumerableDataSource <DateTime>(dates); datesDataSource.SetXMapping(x => dateAxis.ConvertToDouble(x)); var numberOpenDataSource = new EnumerableDataSource <Double>(nr); numberOpenDataSource.SetYMapping(y => y); CompositeDataSource compositeDataSource = new CompositeDataSource(datesDataSource, numberOpenDataSource); Console.WriteLine("nOfS : " + nameOfStock); if (!string.IsNullOrEmpty(nameOfStock)) { plotter.AddLineGraph(compositeDataSource, getRandomColor(), 3, nameOfStock); // Force evertyhing plotted to be visible plotter.FitToView(); } Console.WriteLine("plotterChild count : " + plotter.Children.Count()); }
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); }
/// <summary> /// Отображает функцию f на графике /// </summary> private void drawFunction(Function f, Function noisedF) { if (f != null) { LinkedList <double> x = new LinkedList <double>(), y = new LinkedList <double>(); for (double _x = f.minX; _x < f.maxX + f.step / 2; _x += f.step) { x.AddLast(_x); y.AddLast(f.getValue(_x)); } var xDataSource = x.AsXDataSource(); var yDataSource = y.AsYDataSource(); CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource); functionGraph.DataSource = compositeDataSource; } else { functionGraph.DataSource = new CompositeDataSource(); } if (noisedF != null) { LinkedList <double> x = new LinkedList <double>(), y = new LinkedList <double>(); for (double _x = noisedF.minX; _x < noisedF.maxX + noisedF.step / 2; _x += noisedF.step) { x.AddLast(_x); y.AddLast(noisedF.getValue(_x)); } var xDataSource = x.AsXDataSource(); var yDataSource = y.AsYDataSource(); CompositeDataSource compositeDataSource = xDataSource.Join(yDataSource); noisedFunctionGraph.DataSource = compositeDataSource; } else { noisedFunctionGraph.DataSource = new CompositeDataSource(); } chart.LegendVisible = false; chart.FitToView(); }
public void PlotGraph() { // Create data sources: var xDataSource = time_x.AsXDataSource(); var yDataSourceTemp = temp_y.AsYDataSource(); var yDataSourceHum = hum_y.AsYDataSource(); var yDataSourcePress = press_y.AsYDataSource(); var yDataSourceLight = light_y.AsYDataSource(); CompositeDataSource compositeDataSource = xDataSource.Join(yDataSourceTemp); // Adding graph to plotter main.plotter.AddLineGraph( compositeDataSource, Colors.DarkRed, 1, "Temp"); CompositeDataSource compositeDataSourceHum = xDataSource.Join(yDataSourceHum); main.plotter2.AddLineGraph( compositeDataSourceHum, Colors.CadetBlue, 1, "Hum"); CompositeDataSource compositeDataSourcePress = xDataSource.Join(yDataSourcePress); main.plotter3.AddLineGraph( compositeDataSourcePress, Colors.DarkGreen, 1, "Press"); CompositeDataSource compositeDataSourceLight = xDataSource.Join(yDataSourceLight); main.plotter4.AddLineGraph( compositeDataSourceLight, Colors.Gold, 1, "Light"); main.plotter.FitToView(); main.plotter2.FitToView(); main.plotter3.FitToView(); main.plotter4.FitToView(); }