private void CreateGraph_MultiYDemo( ZedGraphControl z1 ) { GraphPane myPane = z1.GraphPane; // Set the titles and axis labels myPane.Title.Text = "Demonstration of Multi Y Graph"; myPane.XAxis.Title.Text = "Time, s"; myPane.YAxis.Title.Text = "Velocity, m/s"; myPane.Y2Axis.Title.Text = "Acceleration, m/s2"; // Make up some data points based on the Sine function PointPairList vList = new PointPairList(); PointPairList aList = new PointPairList(); PointPairList dList = new PointPairList(); PointPairList eList = new PointPairList(); // Fabricate some data values for ( int i = 0; i < 30; i++ ) { double time = (double) i; double acceleration = 2.0; double velocity = acceleration * time; double distance = acceleration * time * time / 2.0; double energy = 100.0 * velocity * velocity / 2.0; aList.Add( time, acceleration ); vList.Add( time, velocity ); eList.Add( time, energy ); dList.Add( time, distance ); } // -------------------------------------------------------------------- // Velocity Curve // Generate a red curve with diamond symbols, and "Velocity" in the legend LineItem myCurve = myPane.AddCurve( "Velocity", vList, Color.Red, SymbolType.Diamond ); // Fill the symbols with white myCurve.Symbol.Fill = new Fill( Color.White ); // Generate a blue curve with circle symbols, and "Acceleration" in the legend myCurve = myPane.AddCurve( "Acceleration", aList, Color.Blue, SymbolType.Circle ); // Fill the symbols with white myCurve.Symbol.Fill = new Fill( Color.White ); // Associate this curve with the Y2 axis myCurve.IsY2Axis = true; // ------------------------------------------------------------------- // -------------------------------------------------------------------- // Distance Curve // Generate a green curve with square symbols, and "Distance" in the legend myCurve = myPane.AddCurve( "Distance", dList, Color.Green, SymbolType.Square ); // Fill the symbols with white myCurve.Symbol.Fill = new Fill( Color.White ); // Associate this curve with the second Y axis myCurve.YAxisIndex = 1; // -------------------------------------------------------------------- // -------------------------------------------------------------------- // Energy Curve // Generate a Black curve with triangle symbols, and "Energy" in the legend myCurve = myPane.AddCurve( "Energy", eList, Color.Black, SymbolType.Triangle ); // Fill the symbols with white myCurve.Symbol.Fill = new Fill( Color.White ); // Associate this curve with the Y2 axis myCurve.IsY2Axis = true; // Associate this curve with the second Y2 axis myCurve.YAxisIndex = 1; // -------------------------------------------------------------------- // Show the x axis grid myPane.XAxis.MajorGrid.IsVisible = true; // Make the Y axis scale red myPane.YAxis.Scale.FontSpec.FontColor = Color.Red; myPane.YAxis.Title.FontSpec.FontColor = Color.Red; // turn off the opposite tics so the Y tics don't show up on the Y2 axis myPane.YAxis.MajorTic.IsOpposite = false; myPane.YAxis.MinorTic.IsOpposite = false; // Don't display the Y zero line myPane.YAxis.MajorGrid.IsZeroLine = false; // Align the Y axis labels so they are flush to the axis myPane.YAxis.Scale.Align = AlignP.Inside; // Enable the Y2 axis display myPane.Y2Axis.IsVisible = true; // Make the Y2 axis scale blue myPane.Y2Axis.Scale.FontSpec.FontColor = Color.Blue; myPane.Y2Axis.Title.FontSpec.FontColor = Color.Blue; // turn off the opposite tics so the Y2 tics don't show up on the Y axis myPane.Y2Axis.MajorTic.IsOpposite = false; myPane.Y2Axis.MinorTic.IsOpposite = false; // Display the Y2 axis grid lines myPane.Y2Axis.MajorGrid.IsVisible = true; // Align the Y2 axis labels so they are flush to the axis myPane.Y2Axis.Scale.Align = AlignP.Inside; myPane.Y2Axis.Scale.Min = 1.5; /////////////////////////////////////////////////////////////////// // Create a second Y Axis, green YAxis yAxis3 = new YAxis( "Distance, m" ); myPane.YAxisList.Add( yAxis3 ); yAxis3.Scale.FontSpec.FontColor = Color.Green; yAxis3.Title.FontSpec.FontColor = Color.Green; yAxis3.Color = Color.Green; // turn off the opposite tics so the Y2 tics don't show up on the Y axis yAxis3.MajorTic.IsInside = false; yAxis3.MinorTic.IsInside = false; yAxis3.MajorTic.IsOpposite = false; yAxis3.MinorTic.IsOpposite = false; // Align the Y2 axis labels so they are flush to the axis yAxis3.Scale.Align = AlignP.Inside; ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// Y2Axis yAxis4 = new Y2Axis( "Energy" ); yAxis4.IsVisible = true; myPane.Y2AxisList.Add( yAxis4 ); // turn off the opposite tics so the Y2 tics don't show up on the Y axis yAxis4.MajorTic.IsInside = false; yAxis4.MinorTic.IsInside = false; yAxis4.MajorTic.IsOpposite = false; yAxis4.MinorTic.IsOpposite = false; // Align the Y2 axis labels so they are flush to the axis yAxis4.Scale.Align = AlignP.Inside; yAxis4.Type = AxisType.Log; yAxis4.Scale.Min = 100; ///////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// Y2Axis yAxis5 = new Y2Axis( "Another one" ); yAxis5.IsVisible = true; myPane.Y2AxisList.Add( yAxis5 ); // turn off the opposite tics so the Y2 tics don't show up on the Y axis yAxis5.MajorTic.IsInside = false; yAxis5.MinorTic.IsInside = false; yAxis5.MajorTic.IsOpposite = false; yAxis5.MinorTic.IsOpposite = false; // Align the Y2 axis labels so they are flush to the axis yAxis5.Scale.Align = AlignP.Inside; //yAxis5.Type = AxisType.Log; ///////////////////////////////////////////////////////////////// // Fill the axis background with a gradient myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45.0f ); myPane.IsAlignGrids = true; // Assume this is an old one Y2Axis test = new Y2Axis( "test" ); // save the scale Scale saveScale = test.Scale; // throw away the "old" Y2 axis myPane.Y2AxisList.RemoveAt( 1 ); // Create a new YAxis int index = myPane.YAxisList.Add( "test" ); // replace the actual scale data foreach ( YAxis axis in myPane.YAxisList ) { if ( String.Compare( axis.Title.Text, "test", true ) == 0 ) { // make a new scale axis.Scale.MakeNewScale( saveScale, AxisType.Linear ); } } //int index2 = myPane.YAxisList.IndexOf( "test" ); //int x = myPane.YAxisList.IndexOf( "test" ); //int poop = x; //YAxis axis = myPane.YAxisList.Find( null ); //myPane.YAxisList.Add( test ); z1.AxisChange(); z1.Refresh(); //for ( int i = 0; i < 10000000; i++ ) // ; //myPane.Y2AxisList.RemoveAt( myPane.Y2AxisList.Count - 1 ); //myPane.Y2AxisList.RemoveAt( myPane.Y2AxisList.Count - 1 ); //z1.Refresh(); }
public void UpdateAllZedGraph() { zedGraphControlAccS0.AxisChange(); zedGraphControlAccS1.AxisChange(); zedGraphControlAccS2.AxisChange(); zedGraphControlAccS3.AxisChange(); zedGraphControlAccS4.AxisChange(); zedGraphControlGirS0.AxisChange(); zedGraphControlGirS1.AxisChange(); zedGraphControlGirS2.AxisChange(); zedGraphControlGirS3.AxisChange(); zedGraphControlGirS4.AxisChange(); zedGraphControlThetaS0.AxisChange(); /*zedGraphControlThetaS1.AxisChange(); * zedGraphControlThetaS2.AxisChange(); * zedGraphControlThetaS3.AxisChange(); * zedGraphControlThetaS4.AxisChange();*/ zedGraphControlStandLaySit.AxisChange(); zedGraphControlAccS0.Invalidate(); zedGraphControlAccS1.Invalidate(); zedGraphControlAccS2.Invalidate(); zedGraphControlAccS3.Invalidate(); zedGraphControlAccS4.Invalidate(); zedGraphControlGirS0.Invalidate(); zedGraphControlGirS1.Invalidate(); zedGraphControlGirS2.Invalidate(); zedGraphControlGirS3.Invalidate(); zedGraphControlGirS4.Invalidate(); zedGraphControlThetaS0.Invalidate(); /*zedGraphControlThetaS1.Invalidate(); * zedGraphControlThetaS2.Invalidate(); * zedGraphControlThetaS3.Invalidate(); * zedGraphControlThetaS4.Invalidate();*/ zedGraphControlStandLaySit.Invalidate(); zedGraphControlAccS0.Refresh(); zedGraphControlAccS1.Refresh(); zedGraphControlAccS2.Refresh(); zedGraphControlAccS3.Refresh(); zedGraphControlAccS4.Refresh(); zedGraphControlGirS0.Refresh(); zedGraphControlGirS1.Refresh(); zedGraphControlGirS2.Refresh(); zedGraphControlGirS3.Refresh(); zedGraphControlGirS4.Refresh(); zedGraphControlThetaS0.Refresh(); /*zedGraphControlThetaS1.Refresh(); * zedGraphControlThetaS2.Refresh(); * zedGraphControlThetaS3.Refresh(); * zedGraphControlThetaS4.Refresh();*/ zedGraphControlStandLaySit.Refresh(); }
public void Draw(double data, double data1, double data2) { if (zedGraphControl.GraphPane.CurveList.Count <= 0) { return; } LineItem curve = zedGraphControl.GraphPane.CurveList[0] as LineItem; LineItem curve1 = zedGraphControl.GraphPane.CurveList[1] as LineItem; LineItem curve2 = zedGraphControl.GraphPane.CurveList[2] as LineItem; if (curve == null) { return; } if (curve1 == null) { return; } IPointListEdit list = curve.Points as IPointListEdit; IPointListEdit list1 = curve1.Points as IPointListEdit; IPointListEdit list2 = curve2.Points as IPointListEdit; if (list == null) { return; } // Time is measured in seconds double time = (Environment.TickCount - TickStart) / 1000.0; list.Add(time, data); // Thêm điểm trên đồ thị list1.Add(time, data1); list2.Add(time, data2); Scale xScale = zedGraphControl.GraphPane.XAxis.Scale; Scale yScale = zedGraphControl.GraphPane.YAxis.Scale; // Tự động Scale theo trục x if (time > xScale.Max - xScale.MajorStep) { xScale.Max = time + xScale.MajorStep; xScale.Min = xScale.Max - 30; } // Tự động Scale theo trục y if (data > yScale.Max - yScale.MajorStep) { yScale.Max = data + yScale.MajorStep; } else if (data < yScale.Min + yScale.MajorStep) { yScale.Min = data - yScale.MajorStep; } zedGraphControl.AxisChange(); zedGraphControl.Invalidate(); zedGraphControl.Refresh(); }
private void CreateGraph(ZedGraphControl zgc) { // // clear old coordinates // myPane.CurveList.Clear(); zgc.AxisChange(); // Generate a LightBlue curve with circle symbols, and "My Curve" in the legend LineItem CurveS = myPane.AddCurve("Series GA", PPlist[0], Color.LightBlue, SymbolType.Diamond); // Generate a PaleVioletRed curve with circle symbols, and "My Curve" in the legend LineItem CurveP = myPane.AddCurve("Parallel GA", PPlist[1], Color.PaleVioletRed, SymbolType.Circle); float allPointSize = 50F; // Fill the area under the curve with a white-red gradient at 45 degrees CurveS.Line.Fill = new Fill(Color.Transparent, Color.LightBlue, allPointSize); // Make the symbols opaque by filling them with white CurveS.Symbol.Fill = new Fill(Color.Transparent); // Fill the area under the curve with a white-red gradient at 45 degrees CurveP.Line.Fill = new Fill(Color.Transparent, Color.PaleVioletRed, allPointSize); // Make the symbols opaque by filling them with white CurveP.Symbol.Fill = new Fill(Color.Transparent); // Calculate the Axis Scale Ranges zgc.AxisChange(); zgc.Refresh(); }
public void DrawTimeSeries(SeriesList list, string title, string subTitle, bool undoZoom, bool multiLeftAxis = false) { CreateSeries(list, title, subTitle, undoZoom, multiLeftAxis); for (int i = 0; i < list.Count; i++) { FillTimeSeries(list[i], chart1.GraphPane.CurveList[i]); } FormatBottomAxisStandard(); chart1.RestoreScale(chart1.GraphPane); pane.YAxis.Scale.Mag = 0; pane.YAxis.Scale.Format = "#,#"; LabelYaxis(list); chart1.Refresh(); }
private void ClearGauge(int idx) { if (lblGuage1.InvokeRequired) { ClearDataCallback d = new ClearDataCallback(ClearGauge); this.Invoke(d, new object[] { idx }); } else { ZedGraph.ZedGraphControl currZG = null; System.Windows.Forms.Label currLabel = null; System.Windows.Forms.AGauge currGauge = null; if (idx == 1) { currZG = zg1; currLabel = lblGuage1; currGauge = gauge1; } if (idx == 2) { currZG = zg2; currLabel = lblGuage2; currGauge = gauge2; } if (idx == 3) { currZG = zg3; currLabel = lblGuage3; currGauge = gauge3; } if (currZG != null) { GraphPane myPane = currZG.GraphPane; myPane.Title.Text = "No data."; myPane.CurveList.Clear();// clear the graph currZG.Invalidate(); currZG.Refresh(); } if (currLabel != null) { currLabel.Text = "No data"; } if (currGauge != null) { currGauge.Value = 0; } } }
private void asignarGrafica(ZedGraphControl z, int i) { CurveList g = new CurveList(); g = h.getGrafica(i); if (g != null) { z.GraphPane.CurveList = g; z.Invalidate(); z.Refresh(); } }
protected void MenuStrip_ClearLast(object sender, EventArgs e) { while (m_MeasurerBeamList.Count > 0) { var temp = m_MeasurerBeamList[m_MeasurerBeamList.Count - 1]; m_MeasurerBeamList.Remove(temp); var tempText = m_MeasurerBeamTextList[m_MeasurerBeamTextList.Count - 1]; m_MeasurerBeamTextList.Remove(tempText); if (m_Control.GraphPane.GraphObjList.IndexOf(tempText) > -1) { m_Control.GraphPane.GraphObjList.Remove(tempText); } if (m_Control.GraphPane.CurveList.IndexOf(temp) <= -1) { continue; } m_Control.GraphPane.CurveList.Remove(temp); break; } m_Control.Refresh(); }
public void DrawTimeSeries(GraphData list, string title, string subTitle, bool undoZoom, bool multiLeftAxis = false) { CreateSeries(list, title, subTitle, undoZoom, multiLeftAxis); int i = 0; foreach (DataTable s in list.Tables) { if (s.TableName.Length > 5 && s.TableName.Remove(5) == "table") { FillTimeSeries(s, chart1.GraphPane.CurveList[i]); } i++; } FormatBottomAxisStandard(); chart1.RestoreScale(chart1.GraphPane); pane.YAxis.Scale.Mag = 0; pane.YAxis.Scale.Format = "#,#"; LabelYaxis(list); chart1.Refresh(); }
private void ApplyChangesToGraphControl(ZedGraphControl graphControl) { if (chkLogX.Checked) graphControl.GraphPane.XAxis.Type = AxisType.Log; else graphControl.GraphPane.XAxis.Type = AxisType.Linear; if (chkLogY.Checked) graphControl.GraphPane.YAxis.Type = AxisType.Log; else graphControl.GraphPane.YAxis.Type = AxisType.Linear; graphControl.IsAntiAlias = chkAntiAlias.Checked; if (chkXAuto.Checked) { graphControl.GraphPane.XAxis.Scale.MaxAuto = chkXAuto.Checked; graphControl.GraphPane.XAxis.Scale.MinAuto = chkXAuto.Checked; } else { graphControl.GraphPane.XAxis.Scale.Min = Util.ConvertToDouble(txtMinX.Text, graphControl.GraphPane.XAxis.Scale.Min); graphControl.GraphPane.XAxis.Scale.Max = Util.ConvertToDouble(txtMaxX.Text, graphControl.GraphPane.XAxis.Scale.Max); } if (chkYAuto.Checked) { graphControl.GraphPane.YAxis.Scale.MaxAuto = chkYAuto.Checked; graphControl.GraphPane.YAxis.Scale.MinAuto = chkYAuto.Checked; } else { graphControl.GraphPane.YAxis.Scale.Min = Util.ConvertToDouble(txtMinY.Text, graphControl.GraphPane.YAxis.Scale.Min); graphControl.GraphPane.YAxis.Scale.Max = Util.ConvertToDouble(txtMaxY.Text, graphControl.GraphPane.YAxis.Scale.Max); } graphControl.AxisChange(); graphControl.Refresh(); }
public static ZedGraphControl KresliGraf(string nazovGrafu,List<Spread> myCustomObjects, ZedGraphControl zg1) { zg1.GraphPane.CurveList.Clear(); zg1.GraphPane.GraphObjList.Clear(); GraphPane myPane = zg1.GraphPane; // Set the titles and axis labels myPane.Title.Text = nazovGrafu; myPane.XAxis.Title.Text = "Date"; myPane.YAxis.Title.Text = "$"; myPane.XAxis.Type = AxisType.Date; PointPairList list = new PointPairList(); int rok = myCustomObjects.First().Date.Year; DateTime predchadzDatum = myCustomObjects.First().Date; foreach (var item in myCustomObjects) { var x = (double)new XDate(DateTime.Parse(item.Date.ToShortDateString())); var y = item.Value; //Console.WriteLine(x + " " + y); list.Add(x, y); //Console.WriteLine(rok + " > " + item.Date.Year.ToString() + " " + (item.Date + " > " + new DateTime(item.Date.Year, 1, 1)).ToString() + " " + (predchadzDatum + " < " + new DateTime(item.Date.Year, 1, 1)).ToString()); //Console.WriteLine((rok > item.Date.Year).ToString() + " " + (item.Date > new DateTime(item.Date.Year, 1, 1)).ToString() + " " + (predchadzDatum < new DateTime(item.Date.Year, 1, 1)).ToString()); if (item.Date.Year != predchadzDatum.Year) { LineItem line = new LineItem(String.Empty, new[] { x, x }, new[] { myPane.YAxis.Scale.Min, myPane.YAxis.Scale.Max }, Color.Black, SymbolType.None); line.Line.Style = System.Drawing.Drawing2D.DashStyle.Dash; line.Line.Width = 1f; myPane.CurveList.Add(line); Console.WriteLine("Datum " + item.Date); } predchadzDatum = item.Date; } myPane.CurveList.Add(new LineItem("My Curve", list, Color.Blue, SymbolType.None)); zg1.Refresh(); // LineItem myCurve = myPane.AddCurve("My Curve", list, Color.Blue, SymbolType.None); zg1.AxisChange(); return zg1; }
internal void OnMouseUp(ZedGraphControl sender, MouseEventArgs e) { m_HighLight?.Close(); m_HighLight = null; var range = m_Max - m_Min; if (e.Location == m_Start || Vertical ? (e.Location.X <= m_Min || e.Location.X >= m_Max) : (e.Location.Y <= m_Min || e.Location.Y >= m_Max) || range == 0) { return; } var ratio = (float)((Vertical ? e.Location.X : e.Location.Y) - m_Min) / range; sender.MasterPane.SetProportion(this, ratio); sender.Invalidate(); sender.Refresh(); }
private void CreateGraph(ZedGraph.ZedGraphControl zgc, IList <double> costsList) { GraphPane myPane = zgc.GraphPane; myPane.Title.Text = "Koszt w kolejnych iteracjach"; myPane.XAxis.Title.Text = "Numer iteracji"; myPane.YAxis.Title.Text = "Koszt"; PointPairList list1 = new PointPairList(); list1.Clear(); for (int i = 0; i < costsList.Count; i++) { list1.Add(new PointPair(i, costsList[i])); } LineItem myCurve = myPane.AddCurve(null, list1, Color.Red); zgc.AxisChange(); zgc.Refresh(); }
private bool ZG_MouseMoveEvent(ZedGraphControl control, MouseEventArgs e) { if (!m_MeasurerActivated) { return(false); // tell the ZedGraphControl to handle it } // update the target point var point = control.GraphPane.ReverseTransformCoord(e.X, e.Y, Coord); var scale = control.GraphPane.XAxis.Scale; var value = scale.Value(control.GraphPane, (int)Math.Round(point.X), point.X); m_MeasurerBeam.Points[1].X = value; m_MeasurerBeam.Points[1].Y = point.Y; // control.GraphPane.ReverseTransform(new Point(e.X, e.Y), // out m_MeasurerBeam.Points[1].X, out m_MeasurerBeam.Points[1].Y); // force a redraw control.Refresh(); // tell the ZedGraphControl not to do anything else with this event return(true); }
private void CreateGraph_Clone( ZedGraphControl z1 ) { MasterPane master = z1.MasterPane; Border myBorder = new Border(); myBorder.IsVisible = false; master.Border = myBorder; master.PaneList.Clear(); master.Title.Text = "First try"; master.Margin.All = 10; master.InnerPaneGap = 10; // Enable the master pane legend master.Legend.IsVisible = true; master.Legend.Position = ZedGraph.LegendPos.TopCenter; GraphPane[] myPane = new GraphPane[3]; for ( int j = 0; j < 3; j++ ) { if ( j < 2 ) myPane[j] = new GraphPane( new RectangleF( 40, 40, 150, 100 ), "", "", "" ); else myPane[j] = new GraphPane( new RectangleF( 40, 40, 300, 100 ), "", "", "" ); myPane[j].Fill = new Fill( Color.BlanchedAlmond ); // myPane(j).AxisFill = New ZedGraph.Fill(Color.SeaGreen) myPane[j].BaseDimension = 6.0F; myPane[j].XAxis.Title.IsVisible = true; myPane[j].XAxis.Scale.IsVisible = true; myPane[j].Legend.IsVisible = false; myPane[j].Border.IsVisible = false; myPane[j].Title.IsVisible = true; myPane[j].Margin.All = 0; // This sets the minimum amount of space for the left and right side, respectively // The reason for this is so that the AxisRects all end up being the same size. myPane[j].YAxis.MinSpace = 50; myPane[j].Y2Axis.MinSpace = 20; master.Add( myPane[j] ); } using ( Graphics g = CreateGraphics() ) master.SetLayout( g, PaneLayout.ExplicitCol21 ); //Call GetMonthlist() //myPane[0] = zgHistogram.GraphPane.Clone; //myPane[1] = zgProbability.GraphPane.Clone; //myPane[2] = zgTimeSeries.GraphPane.Clone; // instead of // Call CreateGraph_TimeSeries(zgM, myPane(2)) // Call CreateGraph_Probability(zgM, myPane(1)) // Call CreateGraph_Histogram(zgM, myPane(0)) z1.AxisChange(); z1.Refresh(); }
public void CreateChart(ZedGraphControl zgc) { EventHandler method = null; this._myMainPane.YAxis.MajorGrid.IsVisible = true; this._myMainPane.YAxis.MinorGrid.IsVisible = true; this._myMainPane.CurveList.Clear(); this._myMainPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45f); this._myMainPane.Title.Text = this._reportTitle; this._myMainPane.XAxis.Title.Text = "Data"; this._myMainPane.YAxis.Title.Text = "Probability"; this._myMainPane.YAxis.Scale.MaxAuto = false; this._myMainPane.YAxis.Scale.MinAuto = false; this._myMainPane.YAxis.Scale.Max = 1.0; this._myMainPane.YAxis.Scale.Min = 0.0; if ((this._myMainXaxisData != null) && (this._myMainXaxisData.Length > 0)) { Stats stats = new Stats(); double[] y = new double[this._myMainXaxisData.Length]; for (int i = 0; i < this._myMainXaxisData.Length; i++) { y[i] = (i + 1) * (1.0 / ((double) this._myMainXaxisData.Length)); } stats.SortArray(this._myMainXaxisData.Length, this._myMainXaxisData); this._myMainPane.AddCurve(this._curveLabel, this._myMainXaxisData, y, this._curveColor, SymbolType.Diamond); this._myMainPane.AxisChange(); if (method == null) { method = delegate { zgc.Update(); zgc.Refresh(); }; } base.Invoke(method); } zgc.Size = new Size(base.ClientRectangle.Width - 0x19, base.ClientRectangle.Height - 0x2d); }
/** * Grafico vazio: usado quando aparecem ocupacoes negativas (erros nos dados) */ private void CreateEmptyChart(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; // Set the GraphPane title myPane.Title.Text = ""; myPane.Fill.Color = Color.LightGray; myPane.Chart.Fill.Type = FillType.None; // Adicionar as fatias: myPane.CurveList.Clear(); myPane.AddPieSlice(1, Color.LightSlateGray, Color.White, 45f, .0, "Ocupação não calculável"); zgc.AxisChange(); zgc.Refresh(); }
//--------------------------实时显示---------------------- private void AddPoint(ref ZedGraphControl zedgraph, ref PointPairList list, double x, double y) { try { //LineItem mycurve = zedgraph.GraphPane.AddCurve("", list, Color.DarkBlue, SymbolType.Circle); list.Add(x, y); if (list.Count > 120) list.RemoveAt(0); if (zedgraph != null) { zedgraph.AxisChange(); zedgraph.Refresh(); } } catch (Exception Ex) { MessageBox.Show(Ex.ToString()); return; } finally { GC.Collect(); } }
void zgc_ScrollDoneEvent( ZedGraphControl sender, ScrollBar scrollBar, ZoomState oldState, ZoomState newState ) { // When scroll action is finished, recalculate the axis ranges sender.AxisChange(); sender.Refresh(); }
private void SoapDeSerialize( ZedGraphControl z1, string fileName ) { if ( z1 != null && !String.IsNullOrEmpty( fileName ) ) { SoapFormatter mySerializer = new SoapFormatter(); Stream myReader = new FileStream( fileName, FileMode.Open, FileAccess.Read, FileShare.Read ); MasterPane master = (MasterPane) mySerializer.Deserialize( myReader ); z1.Refresh(); myReader.Close(); z1.MasterPane = master; //trigger a resize event z1.Size = z1.Size; } }
private void CreateGraph_PolyTest( ZedGraphControl z1 ) { GraphPane junk = z1.GraphPane.Clone(); // Get a reference to the GraphPane instance in the ZedGraphControl GraphPane myPane = z1.GraphPane; PointD[] corners = new PointD[4]; corners[0] = new PointD( 300.0f, 85.0f ); corners[1] = new PointD( 400.0f, 85.0f ); corners[2] = new PointD( 400.0f, 95.0f ); corners[3] = new PointD( 300.0f, 95.0f ); PolyObj poly1 = new PolyObj( corners, Color.Empty, Color.Red ); PointD[] corners3 = new PointD[3]; corners3[0] = new PointD( 300.0f, 88.0f ); corners3[1] = new PointD( 375.0f, 95.0f ); corners3[2] = new PointD( 300.0f, 95.0f ); PolyObj poly3 = new PolyObj( corners3, Color.Empty, Color.LightGreen ); PointD[] corners2 = new PointD[3]; corners2[0] = new PointD( 333.0f, 85.0f ); corners2[1] = new PointD( 400.0f, 91.0f ); corners2[2] = new PointD( 400.0f, 85.0f ); PolyObj poly2 = new PolyObj( corners2, Color.Empty, Color.Cyan ); myPane.GraphObjList.Add( poly3 ); myPane.GraphObjList.Add( poly2 ); myPane.GraphObjList.Add( poly1 ); myPane.XAxis.Scale.Min = 250; myPane.XAxis.Scale.Max = 450; myPane.YAxis.Scale.Min = 80; myPane.YAxis.Scale.Max = 100; z1.AxisChange(); z1.Refresh(); //Serialize( z1, "junk.bin" ); //z1.MasterPane.PaneList.Clear(); //DeSerialize( z1, "junk.bin" ); }
private void RefreshChart(ZedGraphControl chart) { chart.GraphPane.AxisChange(); chart.Refresh(); }
private void axisChangeZedGraph(ZedGraphControl zg) { if (zg.InvokeRequired) { axisChangeZedGraphCallBack ad = new axisChangeZedGraphCallBack(axisChangeZedGraph); zg.Invoke(ad, new object[] { zg }); } else { zg.AxisChange(); zg.Invalidate(); zg.Refresh(); } }
private void CreateGraph(ZedGraphControl zgc) { // // clear old coordinates // myPane.CurveList.Clear(); zgc.AxisChange(); // // Make up some data points from the Sine function PointPairList[] list = new PointPairList[5]; int minValue = 0, maxValue = 0; // // set data according by selectedIndex // switch (cmbCoordinateName.SelectedIndex) { case 0: // DX (Distance of the fox from rabbit on X axis) Input data { // size of screen 0 800 minValue = -FuzzyLogic.Width; // Rabbit is very Right than Fox (F-----------R) DX = xFox-xRabbit = -800 maxValue = FuzzyLogic.Width; // Rabbit is very Left than Fox (R-----------F) DX = xFox-xRabbit = +800 } break; case 1: // DY (Distance of the fox from rabbit on Y axis) Input data { // size of screen 0 800 minValue = -FuzzyLogic.Height; // Rabbit is very Up than Fox (F-----------R) DY = xFox-xRabbit = -800 maxValue = FuzzyLogic.Height; // Rabbit is very Down than Fox (R-----------F) DY = xFox-xRabbit = +800 } break; case 2: // DXF (Amount of the fox displacement distances on the X axis) case 3: // DYF (Amount of the fox displacement distances on the Y axis) { // Amount of the fox displacement distances minValue = -FuzzyLogic.maxStepSpeed; // (F-----------R) // -30 // maxValue = FuzzyLogic.maxStepSpeed; // (R-----------F) // +30 } break; } // // set double GaussianArray according by selectedIndex // double[,] gaussianBuffer = new double[5, 2]; switch (cmbCoordinateName.SelectedIndex) { case 0: gaussianBuffer = FuzzyLogic.gaussianData_DX; break; case 1: gaussianBuffer = FuzzyLogic.gaussianData_DY; break; case 2: gaussianBuffer = FuzzyLogic.gaussianData_DXF; break; case 3: gaussianBuffer = FuzzyLogic.gaussianData_DYF; break; } // for (int i = 0; i < 5; i++) // 5 type for gaussian Coordinate in one plot { list[i] = new PointPairList(); for (double x = minValue; x <= maxValue; x++) { double y = FuzzyLogic.Gaussian(x, gaussianBuffer[i, 0], gaussianBuffer[i, 1]); list[i].Add(x, y); } } // Generate a blue curve with circle symbols, and "My Curve" in the legend LineItem Curve0 = myPane.AddCurve(grb0.Text, list[0], grb0.ForeColor, SymbolType.Circle); LineItem Curve1 = myPane.AddCurve(grb1.Text, list[1], grb1.ForeColor, SymbolType.Circle); LineItem Curve2 = myPane.AddCurve(grb2.Text, list[2], grb2.ForeColor, SymbolType.Circle); LineItem Curve3 = myPane.AddCurve(grb3.Text, list[3], grb3.ForeColor, SymbolType.Circle); LineItem Curve4 = myPane.AddCurve(grb4.Text, list[4], grb4.ForeColor, SymbolType.Circle); float allPointSize = 50F; // Fill the area under the curve with a white-red gradient at 45 degrees Curve0.Line.Fill = new Fill(Color.Transparent, grb0.ForeColor, allPointSize); // Make the symbols opaque by filling them with white Curve0.Symbol.Fill = new Fill(Color.Transparent); // Fill the area under the curve with a white-red gradient at 45 degrees Curve1.Line.Fill = new Fill(Color.Transparent, grb1.ForeColor, allPointSize); // Make the symbols opaque by filling them with white Curve1.Symbol.Fill = new Fill(Color.Transparent); // Fill the area under the curve with a white-red gradient at 45 degrees Curve2.Line.Fill = new Fill(Color.Transparent, grb2.ForeColor, allPointSize); // Make the symbols opaque by filling them with white Curve2.Symbol.Fill = new Fill(Color.Transparent); // Fill the area under the curve with a white-red gradient at 45 degrees Curve3.Line.Fill = new Fill(Color.Transparent, grb3.ForeColor, allPointSize); // Make the symbols opaque by filling them with white Curve3.Symbol.Fill = new Fill(Color.Transparent); // Fill the area under the curve with a white-red gradient at 45 degrees Curve4.Line.Fill = new Fill(Color.Transparent, grb4.ForeColor, allPointSize); // Make the symbols opaque by filling them with white Curve4.Symbol.Fill = new Fill(Color.Transparent); // Calculate the Axis Scale Ranges zgc.AxisChange(); zgc.Refresh(); }
public void CreateFrameTimeGraph(ZedGraphControl zg, IList<string> projectInfo, IEnumerable<ProteinBenchmark> benchmarks, IList<Color> graphColors) { Debug.Assert(zg != null); try { // get a reference to the GraphPane GraphPane myPane = zg.GraphPane; // Clear the bars myPane.CurveList.Clear(); // Clear the bar labels myPane.GraphObjList.Clear(); // Clear the XAxis Project Information myPane.XAxis.Title.Text = String.Empty; // If no Project Information, get out if (projectInfo.Count == 0) { return; } // Create the bars for each benchmark int i = 0; foreach (ProteinBenchmark benchmark in benchmarks) { var yPoints = new double[2]; yPoints[0] = benchmark.MinimumFrameTime.TotalSeconds; yPoints[1] = benchmark.AverageFrameTime.TotalSeconds; CreateBar(i, myPane, benchmark.OwningSlotName, yPoints, graphColors); i++; } // Create the bar labels BarItem.CreateBarLabels(myPane, true, String.Empty, zg.Font.Name, zg.Font.Size, Color.Black, true, false, false); // Set the Titles myPane.Title.Text = "HFM.NET - Client Benchmarks"; var sb = new StringBuilder(); for (i = 0; i < projectInfo.Count - 2; i++) { sb.Append(projectInfo[i]); sb.Append(" / "); } sb.Append(projectInfo[i]); myPane.XAxis.Title.Text = sb.ToString(); myPane.YAxis.Title.Text = "Frame Time (Seconds)"; // Draw the X tics between the labels instead of at the labels myPane.XAxis.MajorTic.IsBetweenLabels = true; // Set the XAxis labels var labels = new[] { "Min. Frame Time", "Avg. Frame Time" }; myPane.XAxis.Scale.TextLabels = labels; // Set the XAxis to Text type myPane.XAxis.Type = AxisType.Text; // Fill the Axis and Pane backgrounds myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F); myPane.Fill = new Fill(Color.FromArgb(250, 250, 255)); } finally { // Tell ZedGraph to refigure the // axes since the data have changed zg.AxisChange(); // Refresh the control zg.Refresh(); } }
private bool init_zed(ref ZedGraphControl zed, PointPairList list1, PointPairList list2) { try { LineItem myCurve1; LineItem myCurve2; //list.Clear(); zed.GraphPane.CurveList.Clear();//折线图清空 zed.GraphPane.GraphObjList.Clear(); zed.AxisChange(); zed.Refresh(); // list = init_zed_data(4, comboBox2.Text.ToString(), 1, 120); myCurve1 = zed.GraphPane.AddCurve("深基点", list1, Color.Red, SymbolType.None); myCurve2 = zed.GraphPane.AddCurve("浅基点", list2, Color.Blue, SymbolType.None); zed.AxisChange(); zed.Refresh(); return true; } catch { return false; } }
private void CreateGraph_junk6( ZedGraphControl z1 ) { z1.GraphPane.Title.Text = "My Test Graph\n(For CodeProject Sample)"; z1.GraphPane.XAxis.Title.Text = "My X-Axis"; z1.GraphPane.YAxis.Title.Text = "My Y-Axis"; z1.Refresh(); }
private bool ZG_MouseUpEvent(ZedGraphControl control, MouseEventArgs e) { if (!e.Button.Equals(MouseButtons.Left)) { return(false); } // indicate to the mouse movement event that we finished with the measurer-beam m_MeasurerActivated = false; // calculate the distance var ds = 1.0; if ((m_Control.GraphPane.XAxis.Type == AxisType.Date) || (m_Control.GraphPane.XAxis.Type == AxisType.DateAsOrdinal)) { switch (m_Control.GraphPane.XAxis.Scale.MajorUnit) { case DateUnit.Year: ds = 1.0 / 365.0; break; case DateUnit.Day: ds = 1.0; break; case DateUnit.Hour: ds = 24.0; break; case DateUnit.Minute: ds = 24.0 * 60.0; break; case DateUnit.Second: ds = 24.0 * 60.0 * 60.0; break; case DateUnit.Millisecond: ds = 24.0 * 60.0 * 60.0 * 1000.0; break; } } double dx = (m_MeasurerBeam.Points[1].X - m_MeasurerBeam.Points[0].X) * ds; double dy = m_MeasurerBeam.Points[1].Y - m_MeasurerBeam.Points[0].Y; double distance = Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2)); // if this is only a point and not an actual measurer beam - remove it // otherwise, add it to our "watch-list" if (distance == 0.0) { m_Control.GraphPane.CurveList.Remove(m_MeasurerBeam); } else { // calculate the position for the text double cx = (m_MeasurerBeam.Points[1].X + m_MeasurerBeam.Points[0].X) / 2; double cy = (m_MeasurerBeam.Points[1].Y + m_MeasurerBeam.Points[0].Y) / 2; // calculate the angle for the text (must be done in screen coordinates) PointF p1 = control.GraphPane.GeneralTransform(m_MeasurerBeam.Points[0].X, m_MeasurerBeam.Points[0].Y, Coord); PointF p2 = control.GraphPane.GeneralTransform(m_MeasurerBeam.Points[1].X, m_MeasurerBeam.Points[1].Y, Coord); // add text to describe the distance (if one dimension is much bigger than the other // AND axes type are different - create a text only for the bigger dimension) var text = new TextObj($"{distance:N3}", cx, cy, Coord, AlignH.Center, AlignV.Bottom); if (!m_Control.GraphPane.YAxis.Type.Equals(m_Control.GraphPane.XAxis.Type)) { double dpx = Math.Abs(p2.X - p1.X); double dpy = Math.Abs(p2.Y - p1.Y); if (dpx > 20.0 * dpy) { text.Text = $"{Math.Abs(dx):N3} [ {m_Control.GraphPane.XAxis.Scale.MajorUnit}s ]"; } else if (dpy > 20.0 * dpx) { text.Text = $"{Math.Abs(dy):N3} [ {m_Control.GraphPane.YAxis.Type} ]"; } } text.FontSpec.Angle = 0.0f; // Convert.ToSingle(-Math.Atan((p2.Y - p1.Y) / (p2.X - p1.X)) * 180.0 / Math.PI); text.FontSpec.FontColor = m_FontColor; text.FontSpec.Size = m_FontSize; text.FontSpec.Border.IsVisible = false; m_Control.GraphPane.GraphObjList.Add(text); // add tooltip to describe the distance (and add a point in the middle) var dXdYstr = $"Distance: {distance:N3}\ndy: {Math.Abs(dy):N3} [{m_Control.GraphPane.YAxis.Type}]\n" + $"dx: {Math.Abs(dx):N3} [{m_Control.GraphPane.XAxis.Scale.MajorUnit}]"; m_MeasurerBeam.AddPoint(cx, cy); for (int i = 0; i < 3; i++) { m_MeasurerBeam.Points[i].Tag = dXdYstr; } // add curve and its text to the "watch-list" m_MeasurerBeamTextList.Add(text); m_MeasurerBeamList.Add(m_MeasurerBeam); } // force a redraw control.Refresh(); // tell the ZedGraphControl not to do anything else with this event return(true); }
private void refresh(ZedGraphControl zedC) { zedC.AxisChange(); zedC.RestoreScale(zedC.GraphPane); zedC.Refresh(); }
private bool old_zedGraphControl1_MouseMoveEvent( ZedGraphControl control, MouseEventArgs e ) { GraphPane myPane = control.GraphPane; PointF mousePt = new PointF( e.X, e.Y ); // see if a dragging operation is underway if ( isDragPoint ) { // get the scale values that correspond to the current point double curX, curX2, curY, curY2; myPane.ReverseTransform( mousePt, out curX, out curX2, out curY, out curY2 ); // if it's a Y2 axis, use that value instead of Y if ( dragCurve.IsY2Axis ) curY = curY2; // calculate the new scale values for the point PointPair newPt = new PointPair( startPair.X + curX - startX, (int) ( startPair.Y + curY - startY + 0.5 ) ); // save the data back to the point list ( dragCurve.Points as PointPairList )[dragIndex] = newPt; // force a redraw control.Refresh(); // tell the ZedGraphControl not to do anything else with this event return true; } else { //change the cursor if the mouse is sufficiently close to a point if ( myPane.FindNearestPoint( mousePt, out dragCurve, out dragIndex ) && dragCurve.Points is PointPairList && dragCurve.YAxisIndex == 0 ) { control.Cursor = Cursors.SizeAll; } else { control.Cursor = Cursors.Default; } } // since we didn't handle the event, tell the ZedGraphControl to handle it return false; }
/// <summary> /// 综合查询绘制曲线 /// </summary> /// <param name="type">传感器类型</param> /// <param name="d_begin">开始时间</param> /// <param name="d_over">结束时间</param> /// <param name="cgq">传感器编号</param> /// <param name="cgq_order">通道(支柱压力传感器为:前柱、后柱、前悬梁,顶板离层为:深基点、浅基点,其他传感器为:“无”)</param> private void drawing_zed(ref ZedGraphControl zed, int type, DateTime d_begin, DateTime d_over, string cgq, string cgq_order,Color col,SymbolType sbt) { PointPairList list = new PointPairList(); GraphPane myPane = zed.GraphPane; //GraphPane myPane = zedGraphControl1.GraphPane; LineItem myCurve; //zgl.GraphPane.CurveList.Remove(my); string sql4conorder = "select 接线次序 from 传感器信息表 where 传感器编号= '" + cgq + "'"; string data_num = (string)db.QueryScalar(sql4conorder); // string sss = "前悬梁前柱后柱"; int i = data_num.IndexOf(cgq_order); string datanum = null; string cgq_table = null;//传感器数据表名称 string cgq_time = null;//传感器数据表中时间字段名 string cgq_num = null;//传感器数据表中传感器编号字段名 switch (type) { case 4://支柱压力 datanum = "顶板通道"; cgq_table = "支柱压力传感器信息表"; cgq_time = "支柱压力观测时间"; cgq_num = "支柱压力传感器编号"; break; case 5://钻孔应力 datanum = "钻孔应力"; cgq_table = "钻孔应力传感器信息表"; cgq_time = "钻孔应力观测时间"; cgq_num = "钻孔应力传感器编号"; break; case 6://锚杆锚索 datanum = "锚杆锚索"; cgq_table = "锚杆锚索传感器信息表"; cgq_time = "锚杆锚索观测时间"; cgq_num = "锚杆锚索传感器编号"; break; case 7://顶板离层 datanum = "离层"; cgq_table = "顶板离层传感器信息表"; cgq_time = "顶板离层观测时间"; cgq_num = "顶板离层传感器编号"; break; default: MessageBox.Show("传感器类型错误!"); return; } //通过接线次序判断数据通道号 if (cgq_order == "无") datanum += "data"; else { if (i == 0) { datanum += "data1"; } else if (i > 0 && i <= 4) { datanum += "data2"; } else if (i >= 5) { datanum += "data3"; } } if (datanum != null) try { //查询特定传感器下特定通道某时间段内数据 string sql4data = "SELECT * FROM " + cgq_table + " WHERE ([" + cgq_time + "] Between #" + d_begin + "# And #" + d_over + "#) and [" + cgq_num + "]='" + cgq + "' ORDER BY " + cgq_time + ""; OleDbDataReader dr1 = db.Query_reader(sql4data); if (dr1.HasRows) //判断记录集是否包含一行或多行 { while (dr1.Read()) { double y = double.Parse(dr1[datanum].ToString()); //取得字段的值 // float y = ddd; DateTime dt = (DateTime)dr1[cgq_time]; // double x = (double)new XDate(dt); double x = (double)new XDate(dt); list.Add(x, y); } } dr1.Close(); } catch(Exception ex) { MessageBox.Show(ex.ToString()); } string mycurve = cgq + "---" + cgq_order; if (cgq_order == "无") mycurve = cgq; myCurve = zed.GraphPane.AddCurve(mycurve, list, col, sbt); zed.AxisChange(); zed.Refresh(); }
private string z1_PointValueEvent( ZedGraphControl z1, GraphPane pane, CurveItem curve, int index ) { StockPt spt = curve.Points[index] as StockPt; if ( spt != null ) { return XDate.ToString( spt.Date, "g" ) + "\n" + "Open = " + spt.Open.ToString( "f2" ) + "\n" + "High = " + spt.High.ToString( "f2" ) + "\n" + "Low = " + spt.Low.ToString( "f2" ) + "\n" + "Close = " + spt.Close.ToString( "f2" ); } else return "Invalid Data"; PointPair pt = curve.Points[index]; box.IsVisible = true; box.Location.Y = pt.Y + 5; z1.Refresh(); return "Point #" + index.ToString() + "\n" + XDate.ToString( pt.X, "g" ) + "\n" + pt.Y.ToString() + "Line 4\nLine 5\nLine 6\nLine 7"; }
//获取 弯曲试验 结果的 DataSource public static void readFinishSample(DataGridView dg, DataGridView dataGridViewSum, string testNo, DateTimePicker dtime, ZedGraph.ZedGraphControl zed) { //try //{ //dg.MultiSelect = true; if (dg != null) { dg.DataSource = null; dg.Columns.Clear(); dg.RowHeadersVisible = false; } BLL.Bend bllTs = new HR_Test.BLL.Bend(); double maxvalue = 0; DataSet dsmax = bllTs.GetFbbMax(" testNo='" + testNo + "' and testDate =#" + dtime.Value.Date + "#"); if (!string.IsNullOrEmpty(dsmax.Tables[0].Rows[0]["Fbb"].ToString())) { maxvalue = Convert.ToDouble(dsmax.Tables[0].Rows[0]["Fbb"].ToString()); } if (!string.IsNullOrEmpty(testNo)) { //if (testNo.Contains('-')) // testNo = testNo.Substring(0, testNo.LastIndexOf("-")); //获取不重复的试验编号列表 DataSet ds = bllTs.GetNotOverlapList(" testNo='" + testNo + "' and testDate =#" + dtime.Value.Date + "#"); DataSet ds1 = bllTs.GetNotOverlapList(" testNo='" + testNo + "' and testDate =#" + dtime.Value.Date + "#"); DataTable dt1 = ds1.Tables[0]; string methodName = dt1.Rows[0]["testMethod"].ToString(); if (dt1 != null) { StringBuilder[] tst = strSql_B(methodName, maxvalue); if (!string.IsNullOrEmpty(tst[0].ToString()) && dg != null) { dg.DataSource = CreateView_B(tst[0].ToString(), dt1.Rows[0]["testNo"].ToString()); } if (!string.IsNullOrEmpty(tst[1].ToString())) { dataGridViewSum.DataSource = CreateAverageView_B(tst[0], tst[1], dt1.Rows[0]["testNo"].ToString()); } } } else { DataSet ds = bllTs.GetFinishListDefault(" testNo='" + testNo + "' and testDate=#" + dtime.Value.Date + "#", maxvalue); DataTable _dt = ds.Tables[0]; DataRow dr = _dt.NewRow(); _dt.Rows.Add(dr); if (dg != null) { dg.DataSource = _dt; } ds.Dispose(); } if (dg != null) { DataGridViewCheckBoxColumn chkcol = new DataGridViewCheckBoxColumn(); chkcol.Name = "选择"; chkcol.MinimumWidth = 50; chkcol.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn(); c.Name = ""; dg.Columns.Insert(0, chkcol); dg.Columns.Insert(1, c); dg.Name = "tensile"; //dg.Rows[0].Cells[0].Value = false; //dg.Rows[0].Cells[0].Selected = false; int rCount = dg.Rows.Count; for (int i = 0; i < rCount; i++) { if (!string.IsNullOrEmpty(dg.Rows[i].Cells[2].Value.ToString())) { if (Convert.ToBoolean(dg.Rows[i].Cells[2].Value.ToString()) == true) { dg.Rows[i].DefaultCellStyle.BackColor = Color.IndianRed; } } if (i > 19) { dg.Rows[i].Cells[1].Style.BackColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Style.ForeColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Style.SelectionForeColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Style.SelectionBackColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Value = _Color_Array[i % 20].ToString(); } else { dg.Rows[i].Cells[1].Style.BackColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Style.ForeColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Style.SelectionBackColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Style.SelectionForeColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Value = _Color_Array[i].ToString(); } } foreach (DataGridViewColumn dgvc in dg.Columns) { dgvc.SortMode = DataGridViewColumnSortMode.NotSortable; dgvc.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; } if (dg.Columns.Count > 1) { dg.Columns[0].Frozen = true; dg.Columns[1].Frozen = true; dg.Columns[1].Width = 10; } if (dg.Columns.Count > 2) { dg.Columns[2].Frozen = true; } dg.Refresh(); } if (zed != null) { //clear all curves foreach (CurveItem ci in zed.GraphPane.CurveList) { ci.Clear(); ci.Label.Text = ""; } zed.AxisChange(); zed.Refresh(); } dsmax.Dispose(); //} //catch (Exception ee) { MessageBox.Show(this, ee.ToString(), "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
void zgc_ScrollProgressEvent( ZedGraphControl sender, ScrollBar scrollBar, ZoomState oldState, ZoomState newState ) { //this.toolStripStatusLabel1.Text = sender.GraphPane.XAxis.Scale.Max.ToString(); // When scroll action is finished, recalculate the axis ranges sender.AxisChange(); sender.Refresh(); }
//----------------------锚杆锚索和钻孔应力初始化曲线 zedGrahp_initializer_mz--------------------------- private void zedGrahp_initializer_mz(ZedGraphControl zedgraph, ref PointPairList list, string ZedGraph_Tile, string ZedGraph_X_Title, string ZedGraph_Y_Title, string ZedGraph_lable) { //曲线设置,标题,X轴,Y轴设置 zedgraph.GraphPane.Title.Text = ZedGraph_Tile; zedgraph.GraphPane.XAxis.Title.Text = ZedGraph_X_Title; zedgraph.GraphPane.YAxis.Title.Text = ZedGraph_Y_Title; zedgraph.GraphPane.XAxis.Type = ZedGraph.AxisType.DateAsOrdinal;//X轴格式(按时间排列) zedgraph.GraphPane.YAxis.Color = Color.DeepSkyBlue;//设置曲线颜色 //zedgraph.IsEnableVZoom = false;//垂直方向禁止缩放 //zedgraph.IsEnableHZoom = false;//禁止水平方向缩放 zedgraph.IsShowPointValues = true; zedgraph.GraphPane.XAxis.Type = AxisType.Date;//X轴时间显示 zedgraph.GraphPane.XAxis.Scale.Format = "MM-dd:HH";//X轴显示格式 zedgraph.GraphPane.YAxis.MajorGrid.IsVisible = true; //Y方向网格 zedgraph.GraphPane.XAxis.MajorGrid.IsVisible = true; //X方向网格 zedgraph.GraphPane.XAxis.MajorGrid.Color = Color.Gray;//网格颜色 //------------标题设置---------------->> zedgraph.GraphPane.Title.FontSpec.Size = 10f;//标题字体大小 zedgraph.GraphPane.Title.FontSpec.Family = "宋体";//标题字体设置 zedgraph.GraphPane.Title.FontSpec.IsBold = false;//禁止标题加粗 zedgraph.GraphPane.Title.FontSpec.FontColor = Color.Lime; //<<-----------标题设置-------------------- //zedgraph.GraphPane. //------------X轴设置---------------->> zedgraph.GraphPane.XAxis.Title.FontSpec.Size = 10f;//标题字体大小 zedgraph.GraphPane.XAxis.Title.FontSpec.Family = "宋体";//标题字体设置 zedgraph.GraphPane.XAxis.Title.FontSpec.IsBold = false;//禁止标题加粗 zedgraph.GraphPane.XAxis.Scale.FontSpec.Size = 8f; //<<-----------X轴设置-------------------- //------------Y轴设置---------------->> zedgraph.GraphPane.YAxis.Title.FontSpec.Size = 10f;//标题字体大小 zedgraph.GraphPane.YAxis.Title.FontSpec.Family = "宋体";//标题字体设置 zedgraph.GraphPane.YAxis.Title.FontSpec.IsBold = false;//禁止标题加粗 zedgraph.GraphPane.YAxis.Scale.FontSpec.Size = 8f; //<<-----------Y轴设置-------------------- //---------隐藏边框------->> zedgraph.BorderStyle = BorderStyle.Fixed3D; //zedgraph.GraphPane.Border.IsVisible = false; //------------zedgraph 控件背景透明--------- zedgraph.GraphPane.Chart.Fill.Color = Color.Transparent; zedgraph.MasterPane.Fill.Color = Color.Transparent; zedgraph.GraphPane.Fill.Color = Color.Transparent; //------------zedgraph 控件背景透明--------- //初始化mycurve LineItem mycurve = zedgraph.GraphPane.AddCurve(ZedGraph_lable, list, Color.DarkGreen, SymbolType.None); // mycurve.Clear(); zedgraph.AxisChange(); zedgraph.Refresh(); }
/// <summary> /// 综合查询绘制曲线 /// </summary> /// <param name="d_begin">开始时间</param> /// <param name="d_over">结束时间</param> /// <param name="cgq">传感器编号</param> private void drawing_zed_dblc(ref ZedGraphControl zed, DateTime d_begin, DateTime d_over, string cgq,Color col) { PointPairList list = new PointPairList(); GraphPane myPane = zed.GraphPane; //GraphPane myPane = zedGraphControl1.GraphPane; LineItem myCurve; //zgl.GraphPane.CurveList.Remove(my); string sql4data = "SELECT 顶板离层观测时间,Abs([离层data1]-[离层data2]) as licengliang FROM 顶板离层传感器信息表 WHERE ([顶板离层观测时间] Between #" + d_begin + "# And #" + d_over + "#) and 顶板离层传感器编号='" + cgq + "' ORDER BY 顶板离层观测时间"; try { OleDbDataReader dr1 = db.Query_reader(sql4data); if (dr1.HasRows) //判断记录集是否包含一行或多行 { while (dr1.Read()) { double y = double.Parse(((double)dr1["licengliang"]).ToString("F2")); //取得字段的值 // float y = ddd; DateTime dt = (DateTime)dr1["顶板离层观测时间"]; // double x = (double)new XDate(dt); double x = (double)new XDate(dt); list.Add(x, y); } } } catch { } finally { db.Close(); } string mycurve = cgq + "---" + "离层量"; myCurve = zed.GraphPane.AddCurve(mycurve, list, col, SymbolType.None); zed.AxisChange(); zed.Refresh(); }
// Currently not is use!!! private void timer1_Tick(object sender, EventArgs e) { string data = "sdf"; string[] stringData2 = data.Split(';'); /* * string[] hexValuesSplit = stringData.Split(' '); * int adcv1 = Convert.ToInt32(hexValuesSplit[4], 16); * int adcv2 = Convert.ToInt32(hexValuesSplit[5], 16); * int adcv3 = Convert.ToInt32(hexValuesSplit[6], 16); * int adcv4 = Convert.ToInt32(hexValuesSplit[7], 16); * * int adcv1 = Convert.ToInt32(hexValuesSplit[1], 16); * int adcv2 = Convert.ToInt32(hexValuesSplit[2], 16); * int adcv3 = Convert.ToInt32(hexValuesSplit[3], 16); * int adcv4 = Convert.ToInt32(hexValuesSplit[4], 16); * * int adcv1 = Convert.ToInt32(stringData2[0]); * int adcv2 = Convert.ToInt32(stringData2[0]); * int adcv3 = Convert.ToInt32(stringData2[0]); * int adcv4 = Convert.ToInt32(stringData2[0]); * */ int adcv1 = 0; int adcv2 = 0; int adcv3 = 0; int adcv4 = 0; string stringData = "123"; if (stringData.Length > 3) { adcv1 = Convert.ToInt32(stringData2[0]); } else { adcv1 = 200; adcv2 = 253; adcv3 = 251; adcv4 = 250; } //sqlinsert(adcv1, adcv2, adcv3, adcv4); label1.Text = Convert.ToString(adcv1 + " " + adcv2 + " " + adcv3 + " " + adcv4); counter = counter + 1; if (this.log == "true") { //filewrite file = new filewrite(); //file.write(counter + "," + adcv1 + "," + adcv2 + "," + adcv3 + "," + adcv4); } spl1.Add(counter, adcv1); spl2.Add(counter, adcv2); spl3.Add(counter, adcv3); spl4.Add(counter, adcv4); zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); zedGraphControl1.Refresh(); Invalidate(); /* * * stringData = Encoding.ASCII.GetString(data, 0, recv); * Console.WriteLine(stringData); * * while (true) * { * input = Console.ReadLine(); * if (input == "exit") * break; * server.Send(Encoding.ASCII.GetBytes(input)); * data = new byte[1024]; * recv = server.Receive(data); * stringData = Encoding.ASCII.GetString(data, 0, recv); * Console.WriteLine(stringData); * } * /**/ //server.Shutdown(SocketShutdown.Both); //server.Close(); }
public static void DisplayInPicture(List<CorePointData> lstCorePt, ZedGraphControl zedGraphControlCore, bool IsClosed) { GraphPane myPane = zedGraphControlCore.GraphPane; //清除原来的图形 myPane.CurveList.Clear(); myPane.GraphObjList.Clear(); //设置网格线可见 myPane.XAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.IsVisible = true; //设置网格线颜色 myPane.XAxis.MajorGrid.Color = Color.Chocolate; myPane.YAxis.MajorGrid.Color = Color.Chocolate; //设置网格线形式 myPane.XAxis.MajorGrid.DashOff = 1; myPane.YAxis.MajorGrid.DashOff = 1; myPane.XAxis.MajorGrid.DashOn = 4; myPane.YAxis.MajorGrid.DashOn = 4; //设置显示坐标 myPane.XAxis.Scale.IsUseTenPower = false; myPane.YAxis.Scale.IsUseTenPower = false; myPane.XAxis.Scale.MagAuto = true; myPane.YAxis.Scale.MagAuto = true; myPane.Title.Text = "重心包线"; myPane.XAxis.Title.Text = "长度(毫米)"; myPane.YAxis.Title.Text = "重量(千克)"; PointPairList listCur = new PointPairList(); double x = 0, y = 0; string strTitle = string.Empty; string strValue = string.Empty; if (lstCorePt != null && lstCorePt.Count > 0) { for (int j = 0; j < lstCorePt.Count; j++) { x = Math.Round(lstCorePt[j].pointXValue, picDigit); y = Math.Round(lstCorePt[j].pointYValue, picDigit); listCur.Add(x, y); //显示名称 strTitle = lstCorePt[j].pointName; // 创建一个阴影区域,看起来有渐变 TextObj text = new TextObj(strTitle, x, y, CoordType.AxisXYScale, AlignH.Right, AlignV.Center); //是否有背景 text.FontSpec.Fill.IsVisible = false; //是否有边框 text.FontSpec.Border.IsVisible = false; //文字是否粗体 text.FontSpec.IsBold = true; //文字是否斜体 text.FontSpec.IsItalic = false; //填充 myPane.GraphObjList.Add(text); } //是否成环形图形 if (IsClosed) { listCur.Add(Math.Round(lstCorePt[0].pointXValue, picDigit), Math.Round(lstCorePt[0].pointYValue, picDigit)); } LineItem myCurveCur = myPane.AddCurve(string.Empty, listCur, Color.Blue, SymbolType.Default); myCurveCur.Symbol.Size = 6; myCurveCur.Symbol.Fill = new Fill(Color.Blue, Color.Blue); myCurveCur.Symbol.Border.IsVisible = true; myCurveCur.Line.IsVisible = true; } zedGraphControlCore.AxisChange(); zedGraphControlCore.Refresh(); }
private bool BasicLinear_MouseMoveEvent( ZedGraphControl sender, MouseEventArgs e ) { // Save the mouse location PointF mousePt = new PointF( e.X, e.Y ); // Find the Chart rect that contains the current mouse location GraphPane pane = sender.MasterPane.FindChartRect( mousePt ); // If pane is non-null, we have a valid location. Otherwise, the mouse is not // within any chart rect. if ( pane != null ) { LineObj cursorLine = pane.GraphObjList["cursorLine"] as LineObj; // NOTE: the above line will throw an exception if the "cursorLine" tag can't be found // (if it was deleted or something) cursorLine.IsVisible = false; nearestCurve = null; nearestIndex = -1; nearestX = 1e300; double x, x2, y, y2; // Convert the mouse location to X, Y, and Y2 scale values pane.ReverseTransform( mousePt, out x, out x2, out y, out y2 ); foreach ( CurveItem curve in pane.CurveList ) { IPointList pointList = curve.Points; for ( int i = 0; i < pointList.Count; i++ ) { PointPair pt = pointList[i]; if ( Math.Abs( x - pt.X ) < nearestX ) { nearestCurve = curve; nearestIndex = i; nearestX = Math.Abs( x - pt.X ); } } } if ( nearestIndex >= 0 && nearestCurve != null ) { PointPair pt = nearestCurve.Points[nearestIndex]; // Format the status label text toolStripStatusXY.Text = "(" + pt.X.ToString( "f2" ) + ", " + pt.Y.ToString( "f2" ) + ")"; cursorLine.Location.X1 = pt.X; cursorLine.Location.Width = 0; cursorLine.IsVisible = true; this.Cursor = Cursors.Cross; } else { toolStripStatusXY.Text = string.Empty; this.Cursor = Cursors.Default; } statusStrip1.Refresh(); sender.Refresh(); //sender.Invalidate(); return true; } else { // If there is no valid data, then clear the status label text toolStripStatusXY.Text = string.Empty; sender.Refresh(); this.Cursor = Cursors.Default; // Return false to indicate we have not processed the MouseMoveEvent // ZedGraphControl should still go ahead and handle it return false; } }
/// <summary> /// /// </summary> /// <param name="control"></param> public PlotterWindow(Plotter control) { m_owner = control; m_isSavable = false; InitializeComponent(); m_zCnt = new ZedGraphControl(); m_zCnt.Dock = DockStyle.Fill; m_zCnt.GraphPane.Title.Text = ""; m_zCnt.GraphPane.XAxis.Title.IsVisible = false; m_zCnt.GraphPane.YAxis.Title.IsVisible = false; m_zCnt.GraphPane.Legend.IsVisible = false; m_zCnt.GraphPane.XAxis.Scale.Max = 100; m_zCnt.GraphPane.XAxis.Scale.MaxAuto = true; m_zCnt.GraphPane.YAxis.Scale.MaxAuto = true; m_zCnt.GraphPane.XAxis.Scale.Min = 0; m_zCnt.GraphPane.Margin.Top = 35.0f; m_zCnt.GraphPane.YAxis.MajorGrid.IsVisible = true; m_zCnt.GraphPane.XAxis.MinorTic.Color = Color.FromArgb(200, 200, 200); m_zCnt.GraphPane.XAxis.MajorTic.Color = Color.FromArgb(200, 200, 200); m_zCnt.GraphPane.YAxis.MinorTic.Color = Color.FromArgb(200, 200, 200); m_zCnt.GraphPane.YAxis.MajorTic.Color = Color.FromArgb(200, 200, 200); m_zCnt.GraphPane.Chart.Border.Color = Color.FromArgb(200, 200, 200); m_zCnt.GraphPane.YAxis.MajorGrid.Color = Color.FromArgb(200, 200, 200); m_zCnt.GraphPane.Fill = new Fill(Color.White, Color.LightGray, 90.0f); plotTableLayoutPanel.Controls.Add(m_zCnt, 0, 0); m_zCnt.AxisChange(); m_zCnt.Refresh(); displaySettingDataGrid.ContextMenuStrip = gridContextMenuStrip; }
private void CreateGraph_BarJunk2( ZedGraphControl z1 ) { GraphPane myPane = z1.GraphPane; myPane.CurveList.Clear(); PointPairList list = new PointPairList(); list.Clear(); list.Add( 4, 0 ); list.Add( -2, 1 ); list.Add( 5, 2 ); list.Add( 3, 3 ); string[] labels = { "bar one", "bar two", "bar three", "bar four" }; myPane.YAxis.Scale.TextLabels = labels; myPane.YAxis.Type = AxisType.Text; //myPane.YAxis.Cross = 0.0; myPane.XAxis.MajorGrid.IsZeroLine = true; BarItem myCurve2 = myPane.AddBar( "curve 2", list, Color.Red ); myCurve2.Bar.Fill = new Fill( Color.Red, Color.White, Color.Red, 90 ); // Set BarBase to the YAxis for horizontal bars myPane.BarSettings.Base = BarBase.Y; z1.AxisChange(); z1.Refresh(); }
public void CreateChart(ZedGraphControl zgc, double Metros_lineares_livres, double Metros_lineares_ocupados, double Metros_ocupados_estimados) { GraphPane myPane = zgc.GraphPane; // Set the GraphPane title myPane.Title.Text = ""; myPane.Fill.Color = Color.LightGray; myPane.Chart.Fill.Type = FillType.None; double total = Metros_lineares_livres + Metros_lineares_ocupados + Metros_ocupados_estimados; double percent_Livre = 0; double percent_ocupado = 0; double percent_ocupado_estimado = 0; if (total > 0) { percent_Livre = Metros_lineares_livres * 100 / total; percent_ocupado = Metros_lineares_ocupados * 100 / total; percent_ocupado_estimado = Metros_ocupados_estimados * 100 / total; } // Adicionar as fatias: myPane.CurveList.Clear(); myPane.AddPieSlice(Metros_lineares_livres, Color.Green, Color.White, 45f, .05, percent_Livre > 0 ? string.Format("Livre ({0:.00}%)", percent_Livre) : "Livre"); myPane.AddPieSlice(Metros_lineares_ocupados, Color.Red, Color.White, 45f, .0, percent_ocupado > 0 ? string.Format("Ocupado ({0:.00}%)", percent_ocupado) : "Ocupado"); if (Metros_ocupados_estimados > 0) myPane.AddPieSlice(Metros_ocupados_estimados, Color.IndianRed, Color.White, 45f, .0, string.Format("Ocupado (estimado) ({0:.00}%)", percent_ocupado_estimado)); zgc.AxisChange(); zgc.Refresh(); }
public static void readFinishSampleReport(DataGridView dg, string testNo, string testSampleNo, DateTimePicker dtpfrom, DateTimePicker dtpto, ZedGraph.ZedGraphControl zed) { BLL.GBT3354_Samples bllTs = new HR_Test.BLL.GBT3354_Samples(); string strWhere = string.Empty; if (!string.IsNullOrEmpty(testNo)) { strWhere += " and testNo like '%" + testNo + "%'"; } if (!string.IsNullOrEmpty(testSampleNo)) { strWhere += " and testSampleNo like '%" + testSampleNo + "%'"; } double maxValue = 0; DataSet dsmax = bllTs.GetMaxFm("isFinish=true and isEffective=false and testDate>=#" + dtpfrom.Value.Date + "# and testDate<=#" + dtpto.Value.Date + "#" + strWhere); if (dsmax != null) { if (dsmax.Tables[0].Rows.Count > 0) { if (!string.IsNullOrEmpty(dsmax.Tables[0].Rows[0]["Pmax"].ToString())) { maxValue = Convert.ToDouble(dsmax.Tables[0].Rows[0]["Pmax"].ToString()); } } } DataSet ds = bllTs.GetFinishList("isFinish=true and isEffective=false and testDate>=#" + dtpfrom.Value.Date + "# and testDate<=#" + dtpto.Value.Date + "#" + strWhere, maxValue); DataTable dt = ds.Tables[0]; dg.DataSource = dt; DataGridViewCheckBoxColumn chkcol = new DataGridViewCheckBoxColumn(); //DataGridViewDisableCheckBoxColumn chkcol = new DataGridViewDisableCheckBoxColumn(); chkcol.Name = "选择"; DataGridViewTextBoxColumn c = new DataGridViewTextBoxColumn(); c.Visible = true; c.Name = " "; dg.Columns.Insert(0, c); dg.Columns.Insert(0, chkcol); dg.Columns[1].Frozen = true; dg.Columns[2].Frozen = true; //dg.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells); dg.Columns[0].Width = 50; dg.Columns[1].Width = 50; dg.Columns[2].Width = 100; if (dg.ColumnCount > 0) { foreach (DataGridViewColumn dgvc in dg.Columns) { dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; dgvc.SortMode = DataGridViewColumnSortMode.NotSortable; dgvc.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; } } dg.Refresh(); for (int i = 0; i < dg.Rows.Count; i++) { if (i > 19) { dg.Rows[i].Cells[1].Style.BackColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Style.ForeColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Style.SelectionForeColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Style.SelectionBackColor = Color.FromName(_Color_Array[i % 20]); dg.Rows[i].Cells[1].Value = _Color_Array[i % 20].ToString(); } else { dg.Rows[i].Cells[1].Style.BackColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Style.ForeColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Style.SelectionForeColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Style.SelectionBackColor = Color.FromName(_Color_Array[i]); dg.Rows[i].Cells[1].Value = _Color_Array[i].ToString(); } } foreach (CurveItem ci in zed.GraphPane.CurveList) { ci.Clear(); ci.Label.Text = ""; } zed.AxisChange(); zed.Refresh(); ds.Dispose(); }