private void DrawGraph(ZedGraphControl DoThi, List <PredicResults> results) { //ve gia tri LineItem curve2_1 = DoThi.GraphPane.CurveList[0] as LineItem; LineItem curve2_2 = DoThi.GraphPane.CurveList[1] as LineItem; //init do thi. // Get the PointPairList IPointListEdit list21 = curve2_1.Points as IPointListEdit; IPointListEdit list22 = curve2_2.Points as IPointListEdit; list21.Clear(); list22.Clear(); DoThi.AxisChange(); DoThi.Invalidate(); int i = 0; foreach (var item in results) { var xdate = new XDate(item.Date); list21.Add(xdate, item.ActualClose); list22.Add(xdate, item.PredictedClose); // đoạn chương trình thực hiện vẽ đồ thị Scale xScale = DoThi.GraphPane.XAxis.Scale; i++; } // Vẽ đồ thị DoThi.AxisChange(); // Force a redraw DoThi.Invalidate(); }
public void ClearAllGraphData() { try { for (int i = 0; i < masterPane.PaneList.Count; i++) { if (masterPane.PaneList[i].CurveList.Count <= 0) { return; } foreach (CurveItem item in masterPane.PaneList[i].CurveList) { if (item is LineItem) { (item.Points as IPointListEdit).Clear(); } if (item is BarItem) { item.Points[0].Y = 0.0; } } masterPane.PaneList[i].AxisChange(); } graph.Invalidate(); } catch { throw new Exception("While Clearing data"); } }
public void ResetGraph() { zedgraph.AxisChange(); // Обновляем график zedgraph.Invalidate(); }
// METODO per il disegno grafico DR public void CreateGraphDeadReckoning(ZedGraphControl zgc, double[] spostamentoX, double[] spostamentoY) { if (zgc.InvokeRequired) { refreshInvokeDR d = new refreshInvokeDR(CreateGraphDeadReckoning); zgc.Invoke(d, zgc, spostamentoX, spostamentoY); } else { zgc.AxisChange(); zgc.Invalidate(); zgc.Refresh(); GraphPane myPane = zgc.GraphPane; myPane.Title.Text = "Estimated 2D path"; for (int i = 0; i < spostamentoX.Length; i++) { myPane.CurveList[0].AddPoint(new PointPair(spostamentoX[i], spostamentoY[i])); zgc.AxisChange(); zgc.Invalidate(); zgc.Refresh(); } zgc.AxisChange(); zgc.Invalidate(); zgc.Refresh(); startIndexDR = spostamentoX.Length; } }
private void button5_Click(object sender, EventArgs e) { try { if (connectTriger) { serialPort.PortName = serialPortName; serialPort.BaudRate = Convert.ToInt32(comboBox2.Text); serialPort.Open(); this.button5.Text = "Disconnect"; this.label13.Text = "Connected!"; connectTriger = false; this.button1.Enabled = true; this.trackBar1.Enabled = true; } else { serialPort.Close(); this.button5.Text = "Connect"; this.button1.Enabled = false; this.button2.Enabled = false; this.button3.Enabled = false; this.trackBar1.Enabled = false; timer.Stop(); trigerButton2 = false; myPane.CurveList.Clear(); lists = new PointPairList[4] { new PointPairList(), new PointPairList(), new PointPairList(), new PointPairList() }; myCurves = new LineItem[4]; dataCurves = new string[5] { null, null, null, null, null }; dataCurvesBuffer = new List <string>() { "0.00", "0.00", "0.00", "0.00" }; count = 0; i = 0; x = 0; y1 = 0; y2 = 0; y3 = 0; y4 = 0; global = 0; time = 0; zedGraph.GraphPane.YAxis.Scale.Min = 0; myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = 1.2; zedGraph.AxisChange(); zedGraph.Refresh(); zedGraph.Invalidate(); countTime = 0; this.label7.Text = "all time = " + Math.Round(x, 2) + " s"; this.label8.Text = "count = " + countTime; connectTriger = true; this.label13.Text = "Disconnected!"; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void UpdateCompleteGraph() { using (Graphics g = m_Graph.CreateGraphics()) { m_Graph.MasterPane.SetLayout(g, PaneLayout.SquareRowPreferred); m_Graph.MasterPane.DoLayout(g); } m_Graph.AxisChange(); m_Graph.Invalidate(); }
private void setChart(ZedGraphControl zedGraphControl, GraphPane graphPane, RollingPointPairList listPoint, double temperature) { zedGraphControl.GraphPane.CurveList.Clear(); zedGraphControl.AxisChange(); zedGraphControl.Invalidate(); listPoint.Add(timeSeconds, temperature + this.randomTem); graphPane.AddCurve("Điểm đo ", listPoint, Color.Red, SymbolType.Diamond); zedGraphControl.AxisChange(); zedGraphControl.Invalidate(); }
public void Clear() { GraphPane gPane = fGraph.GraphPane; gPane.Title.Text = ""; gPane.XAxis.Title.Text = ""; gPane.YAxis.Title.Text = ""; gPane.CurveList.Clear(); fGraph.AxisChange(); fGraph.Invalidate(); }
public void DrawCurve1(string label, PointPairList list) { GraphPane g = _graphControl.GraphPane; LineItem l = g.AddCurve(label, list, Color1, NodeSymbol1); l.Line.Width = Width1; l.Line.IsSmooth = UseSmoothing; _graphControl.AxisChange(); _graphControl.Invalidate(); }
public void Plot(PlotableFunction f, double min, double max) { LineItem ln = new LineItem(f.Name, GetPoints(f, min, max), linecolor, SymbolType.None); ln.Line.Style = f.DashStyle; ln.Line.Width = f.LineWidth; zgc.GraphPane.CurveList.Clear(); zgc.GraphPane.CurveList.Add(ln); zgc.AxisChange(); zgc.Invalidate(); }
public void DrawGraph(double[] x, List <double[]> t, double tenv) { GraphPane pane = zedGraph.GraphPane; pane.CurveList.Clear(); PointPairList list = null; for (int i = 0; i < t.Count - 1; i++) { list = new PointPairList(); for (int j = 0; j < x.Length; j++) { list.Add(x[j], t[i][j] /*> tenv ? t[i][j] : tenv*/); } pane.AddCurve("", list, Color.Blue, SymbolType.None); } list = new PointPairList(); for (int i = 0; i < x.Length; i++) { list.Add(x[i], t.Last()[i] /*> tenv ? t[i][j] : tenv*/); } pane.AddCurve("", list, Color.Red, SymbolType.Star); zedGraph.AxisChange(); zedGraph.Invalidate(); }
/// <summary> /// Update Graph /// </summary> /// <param name="list"></param> public void UpdateGraph(List <SickLidar.CartesianPoint> list, ZedGraphControl zgc, bool algorithm) { if (this.ppList != null) { this.ppList.Clear(); } if (zgc.GraphPane.CurveList != null) { zgc.GraphPane.CurveList.Clear(); } for (int i = 0; i < list.Count; i++) { this.ppList.Add(list[i].y, list[i].z); } //--generate a red curve--// this.myPane.AddCurve(null, this.ppList, Color.Red, SymbolType.None); //--tell zedgraph to refigure the axes since the data have changed--// //zgc.AxisChange(); //--make sure the graph gets re-drawn--// if (algorithm == false) { zgc.Invalidate(); } }
/// <summary> /// ZedGraph 드로잉(X가 30이상이면 Shifting) /// </summary> /// <param name="zed">ZedGraphControl</param> /// <param name="current">X값</param> private void drawZed(ZedGraphControl zed, double current) { if (zed.GraphPane.CurveList.Count <= 0) { return; } LineItem curve = zed.GraphPane.CurveList[0] as LineItem; if (curve == null) { return; } IPointListEdit list = curve.Points as IPointListEdit; if (list == null) { return; } list.Add(zedCnt, current); Scale xScale = zed.GraphPane.XAxis.Scale; if (zedCnt > xScale.Max - xScale.MajorStep) { xScale.Max = zedCnt + xScale.MajorStep; xScale.Min = xScale.Max - 30.0; } zed.AxisChange(); zed.Invalidate(); }
/// <summary> /// Draws the graph /// </summary> /// <param name="zgc"> /// The control for the graph element /// </param> /// <param name="measurements"> /// Points of the graph /// </param> private void CreateGraph(ZedGraphControl zgc, string measurements) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); PointPairList list = new PointPairList(); myPane.Title.Text = "TelosB Graph"; //put the received data in the graph XmlDocument tempdoc = new XmlDocument(); tempdoc.LoadXml(measurements); XmlNodeList bookList = tempdoc.GetElementsByTagName("MeasurementValue"); double x = 1; foreach (XmlNode node in bookList) { string yyyy = node.InnerText.ToString(); //listView2.Items.Add(id_Measurement2); double y = Convert.ToDouble(yyyy); x = x + 1; list.Add(x, y); } LineItem myCurve = myPane.AddCurve("My Curve", list, Color.Blue, SymbolType.Circle); //myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F); //myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F); zgc.AxisChange(); zgc.Invalidate(); }
private void CreateGraph(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; // Set the titles and axis labels myPane.Title.Text = "Activation Function"; //myPane.XAxis.Title.Text = "X"; //myPane.XAxis.Title.IsTitleAtCross = true; myPane.XAxis.Title.IsVisible = false; //myPane.YAxis.Title.Text = "Y"; //myPane.YAxis.Title.IsTitleAtCross = true; myPane.YAxis.Title.IsVisible = false; // Set the Y axis intersect the X axis at an X value of 0.0 myPane.YAxis.Cross = 0.0; myPane.XAxis.Cross = 0.0; myPane.Legend.IsVisible = true; // Turn off the axis frame and all the opposite side tics myPane.Chart.Border.IsVisible = false; myPane.XAxis.MajorTic.IsOpposite = false; myPane.XAxis.MinorTic.IsOpposite = false; myPane.YAxis.MajorTic.IsOpposite = false; myPane.YAxis.MinorTic.IsOpposite = false; // Calculate the Axis Scale Ranges zgc.AxisChange(); zgc.Invalidate(); }
private void xxxGraph_ZoomEvent(ZedGraphControl sender, ZoomState oldState, ZoomState newState) { ZedGraphControl zgc = (ZedGraphControl)sender; zgc.AxisChange(); zgc.Invalidate(); }
public void setFont() { GraphPane myPane = _zedGraphOutputCurve.GraphPane; //myPane.IsFontsScaled = false; //myPane.fontSpec.IsBold = false; //fontDialog.Font.Bold; //myPane.fontSpec.IsUnderline = false; // fontDialog.Font.Underline; //myPane.fontSpec.Size = 12; //myPane.fontSpec.Family = "仿宋"; //myPane.IsFontsScaled.fontSpec.Border.IsVisible = false; foreach (var item in myPane.YAxisList) { item.Title.FontSpec = this.fontSpec; } foreach (var item in myPane.Y2AxisList) { item.Title.FontSpec = this.fontSpec; } myPane.XAxis.Title.FontSpec = this.fontSpec; _zedGraphOutputCurve.AxisChange(); _zedGraphOutputCurve.Invalidate(); }
private void drawGraph(ZedGraphControl zedGraph, PointPairList list, string xTitle, string yTitle, string tableName) { GraphPane pane = zedGraph.GraphPane; //pane.CurveList.Clear(); Color color; pane.XAxis.Title.Text = xTitle; pane.YAxis.Title.Text = yTitle; pane.Title.Text = tableName; if (jIndex % 2 == 0) { color = Color.Blue; } else { color = Color.Red; } LineItem Curve = pane.AddCurve("", list, color, SymbolType.None); Curve.Line.IsSmooth = true; //pane.XAxis.MajorGrid.IsVisible = true; pane.YAxis.MajorGrid.IsVisible = true; zedGraph.Refresh(); zedGraph.AxisChange(); zedGraph.Invalidate(); jIndex++; }
public Control CreateTimeOfObjectSizeChart(ChartData chartData) { var chart = new ZedGraphControl(); chart.GraphPane.YAxis.Title.Text = "Time"; chart.GraphPane.XAxis.Title.Text = "Size"; chart.GraphPane.Title.Text = chartData.Title; chart.GraphPane.AddCurve( "Classes", chartData.ClassPoints.Select(z => (double)z.FieldsCount).ToArray(), chartData.ClassPoints.Select(z => z.AverageTime).ToArray(), Color.Red); chart.GraphPane.AddCurve( "Structures", chartData.StructPoints.Select(z => (double)z.FieldsCount).ToArray(), chartData.StructPoints.Select(z => z.AverageTime).ToArray(), Color.Blue); chart.GraphPane.XAxis.Scale.MinAuto = true; chart.GraphPane.XAxis.Scale.MaxAuto = true; chart.GraphPane.YAxis.Scale.MinAuto = true; chart.GraphPane.YAxis.Scale.MaxAuto = true; chart.AxisChange(); chart.Invalidate(); return(chart); }
private void DrawHistogram(ZedGraphControl control, PictureBox pictureBox) { control.GraphPane.CurveList.Clear(); control.GraphPane.AddCurve("Function", Histogram(pictureBox), Color.Blue, SymbolType.None); control.AxisChange(); control.Invalidate(); }
private void CreateGraph(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; PointPairList listPrev = new PointPairList(); PointPairList list = new PointPairList(); myPane.CurveList.Clear(); myPane.Title = "Picture"; for (int i = 0; i < Program.yPrev.Count; i++) { listPrev.Add(i, Program.yPrev[i]); } LineItem myCurve = myPane.AddCurve("Prev", listPrev, Color.Red, SymbolType.None); for (int j = 0; j < Program.y.Count; j++) { list.Add(j, Program.y[j]); } LineItem myCurve2 = myPane.AddCurve("Result", list, Color.Blue, SymbolType.None); zgc.AxisChange(); zgc.Invalidate(); zgc.Show(); }
void TimerEventProcessor(int d) { x1++; c++; samp.Add(d, x1); zgc.AxisChange(); zgc.Invalidate(); }
public void TraceGraph(ZedGraphControl ZGC, int TraceN) { TraceN = TraceN - 1; if (NTraces < TraceN) { throw new Exception("ошибка в открытии файла"); } //обработка открытия неверного формата файла GraphPane pane = ZGC.GraphPane; pane.CurveList.Clear(); PointPairList list = new PointPairList(); int beg = SEGYConstants.HeaderTxt + SEGYConstants.HeaderDyn; int ntb = TraceN * (SEGYConstants.TraceHeader + LTraces * 4); fs.Seek(beg + ntb + SEGYConstants.TraceHeader, SeekOrigin.Begin); //fs.Seek((SEGYConstants.HeaderTxt + (NTraces *(LTraces *4 +SEGYConstants.TraceHeader))+ SEGYConstants.HeaderDyn), SeekOrigin.Begin); byte[] buf = new byte[4]; for (int x = 1; x <= LTraces; x++) { fs.Read(buf, 0, 4); list.Add(x, SEGYFile.ReadWordIBM(buf)); } pane.XAxis.Title.Text = "время"; pane.YAxis.Title.Text = "амплитуда"; Color curveColor = Color.Red; LineItem curve = pane.AddCurve("SEGY", list, curveColor, SymbolType.None); pane.XAxis.Type = AxisType.Linear; curve.Line.IsSmooth = true; pane.YAxis.MajorGrid.IsVisible = true; ZGC.AxisChange(); ZGC.Invalidate(); }//построение графика трассы
public void CreateScatterplot(ZedGraphControl zgc, double[,] graph) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the titles myPane.Title.IsVisible = false; myPane.XAxis.Title.Text = columnNames[0]; myPane.YAxis.Title.Text = columnNames[1]; // Regression problem PointPairList list1 = new PointPairList(); for (int i = 0; i < graph.GetLength(0); i++) { list1.Add(graph[i, 0], graph[i, 1]); } // Add the curve LineItem myCurve = myPane.AddCurve("Y", list1, Color.Blue, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Blue); // Fill the background of the chart rect and pane myPane.Fill = new Fill(Color.WhiteSmoke); zgc.AxisChange(); zgc.Invalidate(); }
/// <summary> /// 设置到饼状图上 /// </summary> /// <param name="pane"></param> private void SetChart(DayReprot report, ZedGraphControl zgc) { GraphPane pane = zgc.GraphPane; pane.CurveList.Clear(); pane.GraphObjList.Clear(); pane.Title.Text = report.Date.ToString($"yyyy-MM-dd 生产情况"); pane.Title.FontSpec.IsItalic = true; pane.Title.FontSpec.Size = 12; pane.Title.FontSpec.Family = "微软雅黑"; //pane.Fill = new Fill(Color.White, Color.Goldenrod, 45.0f); //pane.Chart.Fill.Type = FillType.None; //pane.Legend.Position = LegendPos.Float; //pane.Legend.Location = new Location() addPie("生产时间", report.Times[TimeDefine.ProductTime].TotalMin, pane, Color.Navy); addPie("暂停时间", report.Times[TimeDefine.PauseTime].TotalMin, pane, Color.Yellow); addPie("DT时间", report.Times[TimeDefine.DTTime].TotalMin, pane, Color.Red); addPie("换线时间", report.Times[TimeDefine.ChangeLineTime].TotalMin, pane, Color.DarkRed); addPie("待板时间", report.Times[TimeDefine.WaitInputTime].TotalMin, pane, Color.Blue); addPie("进板时间", report.Times[TimeDefine.WaitOuputTime].TotalMin, pane, Color.Blue); pane.AxisChange(); zgc.Refresh(); zgc.Invalidate(); }
/// <summary> /// Create graph /// </summary> /// <param name="zgc"></param> /// <param name="gPane"></param> /// <param name="title"></param> /// <param name="x_title"></param> /// <param name="y_title"></param> private void CreateGraph(ref ZedGraphControl zgc, ref GraphPane gPane, string title, string x_title, string y_title) { // YZ Plane //--get a reference to the graphPane--// gPane = zgc.GraphPane; //--set the titles--// gPane.Title.Text = title; gPane.XAxis.Title.Text = x_title; gPane.YAxis.Title.Text = y_title; //--manually set the x axis range--// //gPane.XAxis.Scale.Min = -10.0; //gPane.XAxis.Scale.Max = 10.0; gPane.XAxis.MajorGrid.IsVisible = true; //--manually set the y axis range--// //gPane.YAxis.Scale.Min = -10.0; //gPane.YAxis.Scale.Max = 10.0; gPane.YAxis.MajorGrid.IsVisible = true; gPane.YAxis.MajorGrid.IsZeroLine = false; //--scale the axes--// zgc.AxisChange(); zgc.Invalidate(); }
private void UpdateGraph(ZedGraphControl graphControl, CenterSpace.Free.Histo histo) { //Build the graph GraphPane pane1 = graphControl.GraphPane; //Restart pane1.CurveList.Clear(); pane1.Title.Text = comboBoxTestToProcess.Text.Replace(".csv", ""); pane1.XAxis.Title.Text = "Bins"; pane1.YAxis.Title.Text = "Count"; //pane1.YAxis.Scale.Max = 3500; //pane1.XAxis.Scale.Min = -450; //pane1.XAxis.Scale.Max = 450; PointPairList histoList = new PointPairList(); for (int i = 0; i < histo.Counts.Length; i++) { histoList.Add(histo.BinBoundaries[i], histo.Counts[i]); } BarItem histoBar = pane1.AddBar("Count", histoList, Color.Aqua); graphControl.AxisChange(); graphControl.Invalidate(); }
public void DrawGraph(ICollection <double> array) { GraphPane pane = zedGraph.GraphPane; pane.CurveList.Clear(); var itemscount = array.Count; var barPosition = new double[itemscount]; for (int i = 0; i < itemscount; i++) { barPosition[i] = i + 1; } pane.AddBar("", barPosition, array.ToArray(), Color.Blue); pane.XAxis.Scale.Min = 0; pane.XAxis.Scale.Max = itemscount + 1; pane.YAxis.Scale.Max = 1; pane.XAxis.Scale.MajorStepAuto = true; pane.XAxis.Scale.MinorStep = 1; zedGraph.AxisChange(); zedGraph.Invalidate(); }
private void DrawValues(Complex[] funcValues, ZedGraphControl zedGraphControl, string title, Color color) { // Получим панель для рисования GraphPane pane = zedGraphControl.GraphPane; pane.XAxis.Title.Text = "N, номер отсчёта"; pane.YAxis.Title.Text = "Значение функции"; pane.Title.Text = title; // Очистим список кривых на тот случай, если до этого сигналы уже были нарисованы pane.CurveList.Clear(); // Создадим список точек PointPairList list = new PointPairList(); // Заполняем список точек for (int i = 0; i < funcValues.Length; i++) { // добавим в список точку list.Add(i, funcValues[i].Real); } LineItem myCurve = pane.AddCurve("", list, color, SymbolType.None); zedGraphControl.AxisChange(); // Обновляем график zedGraphControl.Invalidate(); }
/// <summary> /// Updates the ZedGraph /// </summary> /// <param name="zedGraph"></param> /// <param name="Data"></param> /// <param name="time"></param> public void UpdateZedGraph(ZedGraphControl zedGraph, Int16[] Data, int time) { if (zedGraph.GraphPane == null) { return; } int localTime = 0; double seconds = 0; rect = new Rectangle((int)zedGraph.GraphPane.Chart.Rect.X, (int)zedGraph.GraphPane.Chart.Rect.Y, (int)zedGraph.GraphPane.Chart.Rect.Width, (int)zedGraph.GraphPane.Chart.Rect.Height); // Make sure that the curvelist has at least one curve if (zedGraph.GraphPane.CurveList.Count <= 0) { return; } // Get the first CurveItem in the graph LineItem curve = zedGraph.GraphPane.CurveList[0] as LineItem; if (curve == null) { return; } // Get the PointPairList IPointListEdit list = curve.Points as IPointListEdit; //If time hits zero, Graph gets cleared and redrawn if (time == 0) { list.Clear(); // Force a redraw //zedGraph.Invalidate(); } // If this is null, it means the reference at curve.Points does not // support IPointListEdit, so we won't be able to modify it if (list == null) { return; } for (int i = 0; i < Data.Length; i++) { seconds = (double)(time + localTime) / Statics.FS; // Time is measured in seconds localTime++; // 3 seconds per cycle list.Add(seconds, Data[i]); } //Only redraw a certain area var xPix = (int)zedGraph.GraphPane.XAxis.Scale.Transform(seconds); rect.X = xPix - ((int)zedGraph.GraphPane.Chart.Rect.Width / 6); //- 20; rect.Width = (int)zedGraph.GraphPane.Chart.Rect.Width / 6 + 10; zedGraph.Invalidate(rect); }