/// <summary> /// /// </summary> private void SetZedStyle(ZedGraph.GraphPane gp) { int fontSize = 12; gp.IsFontsScaled = false; gp.Legend.IsVisible = false; // X // gp.XAxis.Title.FontSpec.Size = fontSize; gp.XAxis.MinorGrid.IsVisible = false; gp.XAxis.Title.Text = XD100Strings.OT; gp.XAxis.Scale.MajorStep = 10; gp.XAxis.Scale.MinorStep = 5; gp.XAxis.Scale.Min = Xdgk.GR.Common.OTControlLineDefines.OTMin; gp.XAxis.Scale.Max = Xdgk.GR.Common.OTControlLineDefines.OTMax; gp.XAxis.Scale.Format = "G"; SetMajorTicStyle(gp.XAxis.MajorTic); SetMinorTicStyle(gp.XAxis.MinorTic); // Y // gp.YAxis.Title.FontSpec.Size = fontSize; gp.YAxis.MajorGrid.IsVisible = false; gp.YAxis.Title.Text = XD100Strings.GT2; gp.YAxis.Scale.Min = Xdgk.GR.Common.OTControlLineDefines.GT2Min; gp.YAxis.Scale.Max = Xdgk.GR.Common.OTControlLineDefines.GT2Max; gp.YAxis.Scale.MajorStep = 10; gp.YAxis.Scale.MinorStep = 5; gp.YAxis.Scale.Format = "G"; SetMajorTicStyle(gp.YAxis.MajorTic); SetMinorTicStyle(gp.YAxis.MinorTic); }
private void Graph_Load(object sender, EventArgs e) { gp = zdGraph.GraphPane; gp.YAxis.IsShowGrid = true; gp.YAxis.Title = "Voltage"; gp.YAxis.ScaleFontSpec.Size = 8; gp.YAxis.TitleFontSpec.Size = 8; gp.YAxis.Min = 0; gp.YAxis.Max = 4096; gp.XAxis.IsShowGrid = true; gp.XAxis.Max = data.Length; gp.XAxis.Min = 0; gp.XAxis.Title = "Time"; gp.XAxis.ScaleFontSpec.Size = 8; gp.XAxis.TitleFontSpec.Size = 8; zdGraph.IsShowPointValues = true; gp.Title = "Voltage Curve"; zdGraph.AxisChange(); gp.AddCurve("Data", x, data, Color.Blue, SymbolType.None); zdGraph.AxisChange(); zdGraph.Refresh(); }
private static void SetupGraph(ZedGraph.GraphPane g) { var color = Color.FromArgb(0xCC, 0xCC, 0xCC); #if SHOW_DERIVATION_2 g.Legend.IsVisible = true; #else g.Legend.IsVisible = false; #endif g.XAxis.IsVisible = false; g.Legend.Border.IsVisible = false; g.Border.Color = color; g.Chart.Border.Color = color; g.XAxis.MajorGrid.IsVisible = true; g.YAxis.MajorGrid.IsVisible = true; g.YAxis.MinorGrid.IsVisible = true; g.Title.FontSpec.Size = 18.0f; g.Legend.FontSpec.Size = 18.0f; g.XAxis.Scale.FontSpec.Size = 18.0f; g.YAxis.Scale.FontSpec.Size = 18.0f; g.XAxis.Title.FontSpec.Size = 18.0f; g.YAxis.Title.FontSpec.Size = 18.0f; }
private void DrawGraph() { // Получим панель для рисования ZedGraph.GraphPane pane = ZedGraphz.GraphPane; // Очистим список кривых на тот случай, если до этого сигналы уже были нарисованы pane.CurveList.Clear(); // Создадим список точек PointPairList list = new PointPairList(); double xmin = -50; double xmax = 50; // Заполняем список точек for (double x = xmin; x <= xmax; x += 0.01) { // добавим в список точку list.Add(x, f(x)); } // Создадим кривую с названием "Sinc", // которая будет рисоваться голубым цветом (Color.Blue), // Опорные точки выделяться не будут (SymbolType.None) LineItem myCurve = pane.AddCurve("Sinc", list, Color.Blue, SymbolType.None); // Вызываем метод AxisChange (), чтобы обновить данные об осях. // В противном случае на рисунке будет показана только часть графика, // которая умещается в интервалы по осям, установленные по умолчанию ZedGraphz.AxisChange(); // Обновляем график ZedGraphz.Invalidate(); }
/// <summary> /// /// </summary> private void SetZedStyle(ZedGraph.GraphPane gp) { int fontSize = 12; gp.IsFontsScaled = false; // X // gp.XAxis.Title.FontSpec.Size = fontSize; gp.XAxis.MinorGrid.IsVisible = false; gp.XAxis.Title.Text = XD100Strings.Time; gp.XAxis.Scale.MajorStep = 2; gp.XAxis.Scale.MinorStep = 1; gp.XAxis.Scale.Min = 0; gp.XAxis.Scale.Max = 24; gp.XAxis.Scale.Format = "G"; SetMajorTicStyle(gp.XAxis.MajorTic); SetMinorTicStyle(gp.XAxis.MinorTic); // Y // gp.YAxis.Title.FontSpec.Size = fontSize; gp.YAxis.MajorGrid.IsVisible = false; gp.YAxis.Title.Text = XD100Strings.GT2; gp.YAxis.Scale.Min = 0; gp.YAxis.Scale.Max = 100; gp.YAxis.Scale.MajorStep = 10; gp.YAxis.Scale.MinorStep = 5; gp.YAxis.Scale.Format = "G"; SetMajorTicStyle(gp.YAxis.MajorTic); SetMinorTicStyle(gp.YAxis.MinorTic); }
public void GraphPane_AxisChangeEvent(GraphPane pane) { if (sameStepForXY) { double realHeight = (zedGraphControl.GraphPane.YAxis.Scale.Max - zedGraphControl.GraphPane.YAxis.Scale.Min) * heightMultiplier; double realWidth = zedGraphControl.GraphPane.XAxis.Scale.Max - zedGraphControl.GraphPane.XAxis.Scale.Min; DoubleExtension multiplier, smallVal, bigVal; if (realHeight > realWidth) { multiplier = new DoubleExtension(realHeight / realWidth); MathExtension.MiddleBasedResize(new DoubleExtension(zedGraphControl.GraphPane.XAxis.Scale.Min), new DoubleExtension(zedGraphControl.GraphPane.XAxis.Scale.Max), multiplier, out smallVal, out bigVal); zedGraphControl.GraphPane.XAxis.Scale.Min = smallVal.AccurateValue; zedGraphControl.GraphPane.XAxis.Scale.Max = bigVal.AccurateValue; zedGraphControl.GraphPane.XAxis.Scale.MajorStep = MathExtension.DynamicRound((bigVal.AccurateValue - smallVal.AccurateValue) / 6); zedGraphControl.GraphPane.XAxis.Scale.MinorStep = MathExtension.DynamicRound((bigVal.AccurateValue - smallVal.AccurateValue) / 6) / 4; } else { multiplier = new DoubleExtension(realWidth / realHeight); MathExtension.MiddleBasedResize(new DoubleExtension(zedGraphControl.GraphPane.YAxis.Scale.Min), new DoubleExtension(zedGraphControl.GraphPane.YAxis.Scale.Max), multiplier, out smallVal, out bigVal); zedGraphControl.GraphPane.YAxis.Scale.Min = smallVal.AccurateValue; zedGraphControl.GraphPane.YAxis.Scale.Max = bigVal.AccurateValue; zedGraphControl.GraphPane.YAxis.Scale.MajorStep = MathExtension.DynamicRound((bigVal.AccurateValue - smallVal.AccurateValue) / 6); zedGraphControl.GraphPane.YAxis.Scale.MinorStep = MathExtension.DynamicRound((bigVal.AccurateValue - smallVal.AccurateValue) / 6) / 4; } } }
private void drawGraph() { Dictionary<double, double> coordinats = new Dictionary<double, double>(); for (double x = xMin; x <= xMax; x += top) { if (x!=0) coordinats.Add(x, a/x); } GraphPane myPane = new GraphPane(); zedGraphControl1.GraphPane = myPane; myPane.XAxis.Title.Text = "Координата X"; myPane.YAxis.Title.Text = "Координата Y"; // myPane.Fill = new Fill(Color.White, Color.LightSkyBlue, 45.0f); myPane.Chart.Fill.Type = FillType.None; myPane.Legend.Position = LegendPos.Float; myPane.Legend.IsHStack = false; if (comboBox1.GetItemText(comboBox1.SelectedIndex) == "1") { myPane.AddBar("", coordinats.Keys.ToArray(), coordinats.Values.ToArray(), penColor); } else { LineItem myCurve = myPane.AddCurve("", coordinats.Keys.ToArray(), coordinats.Values.ToArray(), penColor, SymbolType.None); myCurve.Line.Width = penWeight; myCurve.Symbol.Fill = new Fill(Color.White); } zedGraphControl1.AxisChange(); zedGraphControl1.Refresh(); zedGraphControl1.Visible = true; }
public GraphController(Model model, ZedGraphControl graphControl) { this.model = model; this.graphControl = graphControl; this.graphPane = graphControl.GraphPane; // Initialize lines this.lineItemA = this.graphPane.AddCurve("Person A", new PointPairList(), Color.Red, SymbolType.Diamond); this.lineItemB = this.graphPane.AddCurve("Person B", new PointPairList(), Color.Blue, SymbolType.Circle); this.lineItemAgent = this.graphPane.AddCurve("Agent", new PointPairList(), Color.Green, SymbolType.Star); this.lineItemAgent.IsY2Axis = true; // Set the Titles this.graphPane.Title.Text = "Graph of persons' data and the agent's state"; this.graphPane.XAxis.Title.Text = "Time"; this.graphPane.XAxis.Type = AxisType.Date; this.graphPane.Y2Axis.Title.Text = "Agent's state"; this.graphPane.YAxis.Scale.Min = -4; this.graphPane.YAxis.Scale.Max = 4; this.graphPane.Y2Axis.Scale.Min = -4; this.graphPane.Y2Axis.Scale.Max = 4; this.graphPane.Y2Axis.IsVisible = true; // Update threshold lines UpdateThresholdLines(); }
void EveryNumCycleLoad(object sender, EventArgs e) { MasterPane myMaster = zedGraphControl1 .MasterPane ; myMaster.PaneList.Clear(); myMaster.Title.Text = "MasterPane Test"; myMaster.Title.IsVisible = true; myMaster.Fill = new Fill( Color.White, Color.MediumSlateBlue, 45.0F ); int[][] everyRes = DataProcess .AllSingleCycle (MainForm .arr ) ; for ( int j=0; j< 10; j++ ) { GraphPane myPane = new GraphPane(); myPane.Title.Text = "My Test Graph #" + (j+1).ToString(); myPane.XAxis.Title.Text = "X Axis"; myPane.YAxis.Title.Text = "Y Axis"; //myPane.Fill = new Fill( Color.White, Color.LightYellow, 45.0F ); //myPane.BaseDimension = 6.0F; PointPairList list = new PointPairList(); for ( int i=0; i < everyRes [j ].Length ; i++ ) { int x = i ; int y = everyRes [j ][i ] ; list.Add( x, y ); } LineItem myCurve = myPane.AddCurve( "label" + j.ToString(),list, Color.Red, SymbolType.Diamond ); myMaster.Add( myPane ); } using ( Graphics g = this.CreateGraphics() ) { myMaster .SetLayout( g, PaneLayout.SquareColPreferred ); } }
/// <summary> /// Add a plot of the 1D histogram. You should call the Refresh() function to update the control after all modification is complete. /// </summary> /// <param name="name">The name of the histogram</param> /// <param name="color">The drawing color</param> /// <param name="histogram">The 1D histogram to be drawn</param> public void AddHistogram(String name, System.Drawing.Color color, Histogram histogram) { Debug.Assert(histogram.Dimension == 1, "Only 1D histogram is supported"); GraphPane pane = new GraphPane(); // Set the Title pane.Title.Text = name; pane.XAxis.Title.Text = "Color Intensity"; pane.YAxis.Title.Text = "Pixel Count"; #region draw the histogram RangeF range = histogram.Ranges[0]; int binSize = histogram.BinDimension[0].Size; float step = (range.Max - range.Min) / binSize; float start = range.Min; double[] bin = new double[binSize]; for (int binIndex = 0; binIndex < binSize; binIndex++) { bin[binIndex] = start; start += step; } PointPairList pointList = new PointPairList( bin, Array.ConvertAll<float, double>(histogram.Data, System.Convert.ToDouble)); pane.AddCurve(name, pointList, color); #endregion zedGraphControl1.MasterPane.Add(pane); }
public GraphPane AddGraph( int j, ColorSymbolRotator rotator ) { // Create a new graph with topLeft at (40,40) and size 600x400 GraphPane myPaneT = new GraphPane( new Rectangle( 40, 40, 600, 400 ), "Case #" + ( j + 1 ).ToString(), "Time, Days", "Rate, m/s" ); myPaneT.Fill = new Fill( Color.White, Color.LightYellow, 45.0F ); myPaneT.BaseDimension = 6.0F; // Make up some data arrays based on the Sine function double x, y; PointPairList list = new PointPairList(); for ( int i = 0; i < 36; i++ ) { x = (double)i + 5; y = 3.0 * ( 1.5 + Math.Sin( (double)i * 0.2 + (double)j ) ); list.Add( x, y ); } LineItem myCurve = myPaneT.AddCurve( "Type " + j.ToString(), list, rotator.NextColor, rotator.NextSymbol ); myCurve.Symbol.Fill = new Fill( Color.White ); return myPaneT; }
/// <summary> /// Rescale font size of x axis labels when the graph is zoomed or resized. /// </summary> /// <param name="width">Width of the graph in pixels.</param> /// <param name="pane">GraphPane of the graph.</param> public static void ScaleAxisLabels(int width, GraphPane pane) { if (pane.XAxis.Scale.TextLabels == null) return; pane.XAxis.Scale.IsPreventLabelOverlap = false; int countLabels = (int) Math.Ceiling(pane.XAxis.Scale.Max - pane.XAxis.Scale.Min) + 1; float dxAvailable = (float) width / countLabels; var fontSpec = pane.XAxis.Scale.FontSpec; int pointSize; for (pointSize = 12; pointSize > 4; pointSize--) { using (var font = new Font(fontSpec.Family, pointSize)) { // See if the original labels fit with this font int maxWidth = MaxWidth(font, pane.XAxis.Scale.TextLabels); if (maxWidth <= dxAvailable) break; } } pane.XAxis.Scale.FontSpec.Size = pointSize; pane.AxisChange(); }
private void InitGraph(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle, TimeSeriesDataSource[] dataSourceArray) { _graphPane = zed.GraphPane; _graphPane.Title.Text = title; _graphPane.XAxis.Title.Text = xAxisTitle; _graphPane.XAxis.MajorGrid.IsVisible = true; _graphPane.YAxis.Title.Text = y1AxisTitle; _graphPane.YAxis.MajorGrid.IsVisible = true; _graphPane.Y2Axis.Title.Text = y2AxisTitle; _graphPane.Y2Axis.MajorGrid.IsVisible = false; // Create point-pair lists and bind them to the graph control. int sourceCount = dataSourceArray.Length; _pointPlotArray = new RollingPointPairList[sourceCount]; for(int i=0; i<sourceCount; i++) { TimeSeriesDataSource ds = dataSourceArray[i]; _pointPlotArray[i] = new RollingPointPairList(ds.HistoryLength); LineItem lineItem = _graphPane.AddCurve(ds.Name, _pointPlotArray[i], ds.Color, SymbolType.None); lineItem.IsY2Axis = (ds.YAxis == 1); } }
private void initGraph() { ZedGraph.GraphPane gp = this.zedGraphControl1.GraphPane; gp.IsShowTitle = false; gp.XAxis.Title = "室外温度"; // gp.XAxis.MinAuto = false; // gp.XAxis.MaxAuto = false; gp.XAxis.Min = TemperatureLinePoint.MIN_OUTSIDE_TEMPERATURE; gp.XAxis.Max = TemperatureLinePoint.MAX_OUTSIDE_TEMPERATURE; gp.XAxis.Step = 10; gp.XAxis.MinorStep = 5; gp.XAxis.ScaleFormat = "f0"; gp.YAxis.Title = "供水温度"; gp.XAxis.IsZeroLine = true; // gp.YAxis.MinAuto = false; // gp.YAxis.MaxAuto = false; // gp.YAxis.StepAuto = true; gp.YAxis.Min = TemperatureLinePoint.MIN_TWOGIVE_TEMPERATURE; gp.YAxis.Max = TemperatureLinePoint.MAX_TWOGIVE_TEMPERATURE; //gp.YAxis.IsTicsBetweenLabels = false; gp.YAxis.Step = 10; gp.YAxis.MinorStep = 5; gp.YAxis.ScaleFormat = "f0"; }
public DrawCurve(CurveItem _curve, string _curveName, GraphPane _pane, string _paneName) { CurveName = _curveName; PaneName = _paneName; Curve = _curve; Pane = _pane; }
public static GraphPane AddPanel(this ZedGraphControl zgcGraph) { var result = new GraphPane(); zgcGraph.MasterPane.Add(result); zgcGraph.AxisChange(); return result; }
private void btnSolvingType2Mass_Click(object sender, EventArgs e) { this.btnUpdate_Click(null, null); this.listBox1.Items.Clear(); ZedGraph.GraphPane gp = this.zgSolve1.GraphPane; gp.CurveList.Clear(); this.curves.Clear(); string fname = listFunctions2.SelectedItem.ToString(); int randonCount = int.Parse(this.txtRandomCount.Text); string[,] curveNames = new string[randonCount, randonCount]; for (int i = 0; i < randonCount; i++) { for (int j = 0; j < randonCount; j++) { string curveName = string.Format("Line-{0}_{1}", i, j); this.curves.Add(curveName, new PointPairList()); Color c = Color.DarkBlue;//Color.FromArgb(255, r.Next(255), r.Next(255), r.Next(255)); gp.AddCurve(curveName, this.curves[curveName], c, SymbolType.None); curveNames[i, j] = curveName; } } this.view.ViewActionCall(ViewEventType.SolovePodhod2Type2Mass, fname, curveNames); }
public override void DrawSmoothFilledCurve(IGraphics g, GraphPane pane, CurveItem curve, float scaleFactor) { base.DrawSmoothFilledCurve(g, pane, curve, scaleFactor); // Draw the curve at the bottom of the graph. DrawCurve(g, pane, curve, scaleFactor, GetPointsForLowPointsArray(curve)); }
/// <summary> /// Do all rendering associated with this <see cref="CurveItem"/> to the specified /// <see cref="Graphics"/> device. This method is normally only /// called by the Draw method of the parent <see cref="ZedGraph.CurveList"/> /// collection object. /// </summary> /// <param name="g"> /// A graphic device object to be drawn into. This is normally e.Graphics from the /// PaintEventArgs argument to the Paint() method. /// </param> /// <param name="pane"> /// A reference to the <see cref="ZedGraph.GraphPane"/> object that is the parent or /// owner of this object. /// </param> /// <param name="pos">The ordinal position of the current <see cref="Bar"/> /// curve.</param> /// <param name="scaleFactor"> /// The scaling factor to be used for rendering objects. This is calculated and /// passed down by the parent <see cref="ZedGraph.GraphPane"/> object using the /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust /// font sizes, etc. according to the actual size of the graph. /// </param> public override void Draw(IGraphics g, GraphPane pane, int pos, float scaleFactor) { if (IsXAxisMarker) DrawXMarker(pane, g); else DrawYMarker(pane, g); }
private void zedGraphControl1_Load(object sender, System.EventArgs e) { zedGraphControl1.GraphPane.Title = "Test Case for C#"; /* double[] x = new double[100]; * double[] y = new double[100]; * int i; * for ( i=0; i<100; i++ ) * { * x[i] = (double) i / 100.0 * Math.PI * 2.0; * y[i] = Math.Sin( x[i] ); * } * zedGraphControl1.GraphPane.AddCurve( "Sine Wave", x, y, Color.Red, SymbolType.Square ); * zedGraphControl1.GraphPane.AxisChange(); */ // Create a new graph with topLeft at (40,40) and size 600x400 myPane = new GraphPane(new Rectangle(40, 40, 600, 400), "My Test Graph\n(For CodeProject Sample)", "My X Axis", "My Y Axis"); myPane.Title = "asd"; // Make up some random data points double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }; double[] y = { 20, 10, 50, 40, 35, 60, 90, 25, 48, 75 }; // Generate a red curve with diamond // symbols, and "My Curve" in the legend CurveItem myCurve = myPane.AddCurve("My Curve", x, y, Color.Red, SymbolType.Diamond); // Tell ZedGraph to refigure the // axes since the data have changed myPane.AxisChange(); }
/// <summary> /// Add a new graph to the control. /// </summary> /// <param name="data">The points to plot.</param> /// <param name="key">Name of the set to put in the graph key</param> /// <param name="control">The control to plot on.</param> /// <param name="color">The color for this key.</param> /// <param name="offset">The starting point for this plot.</param> /// <param name="lineStyle">The style of line to plot.</param> public void AddGraph( Dictionary<DateTime, Dictionary<string, double>> data, string key, ZedGraphControl control, Color color, int offset, System.Drawing.Drawing2D.DashStyle lineStyle) { GraphPane pane; int num_panels = control.MasterPane.PaneList.Count; if (num_panels == 2) { pane = control.MasterPane.PaneList[1]; } else { pane = new GraphPane(); control.MasterPane.PaneList.Add(pane); } pane.XAxis.Scale.Max = data.Count; if (data.Count >= 99) { pane.XAxis.Scale.Min = data.Count - 99; } else { pane.XAxis.Scale.Min = 0; } PointPairList list = ExtractPointPair(data, key, offset); LineItem line = pane.AddCurve(key, list, color, SymbolType.None); line.Line.Style = lineStyle; line.IsOverrideOrdinal = true; pane.IsBoundedRanges = true; pane.Title.Text = "OHLC Graph"; pane.XAxis.Type = AxisType.Ordinal; pane.XAxis.Title.Text = "Date"; pane.YAxis.Title.Text = "KEY"; pane.Margin.All = 0; pane.Margin.Bottom = 10; pane.YAxis.MinSpace = 80; pane.Y2Axis.MinSpace = 20; pane.AxisChange(); control.MasterPane.AxisChange(); using (Graphics g = control.CreateGraphics()) { control.MasterPane.SetLayout(g, PaneLayout.SingleColumn); control.MasterPane.AxisChange(g); // Synchronize the Axes ////control.IsAutoScrollRange = true; control.IsShowHScrollBar = true; ////control.IsShowVScrollBar = true; control.IsSynchronizeXAxes = true; ////g.Dispose(); } }
public Form1() { InitializeComponent(); myPane = myPlot.GraphPane; int status = myDevice.connect(); if (status == 0) { MessageBox.Show("Device couldn't be found!"); Environment.Exit(0); } myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = plotWidth; myPane.YAxis.Scale.Min = 0; myPane.YAxis.Scale.Max = 5; myDevice.pinMode(2, 1); myLine = myPane.AddCurve("Analog Voltage", myPoints, Color.Blue, SymbolType.None); myDevice.initPwm(); myLine.Line.Width = 1; myPlot.Invalidate(); myPlot.AxisChange(); myTimer.Start(); }
private void InitGraph(string title, string xAxisTitle, string y1AxisTitle, string y2AxisTitle, SummaryDataSource[] dataSourceArray) { _graphPane = zed.GraphPane; _graphPane.Title.Text = title; _graphPane.XAxis.Title.Text = xAxisTitle; _graphPane.XAxis.MajorGrid.IsVisible = true; _graphPane.YAxis.Title.Text = y1AxisTitle; _graphPane.YAxis.MajorGrid.IsVisible = true; _graphPane.Y2Axis.Title.Text = y2AxisTitle; _graphPane.Y2Axis.MajorGrid.IsVisible = false; // Create point-pair lists and bind them to the graph control. int sourceCount = dataSourceArray.Length; _pointPlotArray = new PointPairList[sourceCount]; for(int i=0; i<sourceCount; i++) { SummaryDataSource ds = dataSourceArray[i]; _pointPlotArray[i] =new PointPairList(); Color color = _plotColorArr[i % 3]; BarItem barItem = _graphPane.AddBar(ds.Name, _pointPlotArray[i], color); barItem.Bar.Fill = new Fill(color); _graphPane.BarSettings.MinClusterGap = 0; barItem.IsY2Axis = (ds.YAxis == 1); } }
public ZedGraphChart() { MasterPane mp = MasterPane; mp.Border.IsVisible = true; mp.Border.Color = Color.Yellow; ZedGraph.GraphPane pane = GraphPane; pane.Title.Text = "/"; pane.Title.FontSpec.FontColor = Color.Gray; pane.IsFontsScaled = false; pane.XAxis.Title.Text = "t "; pane.YAxis.Title.Text = "Δ"; deltas = new PointPairList(); deltaSMA = new PointPairList(); deltaWMA = new PointPairList(); deltaCurrent = new PointPairList(); deltasCurve = GraphPane.AddCurve("Δ", deltas, Color.FromArgb(0, 204, 0), SymbolType.None); deltaSMACurve = GraphPane.AddCurve("sma", deltaSMA, Color.FromArgb(255, 0, 0), SymbolType.None); deltaWMACurve = GraphPane.AddCurve("wma", deltaWMA, Color.Yellow, SymbolType.None); deltaCurrentCurve = GraphPane.AddCurve("now", deltaCurrent, Color.Gray, SymbolType.None); SetTheme(); }
private void Form1_Load(object sender, EventArgs e) { // set your pane myPane = zedGraphControl1.GraphPane; // set a title myPane.Title.Text = "This is an example!"; // set X and Y axis titles myPane.XAxis.Title.Text = "X Axis"; myPane.YAxis.Title.Text = "Y Axis"; // ---- CURVE ONE ---- // draw a sin curve for (int i = 0; i < 100; i++) { listPointsOne.Add(i, Math.Sin(i)); } // set lineitem to list of points myCurveOne = myPane.AddCurve(null, listPointsOne, Color.Black, SymbolType.Circle); // --------------------- // ---- CURVE TWO ---- listPointsTwo.Add(10, 50); listPointsTwo.Add(50, 50); // set lineitem to list of points myCurveTwo = myPane.AddCurve(null, listPointsTwo, Color.Blue, SymbolType.None); myCurveTwo.Line.Width = 5; // --------------------- // delegate to draw zedGraphControl1.AxisChange(); }
/// <summary> /// Render text at the bottom of a bar /// </summary> /// <param name="gp"></param> /// <param name="d"></param> /// <param name="x"></param> protected override void RenderBarLabel(GraphPane gp, RequestDataResults d, float x) { var requestText = new TextObj(d.Request + " -", x, 0).Style(Color.Black, 7); requestText.FontSpec.Angle = 25; requestText.Location.AlignH = AlignH.Right; gp.GraphObjList.Add(requestText); }
//初始化曲线控件上的曲线数量及名称 private void InitCurve(ZedGraph.ZedGraphControl zgControl, string curveName, string path, string lineColor) { if (curveName != null) { //_RPPList_Read = new RollingPointPairList(100000); _ResultPanel = zgControl.GraphPane; zgControl.GraphPane.CurveList.RemoveRange(0, zgControl.GraphPane.CurveList.Count); if (_List_Data != null) { _List_Data = null; } //foreach (CurveItem ci in zgControl.GraphPane.CurveList) //{ // ci.Clear(); //} LineItem CurveList = _ResultPanel.AddCurve(curveName, _RPPList_Read, Color.FromName(lineColor), SymbolType.None);//Y1-X1 CurveList.Line.IsAntiAlias = true; readCurveName(curveName, path); } //MessageBox.Show(zgControl.GraphPane.CurveList.Count.ToString()); //初始化曲线名称即 试样编号的名称 zgControl.AxisChange(); zgControl.RestoreScale(this._ResultPanel); }
/// <summary> /// Add a plot of the 1D histogram. You should call the Refresh() function to update the control after all modification is complete. /// </summary> /// <param name="name">The name of the histogram</param> /// <param name="color">The drawing color</param> /// <param name="histogram">The 1D histogram to be drawn</param> public void AddHistogram(String name, Color color, DenseHistogram histogram) { Debug.Assert(histogram.Dimension == 1, Properties.StringTable.Only1DHistogramSupported); GraphPane pane = new GraphPane(); // Set the Title pane.Title.Text = name; pane.XAxis.Title.Text = Properties.StringTable.Value; pane.YAxis.Title.Text = Properties.StringTable.Count; #region draw the histogram RangeF range = histogram.Ranges[0]; int binSize = histogram.BinDimension[0].Size; float step = (range.Max - range.Min) / binSize; float start = range.Min; double[] bin = new double[binSize]; for (int binIndex = 0; binIndex < binSize; binIndex++) { bin[binIndex] = start; start += step; } PointPairList pointList = new PointPairList( bin, Array.ConvertAll<float, double>( (float[]) histogram.MatND.ManagedArray, System.Convert.ToDouble)); pane.AddCurve(name, pointList, color); #endregion zedGraphControl1.MasterPane.Add(pane); }
/// <summary> /// Construct a <see cref="ZoomState"/> object from the scale ranges settings contained /// in the specified <see cref="GraphPane"/>. /// </summary> /// <param name="pane">The <see cref="GraphPane"/> from which to obtain the scale /// range values. /// </param> /// <param name="type">A <see cref="StateType"/> enumeration that indicates whether /// this saved state is from a pan or zoom.</param> public ZoomState(GraphPane pane, StateType type) { _xAxis = new ScaleState(pane.XAxis); _yAxis = new ScaleStateList(pane.YAxisList); _y2Axis = new ScaleStateList(pane.Y2AxisList); _type = type; }
List<string> selectedKeys = new List<string>(); // Selected Parameters to display #endregion Fields #region Constructors /// <summary> /// Initialises the Graphcontrol /// /// </summary> /// <param name="core"></param> public PropertygraphControl(GroundControlCore.GroundControlCore core) { InitializeComponent(); this.comboBox1.Items.Clear(); List<UAVSingleParameter> uavData = MonitoredDictionary<string, UAVSingleParameter>.NormaliseDictionary(core.currentUAV.uavData); foreach (UAVSingleParameter param in uavData) { comboBox1.Items.Add(param.GetStringPath()); } this.core = core; myPane = zedGraphControl1.GraphPane; // Set the titles and axis labels myPane.Title.Text = "Live Data"; myPane.XAxis.Title.Text = "Time"; myPane.YAxis.Title.Text = "Values"; myPane.XAxis.Type = AxisType.Date; myPane.YAxis.Scale.MaxAuto = true; myPane.XAxis.Scale.MaxAuto = true; zedGraphControl1.IsAutoScrollRange = true; zedGraphControl1.IsEnableWheelZoom = true; zedGraphControl1.IsEnableHPan = true; myPane.Legend.IsVisible = true; }
private void button5_Click(object sender, EventArgs e) { double Ie, Ic, Rc, Re, Rb, Vcc, Vce, Vbe, Imax, Vee, vc, vmax; Rc = Convert.ToDouble(txtemiterpolarmarc.Text) * 1000; Rb = Convert.ToDouble(txtemiterpolarmarb.Text) * 1000; Re = Convert.ToDouble(txtemiterpolarmare.Text) * 1000; Vcc = Convert.ToDouble(txtemiterpolarmavcc.Text); Imax = (1000 * Vcc) / Rc; Vee = Convert.ToDouble(txtemiterpolarmavee.Text); Vbe = Convert.ToDouble(txtemiterpolarmavbe.Text); Ie = -1000 * (Vee + Vbe) / Re; vc = Vcc - (Math.Pow(10, -3) * Ie * Rc); Vce = vc + Vbe; Imax = 1000 * (Vcc - Vee) / (Rc + Re); vmax = Vcc - Vee; ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl(); g.Size = new Size(panel3.Width - 2, panel3.Height - 2); ZedGraph.GraphPane myGraphPane = g.GraphPane; myGraphPane.Title.Text = "Dc yük eğrisi "; myGraphPane.XAxis.Title.Text = "Volt (V)"; myGraphPane.YAxis.Title.Text = "Akım(ma)"; PointPairList list1 = new PointPairList(); myGraphPane.AddCurve("", new double[] { 0, vmax }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.AddCurve("", new double[] { 0, Vce }, new double[] { Ie, Ie }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.AddCurve("", new double[] { Vce, Vce }, new double[] { Ie, 0 }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f); g.AxisChange(); panel3.Controls.Add(g); }
public void AddCurve(GraphPane pane, string name, string measure, Color color, SymbolType sType, int capacity) { _dataPointList = new RollingPointPairList(capacity); // Добавим кривую пока еще без каких-либо точек _myCurve = pane.AddCurve(string.Format("{0} ({1})",name,measure), _dataPointList, color, sType); }
private void btnGo1_Click(object sender, EventArgs e) { this.btnUpdate_Click(null, null); this.view.ConfigGraphPane(this.zgc1, this, PaneLayout.SingleRow, new List <Core.ChartInfo>() { new Core.ChartInfo() { Title = "Depends t with z", XAxisTitle = "t", YAxisTitle = "z" } }); ZedGraph.GraphPane gp = this.zgc1.MasterPane[0]; gp.CurveList.Clear(); string fname = listFunctions1.SelectedItem.ToString(); int randn = int.Parse(txtRandomCount.Text); this.curves.Clear(); Random r = new Random(); for (int i = 0; i < randn; i++) { string curveName = string.Format("curve{0}", i); this.curves.Add(curveName, new PointPairList()); Color c = Color.Black;//Color.FromArgb(255, r.Next(255), r.Next(255), r.Next(255)); gp.AddCurve(curveName, this.curves[curveName], c, SymbolType.None); this.view.ViewActionCall(ViewEventType.StartSolving1, fname, curveName); } }
public ZedGraphDataLoader(ZedGraphControl chart) { chart1 = chart; pane = chart1.GraphPane; pane.Chart.Border.IsVisible = false; // set scale pane.YAxis.Scale.MinGrace = 0; pane.YAxis.Scale.MaxGrace = 0; pane.XAxis.Scale.MinGrace = 0; pane.XAxis.Scale.MaxGrace = 0; pane.XAxis.Scale.MagAuto = false; pane.YAxis.Scale.MagAuto = false; SetPaneVisible(false); chart1.ZoomEvent += chart1_ZoomEvent; chart1.MouseDownEvent += chart1_MouseDownEvent; chart1.MouseUpEvent += chart1_MouseUpEvent; using (Graphics g = chart1.CreateGraphics()) { _dpiFactor = Convert.ToSingle(g.DpiX / 96.0); } // set fonts ApplyFontDefaults(); }
public void AddCurve(GraphPane pane, string name, Color color, int capacity = 8192) { _dataPointList = new RollingPointPairList(capacity); // Добавим кривую пока еще без каких-либо точек pane.AddCurve(name, _dataPointList, color, SymbolType.None); }
public FrmCompara(Historial his) { InitializeComponent(); //Para que la tabla ocupe dos columnas gp1 = zedGraphControl1.GraphPane; gp2 = zedGraphControl2.GraphPane; gp3 = zedGraphControl3.GraphPane; gp4 = zedGraphControl4.GraphPane; //Lista de los controles zedGraph controles = new List<ZedGraphControl>(); controles.Add(zedGraphControl1); controles.Add(zedGraphControl2); controles.Add(zedGraphControl3); controles.Add(zedGraphControl4); //Historial - Apunta al historial del form ppal h = his; //dgvDatos.Columns.Add("Graficas", "Graficas"); //for (int i = 0; i < h.tablas[0].Columns.Count; i++) // dgvDatos.Columns.Add(h.tablas[0].Columns[i].ColumnName, h.tablas[0].Columns[i].ColumnName); }
private void SetupZedGraph() { ZedGraph.GraphPane myPane = zedGraphControl1.GraphPane; // Set the titles myPane.Title.IsVisible = false; myPane.Legend.IsVisible = false; myPane.Fill = new ZedGraph.Fill(Color.White, Color.SlateGray, 45.0f); myPane.Chart.Fill = new ZedGraph.Fill(System.Drawing.Color.Transparent); // new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f); myPane.XAxis.Title.IsVisible = false; myPane.XAxis.Scale.Min = 1; myPane.XAxis.Scale.Max = 28; myPane.XAxis.MajorGrid.IsVisible = false; myPane.XAxis.MinorGrid.IsVisible = false; myPane.XAxis.Scale.IsVisible = false; myPane.YAxis.Title.IsVisible = false; myPane.YAxis.Scale.Min = 1; myPane.YAxis.Scale.Max = 28; myPane.YAxis.MajorGrid.IsVisible = false; myPane.YAxis.MinorGrid.IsVisible = false; myPane.YAxis.Scale.IsVisible = false; myPane.YAxis.Scale.IsReverse = true; zedGraphControl1.AxisChange(); }
public AHRSInterface() { InitializeComponent(); initializeSerialPort(); sensor = new AHRS(); // Set up event handlers sensor.PacketTimeoutEvent += new StateDelegate(TimeoutEventHandler); sensor.PacketReceivedEvent += new PacketDelegate(PacketReceivedEventHandler); sensor.DataReceivedEvent += new DataReceivedDelegate(DataReceivedEventHandler); sensor.PacketSentEvent += new PacketDelegate(PacketSentEventHandler); sensor.COMFailedEvent += new COMFailedDelegate(COMFailedEventHandler); sensor.PacketLabelEvent += new PacketLabel(PacketLabelHandler); renderTimer = new Timer(); renderTimer.Interval = 20; renderTimer.Enabled = true; renderTimer.Tick += new System.EventHandler(OnRenderTimerTick); Pos_Pane = PosGraph.GraphPane; Pos_Pane.Title.Text = "Position controller"; Pos_Pane.XAxis.Title.Text = "Time (s)"; Pos_Pane.YAxis.Title.Text = "Output"; Vel_Pane = VelGraph.GraphPane; Vel_Pane.Title.Text = "Velocity controller"; Vel_Pane.XAxis.Title.Text = "Time (s)"; Vel_Pane.YAxis.Title.Text = "Output"; Cur_Pane = CurGraph.GraphPane; Cur_Pane.Title.Text = "Current controller"; Cur_Pane.XAxis.Title.Text = "Time (s)"; Cur_Pane.YAxis.Title.Text = "Output"; Pos_Tar_List = new RollingPointPairList(SENSOR_GRAPH_POINTS); Pos_Motor_List = new RollingPointPairList(SENSOR_GRAPH_POINTS); Vel_Ext_List = new RollingPointPairList(SENSOR_GRAPH_POINTS); Vel_Int_List = new RollingPointPairList(SENSOR_GRAPH_POINTS); Vel_Motor_List = new RollingPointPairList(SENSOR_GRAPH_POINTS); Cur_Ext_List = new RollingPointPairList(SENSOR_GRAPH_POINTS); Cur_Int_List = new RollingPointPairList(SENSOR_GRAPH_POINTS); Cur_Motor_List = new RollingPointPairList(SENSOR_GRAPH_POINTS); Pos_Tar_Line = Pos_Pane.AddCurve("Position Target", Pos_Tar_List, Color.Blue, SymbolType.None); Pos_Motor_Line = Pos_Pane.AddCurve("Motor position", Pos_Motor_List, Color.Red, SymbolType.None); Vel_Ext_Line = Vel_Pane.AddCurve("External Velocity", Vel_Ext_List, Color.Blue, SymbolType.None); Vel_Int_Line = Vel_Pane.AddCurve("Internal Velocity", Vel_Int_List, Color.Red, SymbolType.None); Vel_Motor_Line = Vel_Pane.AddCurve("Motor Velocity", Vel_Motor_List, Color.Green, SymbolType.None); Cur_Ext_Line = Cur_Pane.AddCurve("External Current", Cur_Ext_List, Color.Blue, SymbolType.None); Cur_Int_Line = Cur_Pane.AddCurve("Internal Current", Cur_Int_List, Color.Red, SymbolType.None); Cur_Motor_Line = Cur_Pane.AddCurve("Motor Current", Cur_Motor_List, Color.Green, SymbolType.None); }
public static ZedGraph.GraphPane Getgp() { if (gp == null) { gp = MainForm.getInstance().zgcDep.GraphPane; } return(gp); }
/// <summary> /// /// </summary> /// <param name="gp"></param> /// <param name="xTitle"></param> /// <param name="yTitle"></param> public void ConfigRecruitLineGraphPane(GraphPane gp, string xTitle, string yTitle) { gp.XAxis.Title.Text = xTitle; gp.XAxis.Type = AxisType.Date; gp.XAxis.Scale.Format = "d"; gp.YAxis.Title.Text = yTitle; }
public RatingTableZedGraphOptions(GraphPane chart) { m_chart = chart; InitializeComponent(); this.checkBoxXAxisIsLog.Checked = m_chart.XAxis.Type == AxisType.Log; this.checkBoxYAxisIsLog.Checked = m_chart.YAxis.Type == AxisType.Log; }
private string MyPointValueHandler(ZedGraphControl control, GraphPane pane, CurveItem curve, int iPt) { // Get the PointPair that is under the mouse PointPair pt = curve[iPt]; return curve.Label.Text + " IV is " + pt.Y.ToString("f2") + "% " + pt.X.ToString("f1") + " strike"; }
public GraphPane CreateLineGraph(int nSeries, string title, string xAxisTitle, string yAxisTitle, bool xAxisTitleVisible, bool yAxisTitleVisible, bool xScaleVisible, bool yScaleVisible, bool xMajorGridVisible, bool xIsBetweenLabels, bool yMajorGridVisible, bool yIsBetweenLabels) { GraphPane graphPane = new GraphPane(); SetupGraphPane(graphPane, title, xAxisTitle, yAxisTitle, xAxisTitleVisible, yAxisTitleVisible, xScaleVisible, yScaleVisible, xMajorGridVisible, xIsBetweenLabels, yMajorGridVisible, yIsBetweenLabels); PointPairList points = new PointPairList(); graphPane.AddCurve("", points, Color.Yellow, SymbolType.None); return graphPane; }
public GraphicsForm() { InitializeComponent(); list = new PointPairList(); p = new GlobalServParam(); s = new Statics(); pane = zedGraphControl1.GraphPane; }
private void btnGo2_Click(object sender, EventArgs e) { this.btnUpdate_Click(null, null); List <Core.ChartInfo> chInfo = new List <Core.ChartInfo>(); chInfo.Add(new Core.ChartInfo() { Title = "Depends (t,z1)", XAxisTitle = "t", YAxisTitle = "z1" }); chInfo.Add(new Core.ChartInfo() { Title = "Depends (t,z1)", XAxisTitle = "t", YAxisTitle = "z2" }); chInfo.Add(new Core.ChartInfo() { Title = "Depends (z1,z2)", XAxisTitle = "z1", YAxisTitle = "z2" }); this.view.ConfigGraphPane(this.zgc1, this, PaneLayout.ExplicitCol21, chInfo); ZedGraph.GraphPane gp = this.zgc1.MasterPane[0]; ZedGraph.GraphPane gp1 = this.zgc1.MasterPane[1]; ZedGraph.GraphPane gp2 = this.zgc1.MasterPane[2]; gp.CurveList.Clear(); gp1.CurveList.Clear(); gp2.CurveList.Clear(); string fname = listFunctions2.SelectedItem.ToString(); int randn = int.Parse(txtRandomCount.Text); this.curves.Clear(); this.curves1.Clear(); this.curves2.Clear(); Random r = new Random(); for (int i = 0; i < randn; i++) { string curveName = string.Format("curve{0}", i); this.curves.Add(curveName, new PointPairList()); this.curves1.Add(curveName, new PointPairList()); this.curves2.Add(curveName, new PointPairList()); Color c = Color.Black;//Color.FromArgb(255, r.Next(255), r.Next(255), r.Next(255)); gp.AddCurve(curveName, this.curves[curveName], c, SymbolType.None); gp1.AddCurve(curveName, this.curves1[curveName], c, SymbolType.None); gp2.AddCurve(curveName, this.curves2[curveName], c, SymbolType.None); this.view.ViewActionCall(ViewEventType.StartSolving2, fname, curveName); } //this.tabControl.SelectedIndex = 0; }
public void ConnectToGraph(ZedGraph.GraphPane objPane) { for (int nInd1 = 0; nInd1 < MAX_MARKERS; nInd1++) { for (int nInd2 = 0; nInd2 < (int)RFExplorerSignalType.TOTAL_ITEMS; nInd2++) { objPane.GraphObjList.Add(m_arrMarkers[nInd1][nInd2]); } } }
//private static void zedGraphControl1_MouseMove(object sender, MouseEventArgs e)//鼠标移动出现虚线 //{ // using (Graphics gc = MainForm.getInstance().DTSReal.CreateGraphics()) // using (Pen pen = new Pen(Color.Gray)) // { // pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; // RectangleF rect = MainForm.getInstance().DTSReal.GraphPane.Chart.Rect; // //确保在画图区域 // if (rect.Contains(e.Location)) // { // MainForm.getInstance().DTSReal.Refresh(); // gc.DrawLine(pen, e.X, rect.Top, e.X, rect.Bottom); // gc.DrawLine(pen, rect.Left, e.Y, rect.Right, e.Y); // } // } //} public static void drawRealDTS(List <DataTable> dt) { float wellzero = ZedGraphClass.getWellZero(); ZedGraph.GraphPane gp = MainForm.getInstance().DTSReal.GraphPane; MainForm.getInstance().DTSReal.PointValueEvent += new ZedGraphControl.PointValueHandler(ZedGraphClass.MyPointValueHandlerTime);//设置节点信息显示样式 //MainForm.getInstance().DTSReal.IsShowHScrollBar = true;//横向滚动条 // MainForm.getInstance().DTSReal.MouseMove += zedGraphControl1_MouseMove;//鼠标在图上移动出现x虚线 MainForm.getInstance().DTSReal.IsShowPointValues = true; // MainForm.getInstance().DTSReal.IsZoomOnMouseCenter = false; //使用滚轮时以鼠标所在点进行缩放还是以图形中心进行缩放。 gp.GraphObjList.Clear(); gp.CurveList.Clear(); //int Linenumber = Convert.ToInt32(MainForm.getInstance().DTSLineNumber.Text); //int k = 0; //if (dt.Count - Linenumber < 0) //{ //} //else //{ // k = dt.Count - Linenumber; //} for (int i = 1; i < dt.Count; i++)//从第一条线开始,并且两条线 { DataTable table = dt[i]; string Linename = table.Rows[0][0].ToString(); PointPairList list1 = new PointPairList(); for (int j = 0; j < table.Rows.Count; j++) { double x; float y; //X轴减去部分井口数据。 x = float.Parse(table.Rows[j][1].ToString()) - wellzero; y = float.Parse(table.Rows[j][2].ToString()); list1.Add(x, y); } if (list1.Count == 0)//如果曲线没有数据 { continue; } else { Color co = ZedGraphClass.GetColor(i); LineItem _lineitem2 = gp.AddCurve(Linename, list1, ZedGraphClass.GetColor(i), SymbolType.Circle); _lineitem2.Line.Width = 2.0F; //线的宽度 string la = _lineitem2.Label.Text.ToString(); _lineitem2.Symbol.Size = 2.4F; //线上节点的大小 _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色 //gp.AxisChange();//若是 } } gp.AxisChange();//若是放到上面的那一行,因为数据太多,会有延迟,导致图形颜色不断变化(一条线一条线的画) MainForm.getInstance().DTSReal.Refresh(); }
public static void exchange(object sender, EventArgs e) { ZedGraph.GraphPane gp = MainForm.getInstance().zgcTime.GraphPane; if (MainForm.getInstance().exchange.Text == "0") { MainForm.getInstance().exchange.Text = "1"; gp.XAxis.Title.Text = "温度"; //X轴名称; gp.YAxis.Title.Text = "深度"; //Y轴名称 } else { MainForm.getInstance().exchange.Text = "0"; gp.XAxis.Title.Text = "深度"; //X轴名称; gp.YAxis.Title.Text = "温度"; //Y轴名称 } }
/// <summary> /// /// </summary> public void Draw(ZedGraph.GraphPane pane, object dataSource) { if (this.GraphPaneConfig == null) { return; } if (this.DataSource == null) { return; } this.GraphPaneConfig.ConfigGraphPane(pane); foreach (CurveConfigBase cfg in this.GraphPaneConfig.CurveConfigBaseCollection) { CurveDataCollection cds = cfg.Create(dataSource); foreach (CurveData cd in cds) { switch (this.GraphPaneConfig.CurItemType) { case CurveItemType.Line: if (this.GraphPaneConfig.XAxisType == ZedGraph.AxisType.Date) { ZedGraph.LineItem curve = pane.AddCurve(cd.Name, cd.PointList, cd.Color); curve.Symbol.Fill = new ZedGraph.Fill(Color.White); } else if (this.GraphPaneConfig.XAxisType == ZedGraph.AxisType.Text) { LineItem curve = pane.AddCurve(cd.Name, null, cd.YValues, cd.Color); pane.XAxis.Scale.TextLabels = cd.XAxisLabels; curve.Symbol.Fill = new Fill(Color.White); } break; case CurveItemType.Bar: pane.AddBar(cd.Name, null, cd.YValues, cd.Color); pane.XAxis.Scale.TextLabels = cd.XAxisLabels; break; case CurveItemType.Pie: pane.AddPieSlices(cd.YValues, cd.XAxisLabels); break; } } } }
public void GraphInit() { // Create a new graph //TODO: Allow graph to change size when widow is adjusted myPane = new ZedGraph.GraphPane(new Rectangle(0, 0, (int)Application.Current.MainWindow.Width, 325), "Allele Frequency\n", "Generations", "Frequency of A"); myPane.XAxis.Max = generation.Value; myPane.XAxis.Min = 0; myPane.YAxis.Max = 1; myPane.YAxis.Min = 0; myPane.AxisChange(graphics); }
public void CreateChart2(ZedGraphControl zedGraphControl2) { ZedGraph.GraphPane myPane2 = zedGraphControl2.GraphPane; myPane2.Title.Text = "Spectrum Analysis (DFT)"; myPane2.XAxis.Title.Text = "Frequency"; zedGraphControl2.GraphPane.CurveList.Clear(); zedGraphControl2.GraphPane.GraphObjList.Clear(); if (Linear.Checked) { myPane2.YAxis.Title.Text = "[Linearized]"; for (int x = 199; x > 0; x--) { list1.Add(-1 * x, wave[x]); } for (int x = 0; x < 199; x++) { list1.Add(x, wave[x]); } } else { myPane2.YAxis.Title.Text = "[dB]"; for (int x = 199; x > 0; x--) { list1.Add(-1 * x, 20 * Math.Log10(wave[x])); } for (int x = 0; x < 199; x++) { list1.Add(x, 20 * Math.Log10(wave[x])); } } ZedGraph.LineItem myCurve = myPane2.AddCurve("", list1, Color.Black, SymbolType.None); myPane2.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f); myPane2.XAxis.MajorGrid.IsVisible = true; myPane2.YAxis.MajorGrid.IsVisible = true; zedGraphControl2.GraphPane.YAxis.Scale.MaxAuto = true; myPane2.XAxis.Scale.Min = 0; myPane2.XAxis.Scale.Max = 200; myPane2.XAxis.Scale.MinorStep = 1; myPane2.XAxis.Scale.MajorStep = 10; zedGraphControl2.AxisChange(); zedGraphControl2.Invalidate(); }
private void button1_Click(object sender, EventArgs e) { this.btnUpdate_Click(null, null); this.listBox1.Items.Clear(); ZedGraph.GraphPane gp = this.zgSolve1.GraphPane; gp.CurveList.Clear(); this.curves.Clear(); string fname = listFunctions2.SelectedItem.ToString(); string curveName = "Line2"; this.curves.Add(curveName, new PointPairList()); Color c = Color.DarkBlue;//Color.FromArgb(255, r.Next(255), r.Next(255), r.Next(255)); gp.AddCurve(curveName, this.curves[curveName], c, SymbolType.None); this.view.ViewActionCall(ViewEventType.SolovePodhod2Type2, fname, curveName); }
void grafigim(double Vcc, double Ic, double Imax, double Vce) { ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl(); g.Size = new Size(panel1.Width - 2, panel1.Height - 2); ZedGraph.GraphPane myGraphPane = g.GraphPane; myGraphPane.Title.Text = "Dc yük eğrisi "; myGraphPane.XAxis.Title.Text = "Volt (V)"; myGraphPane.YAxis.Title.Text = "Akım(ma)"; PointPairList list1 = new PointPairList(); myGraphPane.AddCurve("", new double[] { 0, Vcc }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.AddCurve("", new double[] { 0, Vce }, new double[] { Ic, Ic }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.AddCurve("", new double[] { Vce, Vce }, new double[] { Ic, 0 }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f); g.AxisChange(); panel1.Controls.Add(g); }
private void frmAnalysiseCurve_Load(object sender, EventArgs e) { //m_SR = GetSR((ushort)_fmMain.m_SensorArray[_fmMain.m_LSensorArray[0].SensorIndex].scale); _ResultPanel = this.zedGraphControl.GraphPane; initResultCurve(this.zedGraphControl); this.zedGraphControl.Invalidated += new InvalidateEventHandler(zedGraphControl_Invalidated); this.cmbYr.SelectedIndex = int.Parse(RWconfig.GetAppSettings("ShowY")); this.cmbXr.SelectedIndex = int.Parse(RWconfig.GetAppSettings("ShowX")); this.zedGraphControl.RestoreScale(this.zedGraphControl.GraphPane); m_zedGraphSyb = new Symbol(); m_zedGraphSyb.IsAntiAlias = true; m_zedGraphSyb.Type = SymbolType.Circle; m_zedGraphSyb.Size = 4; m_zedGraphSyb.Border.Width = 2; m_zedGraphSyb.Fill.Color = Color.DarkRed; m_zedGraphSyb.IsVisible = true; if (this._List_Data == null) { MessageBox.Show(this, "曲线数据不存在!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); this.Dispose(); } //将计算后的值呈现在Label上 m_t = new HR_Test.BLL.GBT3354_Samples(); m_m = m_t.GetModel(_TestSampleNo); if (m_m != null) { m_S0 = (double)m_m.S0; m_Ll = (double)m_m.lL; m_Lt = (double)m_m.lT; m_Ez1 = (double)m_m.εz1; m_Ez2 = (double)m_m.εz1; } }
private void button3_Click(object sender, EventArgs e) { double Ib, Ic, Rc, Rb, Vcc, Vce, Vbe, Imax, beta; Rc = Convert.ToDouble(txtbeyzrc.Text) * 1000; Rb = Convert.ToDouble(txtbeyzrb.Text) * 1000; Vcc = Convert.ToDouble(txtbeyzvcc.Text); Imax = (1000 * Vcc) / Rc; beta = Convert.ToDouble(txtbeyzbeta.Text); Vbe = Convert.ToDouble(txtbeyzvbe.Text); Ib = ((Vcc - Vbe) / Rb) * Math.Pow(10, 6); Ic = beta * Ib * Math.Pow(10, -3); Vce = Vcc - Ic * Rc * Math.Pow(10, -3); lblbeyzib.Text = " = " + Ib.ToString(); lblbeyzıc.Text = " = " + Ic.ToString(); lblbeyzımax.Text = " = " + Imax.ToString(); lblbeyzvce.Text = " = " + Vce.ToString(); ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl(); g.Size = new Size(panel2.Width - 2, panel2.Height - 2); ZedGraph.GraphPane myGraphPane = g.GraphPane; myGraphPane.Title.Text = "Dc yük eğrisi "; myGraphPane.XAxis.Title.Text = "Volt (V)"; myGraphPane.YAxis.Title.Text = "Akım(ma)"; PointPairList list1 = new PointPairList(); myGraphPane.AddCurve("", new double[] { 0, Vcc }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.AddCurve("", new double[] { 0, Vce }, new double[] { Ic, Ic }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.AddCurve("", new double[] { Vce, Vce }, new double[] { Ic, 0 }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f); g.AxisChange(); panel2.Controls.Add(g); }
private void button2_Click(object sender, EventArgs e) { double Ib, Ie, Ic, Rc, Rb, Re, Vcc, Vce, Imax, beta; Rc = Convert.ToDouble(txtemiterdirencRC.Text) * 1000; Rb = Convert.ToDouble(txtemiterdirencRB.Text) * 1000; Re = Convert.ToDouble(txtemiterdirencRe.Text) * 1000; Vcc = Convert.ToDouble(txtemiterdirencVcc.Text); Imax = Vcc / (Rc + Re); beta = Convert.ToDouble(txtemiterdirencBeta.Text); double Vbe; Vbe = Convert.ToDouble(txtemiterdirencVbe.Text); Ib = ((Vcc - Vbe) / (Rb + (beta + 1) * Re)); Ic = beta * Ib; Ie = (beta + 1) * Ib; Vce = Vcc - Ic * Rc - Ie * Re; Imax = 1000 * Imax; Ic = 1000 * Ic; ZedGraph.ZedGraphControl g = new ZedGraph.ZedGraphControl(); g.Size = new Size(panel1.Width - 2, panel1.Height - 2); ZedGraph.GraphPane myGraphPane = g.GraphPane; myGraphPane.Title.Text = "Dc yük eğrisi "; myGraphPane.XAxis.Title.Text = "Volt (V)"; myGraphPane.YAxis.Title.Text = "Akım(ma)"; PointPairList list1 = new PointPairList(); myGraphPane.AddCurve("", new double[] { 0, Vcc }, new double[] { Imax, 0 }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.AddCurve("", new double[] { 0, Vce }, new double[] { Ic, Ic }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.AddCurve("", new double[] { Vce, Vce }, new double[] { Ic, 0 }, Color.Blue, ZedGraph.SymbolType.None); myGraphPane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.Red, 3.0f); g.AxisChange(); panel1.Controls.Add(g); }
public CZedGraph_RealTime(ZedGraphControl zgc) { zedGraphControl = zgc; myPane = zgc.GraphPane; myPane.Title.Text = "Graph name"; myPane.TitleGap = 0; myPane.XAxis.Title.Text = "X Axis"; myPane.XAxis.Title.Gap = 0; myPane.YAxis.Title.Text = "Y Axis"; myPane.YAxis.Title.Gap = 0; myPane.IsFontsScaled = false; myPane.XAxis.Scale.MaxAuto = true; myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F); myPane.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45F); myPane.Legend.Position = ZedGraph.LegendPos.InsideTopLeft; myPane.Legend.FontSpec = new FontSpec("Ariel", 25, Color.Black, true, false, false); PointsLists = new List <RollingPointPairList>(); }
public static void DrawingDep()//画时间温度曲线 { //获取时间的查询条件 string messageError = null; String SQLstr = getSQLstr(); MySqlConnection mycon = new MySqlConnection(); mycon = getMycon(); //获取井口位置 float wellzero = ZedGraphClass.getWellZero(); //获取循环(单循环还是多循环) string button = MainForm.getInstance().number.Text; //画图图禁止菜单和画图区域 MainForm.getInstance().groupBox2.Enabled = false; MainForm.getInstance().zgcDep.Enabled = false; //新建数据库连接 string DsingleDepth = MainForm.getInstance().DsingleDepth.Text; if (SQLstr != null) { DataTable SQLName = getTNameTable(DintervalTime1, DintervalTime2);//获取需要使用的表名称 if (SQLName.Rows.Count != 0) { ArrayList SQLList = MyDataTable.getDepth(wellzero, DsingleDepth); //获取深度值 if (SQLList.Count <= 15 && SQLList.Count > 0) //15条线之内 { SQLList = ZedGraphClass.getNewDepth(SQLList); //去重 ZedGraph.GraphPane gp = MainForm.getInstance().zgcDep.GraphPane; //gp.CurveList.Clear();//清除上一步画的图 gp.GraphObjList.Clear(); gp.CurveList.Clear(); //是否X、Y轴缩放的定义 if (MainForm.getInstance().label1.Text == "1") { MainForm.getInstance().zgcDep.IsEnableVZoom = true; //Y轴缩放 MainForm.getInstance().zgcDep.IsEnableHZoom = true; //x轴缩放 } else { MainForm.getInstance().zgcDep.IsEnableVZoom = false; //禁止Y轴缩放 MainForm.getInstance().zgcDep.IsEnableHZoom = true; //x轴缩放 } MainForm.getInstance().zgcDep.PointValueEvent += new ZedGraphControl.PointValueHandler(ZedGraphClass.MyPointValueHandlerDep); //设置节点信息显示样式 MainForm.getInstance().zgcDep.MouseMove += zedGraphControl1_MouseMove; //鼠标在图上移动出现x虚线 MainForm.getInstance().zgcDep.IsShowPointValues = true; //显示节点坐标值 MainForm.getInstance().zgcDep.IsZoomOnMouseCenter = false; //使用滚轮时以鼠标所在点进行缩放还是以图形中心进行缩放。 if (MainForm.getInstance().DintervalTM1.Text != "" && MainForm.getInstance().DintervalTM2.Text != "") { gp.YAxis.Scale.Min = float.Parse(MainForm.getInstance().DintervalTM1.Text); gp.YAxis.Scale.Max = float.Parse(MainForm.getInstance().DintervalTM2.Text); } else { gp.YAxis.Scale.MaxAuto = true; //自动设置大小 gp.YAxis.Scale.MinAuto = true; } MainForm.getInstance().zgcDep.IsAutoScrollRange = false; //坐标轴刻度格式 gp.XAxis.Scale.Format = "yyyy-MM-dd HH:mm:ss"; //横轴格式 gp.XAxis.Type = AxisType.Date; //格式 string[] hn = new string[SQLList.Count]; //折线的标签 if (button == "two") //循环作图 { for (int xunhuan = 0; xunhuan < 4; xunhuan++) { //清除上一步画的图 gp.GraphObjList.Clear(); gp.CurveList.Clear(); for (int i = 0; i < SQLList.Count; i++) { System.Threading.Thread.Sleep(1000); PointPairList list1 = new PointPairList(); DataTable dtValue = new DataTable(); string SQLque = "RecordTime"; dtValue = MyDataTable.getDataTable(SQLName, Convert.ToInt32(SQLList[i]), SQLstr, SQLque, mycon); float e = Convert.ToInt32(SQLList[i].ToString()) - wellzero; hn[i] = e + "m"; for (int k = 0; k < dtValue.Rows.Count; k++) { int bili = 1; if (dtValue.Rows.Count > 1000) { bili = dtValue.Rows.Count / 500; } if (k % bili == 0) { double x = (double)new XDate((DateTime)dtValue.Rows[k]["RecordTime"]); string a = dtValue.Rows[k]["RecordTime"].ToString(); double y = double.Parse(dtValue.Rows[k]["TM"].ToString()); list1.Add(x, y); } } if (list1.Count == 0 && xunhuan == 0) //如果曲线没有数据 { messageError += "深度" + SQLList[i] + "m无数据\n"; continue; } else { Color co = ZedGraphClass.GetColor(i); LineItem _lineitem2 = gp.AddCurve(hn[i], list1, co, SymbolType.Circle); _lineitem2.Line.Width = 2.0F; //线的宽度 //节点设置 if (drawAttribute.Linenum == 2) { _lineitem2.Line.IsVisible = false; } _lineitem2.Symbol.Size = 2.4F; //线上节点的大小 _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色 gp.AxisChange(); MainForm.getInstance().zgcDep.Refresh(); } } } } else { for (int i = 0; i < SQLList.Count; i++) { PointPairList list1 = new PointPairList(); DataTable dtValue = new DataTable(); string SQLque = "RecordTime"; dtValue = MyDataTable.getDataTable(SQLName, Convert.ToInt32(SQLList[i]), SQLstr, SQLque, mycon); float e = Convert.ToInt32(SQLList[i].ToString()) - wellzero; hn[i] = e + "m"; for (int k = 0; k < dtValue.Rows.Count; k++) { int bili = 1; if (dtValue.Rows.Count > 1000) { bili = dtValue.Rows.Count / 500; } if (k % bili == 0) { double x = (double)new XDate((DateTime)dtValue.Rows[k]["RecordTime"]); string a = dtValue.Rows[k]["RecordTime"].ToString(); double y = double.Parse(dtValue.Rows[k]["TM"].ToString()); list1.Add(x, y); } } if (list1.Count == 0) //如果曲线没有数据 { messageError += "深度" + SQLList[i] + "m无数据\n"; continue; } else { Color co = ZedGraphClass.GetColor(i); LineItem _lineitem2 = gp.AddCurve(hn[i], list1, co, SymbolType.Circle); _lineitem2.Line.Width = 2.0F; //线的宽度 //节点设置 if (drawAttribute.Linenum == 2) { _lineitem2.Line.IsVisible = false; } _lineitem2.Symbol.Size = 2.4F; //线上节点的大小 _lineitem2.Symbol.Fill = new Fill(co); //线上节点的颜色 gp.AxisChange(); MainForm.getInstance().zgcDep.Refresh(); } } } } else if (SQLList.Count > 15) { //MessageBox.Show("深度区间太大,曲线条数大于15"); MessageBox.Show("深度区间太大,曲线条数大于15!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { // MessageBox.Show("在所选时间区间内数据库中无数据");//表中无数据 MessageBox.Show("请填写深度!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { // MessageBox.Show("所选时间区间内没有数据,请更改时间区域!"); //没有表 MessageBox.Show("所选时间区间内没有数据,请更改时间区域!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (messageError != null) { MessageBox.Show("以下深度点无数据!\n" + messageError, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { // MessageBox.Show("时间区间选择不正确,请修改!"); MessageBox.Show("时间区间选择不正确,请修改!", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } MainForm.getInstance().groupBox2.Enabled = true; MainForm.getInstance().zgcDep.Enabled = true; mycon.Close(); mycon.Dispose(); SQLstr = null; }
private void addPie(string name, double time, ZedGraph.GraphPane pane, Color color) { float angle = (float)(time / 4); pane.AddPieSlice(time, color, Color.White, angle, 0, name); }
private void btnSolveRK_Click(object sender, EventArgs e) { this.rtbResult1.Text = this.rtbResult2.Text = string.Empty; this.dgvTabRes.DataSource = null; this.n = int.Parse(this.txtN.Text); this.setCount = this.rbN1.Checked ? 1 : 2; //this.gamma = double.Parse(txtGamma.Text); ZedGraph.GraphPane gp = this.zgcMainChart2.GraphPane; gp.CurveList.Clear(); this.curves.Clear(); this.curves.Add(this.curveName, new PointPairList()); gp.AddCurve(this.curveName, this.curves[curveName], Color.Black, SymbolType.None); List <double> gammaList = new List <double>(); List <double> p = new List <double>(); for (int i = 0; i < dgvGama.ColumnCount; i++) { gammaList.Add(Convert.ToDouble(dgvGama.Rows[0].Cells[i].Value)); } List <TaskParameter> list = new List <TaskParameter>(); for (int i = 0; i < dgvParameters.RowCount; i++) { TaskParameter tp = new TaskParameter(dgvParameters.ColumnCount); for (int j = 0; j < dgvParameters.ColumnCount; j++) { double val = Convert.ToDouble(dgvParameters.Rows[i].Cells[j].Value); tp.Param[j] = val; } list.Add(tp); } this.tps = new TaskParameters(list, gammaList); string mfName = this.setCount == 1 ? "MF1" : "MF2"; this.funcDescr = new Functions_2_2(mfName, this.fnames[(sfList.SelectedItem as string).ToUpper()]); this.tw = new TaskWorker(tps, funcDescr.GetType(), funcDescr.MainFuncName, funcDescr.SecFuncName, funcDescr); this.startVector = this.setCount == 1 ? new Vector(1, double.Parse(this.txtY0.Text)) : new Vector(2, double.Parse(this.txtY00.Text), double.Parse(this.txtY01.Text)); RKVectorForm rk = new RKVectorForm(tw, curveName, double.Parse(this.txtT0.Text), double.Parse(this.txtT1.Text), startVector); this.res = rk.SolveWithConstH(n, RKMetodType.RK4_1); if (this.rbN1.Checked) { res.ForEach(r => this.curves[curveName].Add(r.X, r.Y[0])); } else { res.ForEach(r => this.curves[curveName].Add(r.Y[0], r.Y[1])); } this.zgcMainChart2.AxisChange(); this.zgcMainChart2.Refresh(); if (this.setCount == 1) { this.tblResList = new List <ResPointViewType1>(); for (int i = 0; i < res.Count - 1; i++) { (this.tblResList as List <ResPointViewType1>).Add(new ResPointViewType1(res[i].X, res[i].Y[0], -1, -1)); } this.dgvTabRes.DataSource = null; this.dgvTabRes.DataSource = tblResList; } else { this.tblResList = new List <ResPointViewType2>(); for (int i = 0; i < res.Count - 2; i++) { (this.tblResList as List <ResPointViewType2>).Add(new ResPointViewType2(res[i].X, res[i].Y[0], res[i].Y[1], -1, -1)); } this.dgvTabRes.DataSource = null; this.dgvTabRes.DataSource = tblResList; } this.dgvTabRes.RefreshDataSource(); this.randomStartParameters = this.GetRandomStartParam(); }