public static void ShowHistorgam(string title, string[] xLabels, double[] yValues) { // Графики строятся сторонней библиотекой ZedGraph. Документацию можно найти тут http://zedgraph.sourceforge.net/samples.html // Не бойтесь экспериментировать с кодом самостоятельно! var chart = new ZedGraphControl() { Dock = DockStyle.Fill }; chart.GraphPane.Title.Text = title; chart.GraphPane.YAxis.Title.Text = "Y"; chart.GraphPane.AddBar("", Enumerable.Range(0, yValues.Length).Select(i => (double)i).ToArray(), yValues, Color.Blue); chart.GraphPane.YAxis.Scale.MaxAuto = true; chart.GraphPane.YAxis.Scale.MinAuto = true; chart.GraphPane.XAxis.Type = AxisType.Text; chart.GraphPane.XAxis.Scale.TextLabels = xLabels; chart.AxisChange(); // Form — это привычное нам окно программы. Это одна из главных частей подсистемы под названием Windows Forms http://msdn.microsoft.com/ru-ru/library/ms229601.aspx var form = new Form(); form.Text = title; form.Size = new Size(800, 600); form.Controls.Add(chart); form.ShowDialog(); }
private void CreateGraph() { GraphPane myPane = zedGraphControl1.GraphPane; myPane.Title.Text = "Plot of " + foot + " foot motion.\n"; myPane.XAxis.Title.Text = "Time (seconds)"; myPane.YAxis.Title.Text = foot + "foot motion (mm)"; //lists to save points as they come from the MCE xData = new PointPairList(); yData = new PointPairList(); zData = new PointPairList(); // Initially, a curve is added with no data points (list is empty) // Color is blue, and there will be no symbols // 2nd line graph (red) added to show peaks curve = myPane.AddCurve("z-position", zData, Color.Blue, SymbolType.None); curve = myPane.AddCurve("y-position", yData, Color.Red, SymbolType.None); curve = myPane.AddCurve("x-position", yData, Color.Green, SymbolType.None); //curve = myPane.AddCurve("Peak", peakData, Color.Red, SymbolType.Plus); // Just manually control the X axis range so it scrolls continuously // instead of discrete step-sized jumps myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = 6.0; myPane.YAxis.Scale.Min = -700; //if needed, fix Y-axis to a max and min myPane.YAxis.Scale.Max = 400; myPane.XAxis.Scale.MinorStep = 0.2; myPane.XAxis.Scale.MajorStep = 1.0; // Scale the axes zedGraphControl1.AxisChange(); }
public void DrawSorted(SeriesList list, string title, string subTitle, string xAxisTitle) { Clear(); for (int i = 0; i < list.Count; i++) { PointPairList pairs = new PointPairList(); foreach (var pt in list[i]) { pairs.Add(pt.Percent, pt.Value); } LineItem myCurve = pane.AddCurve(list[i].Appearance.LegendText, pairs, Color.Red);//,SymbolType.Diamond); myCurve.Symbol.Fill.Type = FillType.None; } pane.XAxis.Title.Text = xAxisTitle; pane.XAxis.Type = AxisType.Linear; pane.YAxis.Scale.Mag = 0; pane.YAxis.Scale.Format = "#,#"; pane.XAxis.Scale.Format = ""; //pane.XAxis.Scale.MajorUnit = DateUnit.Day; //pane.XAxis.Scale.MajorStep = 1; LabelYaxis(list); chart1.AxisChange(); chart1.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 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 Generate(ref ZedGraph.ZedGraphControl graph) { GraphPane myPane = graph.GraphPane; myPane.Fill = new Fill(Color.FromArgb(210, 210, 210), Color.FromArgb(240, 250, 240)); myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 210), -45F); myPane.Legend.Position = ZedGraph.LegendPos.Right; myPane.Legend.FontSpec.Size = 7; myPane.Title.Text = "DB Size report"; myPane.XAxis.Title.Text = "Table"; myPane.YAxis.Title.Text = "Size in MB"; graph.AxisChange(); IList <E_Label_Value> List = E_Label_Value.LoadFromQuery("SELECT left([TableName],cast((CHARINDEX('_',[TableName],0)-1) as bigint)) as Label ,sum([TotalSpaceMB]) as Value FROM [SYNAPSE].[dbo].[V_Synapse_DB_USAGE] group by left([TableName],cast((CHARINDEX('_',[TableName],0)-1) as bigint)) order by Label"); double[] y = new double[List.Count]; string[] x = new string[List.Count]; int i = 0; foreach (E_Label_Value val in List) { x[i] = val.Label; y[i] = (double)val.Value; i++; } BarItem myCurve = myPane.AddBar("Curve 1", null, y, Color.White); myPane.XAxis.Scale.TextLabels = x; myPane.XAxis.Scale.FontSpec.Angle = 45; myPane.XAxis.Scale.FontSpec.Size = 6; myCurve.Bar.Fill = new Fill(Color.White, Color.SteelBlue, 45.0f); // Draw the X tics between the labels instead of at the labels myPane.XAxis.MajorTic.IsBetweenLabels = true; myPane.Legend.IsVisible = false; // Set the XAxis to Text type myPane.XAxis.Type = AxisType.Text; graph.AxisChange(); }
public virtual void Generate(ref ZedGraph.ZedGraphControl graph) { GraphPane myPane = graph.GraphPane; myPane.Fill = new Fill(Color.FromArgb(210, 210, 210), Color.FromArgb(240, 250, 240)); myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 210), -45F); myPane.Legend.Position = ZedGraph.LegendPos.Right; myPane.Legend.FontSpec.Size = 7; myPane.Title.Text = title; myPane.XAxis.Title.Text = xtitle; myPane.YAxis.Title.Text = ytitle; graph.AxisChange(); IList <E_Label_Value> List = E_Label_Value.LoadFromQuery(query); double[] y = new double[List.Count]; string[] x = new string[List.Count]; int i = 0; foreach (E_Label_Value val in List) { x[i] = val.Label; y[i] = (double)val.Value; i++; } BarItem myCurve = myPane.AddBar("Curve 1", null, y, Color.White); myPane.XAxis.Scale.TextLabels = x; myPane.XAxis.Scale.FontSpec.Angle = angle; myPane.XAxis.Scale.FontSpec.Size = fontsize; myCurve.Bar.Fill = new Fill(Color.Orange, Color.Red, 45.0f); // Draw the X tics between the labels instead of at the labels myPane.XAxis.MajorTic.IsBetweenLabels = true; myPane.Legend.IsVisible = false; // Set the XAxis to Text type myPane.XAxis.Type = AxisType.Text; graph.AxisChange(); }
public static void ShowHeatmap(string title, double[,] heat, int xMin, int yMin) { var chart = new ZedGraphControl() { Dock = DockStyle.Fill }; var maxHeat = heat.Cast<double>().Max(); chart.GraphPane.Title.Text = title; chart.GraphPane.YAxis.Title.Text = ""; var maxSize = Math.Max(heat.GetLength(0), heat.GetLength(1)); for (int x = 0; x < heat.GetLength(0); x++) for (int y = 0; y < heat.GetLength(1); y++) { var value = heat[x, y]; if (value > 1000) throw new ArgumentException("too large heat value " + value); var color = Color.FromArgb(255, 50, (int)(255 * value / maxHeat), 0); var lineItem = chart.GraphPane.AddCurve("", new double[] { x + xMin }, new double[] { y + yMin }, color); lineItem.Symbol.Type = SymbolType.Circle; lineItem.Symbol.Fill = new Fill(color); lineItem.Symbol.Size = (float)(600 * value / maxHeat / maxSize); } chart.GraphPane.YAxis.Scale.MaxAuto = true; chart.GraphPane.YAxis.Scale.MinAuto = true; chart.AxisChange(); var form = new Form(); form.Text = title; form.Size = new Size(800, 600); form.Controls.Add(chart); form.ShowDialog(); }
private void Form1_Load(object sender, EventArgs e) { //X double[] x = new double[ValuesX.Count]; for (int i = 0; i < x.Length; i++) { x[i] = ValuesX[i]; } //Y double[] y = new double[ValuesY.Count]; for (int i = 0; i < y.Length; i++) { y[i] = ValuesY[i]; } //anomaly_delete // create pointpairlist PointPairList list = new PointPairList(x, y); // create regression pointpairlist, very simple! PointPairList regressionList = list.LinearRegression(list, list.Count); // add curve LineItem line = z1.GraphPane.AddCurve("Some curve", list, Color.Salmon, SymbolType.Circle); //отрисовка line.Line.IsVisible = false; // add regression curve LineItem lineReg = z1.GraphPane.AddCurve("Linear regression", regressionList, Color.DarkRed, SymbolType.None); z1.IsShowPointValues = true; z1.AxisChange(); z1.Invalidate(); }
// Build the Chart private void CreateGraph(ZedGraphControl zgc) { // get a reference to the GraphPane GraphPane myPane = zgc.GraphPane; // Set the Titles myPane.Title.Text = "Temperature Graph"; myPane.YAxis.Title.Text = "Temperature"; myPane.XAxis.Title.Text = "Time"; myPane.XAxis.Type = AxisType.Date; //myPane.XAxis.Scale.Format // Generate a red curve with diamond // symbols, and "Porsche" in the legend LineItem myCurve = myPane.AddCurve("Ambient", list1, Color.Red, SymbolType.None); // Generate a blue curve with circle // symbols, and "Piper" in the legend LineItem myCurve2 = myPane.AddCurve("Thermocouple", list2, Color.Blue, SymbolType.None); // Tell ZedGraph to refigure the // axes since the data have changed zgc.AxisChange(); }
//Настройки графика void setup_graph(ZedGraph.ZedGraphControl graph) { var pane = graphTheor.GraphPane; pane.YAxis.Title.Text = "y"; pane.X2Axis.Title.Text = "x"; //Настраиваем пересечение осей pane.XAxis.Cross = 0.0; pane.YAxis.Cross = 0.0; pane.XAxis.Scale.IsSkipFirstLabel = true; pane.XAxis.Scale.IsSkipLastLabel = true; pane.XAxis.Scale.IsSkipCrossLabel = true; pane.YAxis.Scale.IsSkipFirstLabel = true; pane.YAxis.Scale.IsSkipLastLabel = true; pane.YAxis.Scale.IsSkipCrossLabel = true; //Убираем засечки сверху и снизу pane.XAxis.MinorTic.IsOpposite = false; pane.XAxis.MajorTic.IsOpposite = false; pane.YAxis.MinorTic.IsOpposite = false; pane.YAxis.MajorTic.IsOpposite = false; graph.AxisChange(); graph.Invalidate(); }
public void ShowLine(double[,] mImageArray, int point_now_y, ZedGraph.ZedGraphControl zg, bool clear, Color in_color) { double[,] line_show = Calculate_Line(mImageArray, point_now_y); line_show[1, line_show.Length] = line_show[1, line_show.Length - 1]; // delete last point line_show[1, 1] = line_show[1, 2]; // delete last point double[] line_x = new double[line_show.GetLength(1)]; double[] line_y = new double[line_show.GetLength(1)]; for (int k = 0; k < line_show.GetLength(1); k++) { line_x[k] = k; line_y[k] = line_show[1, k + 1]; } if (clear == true) { zg.GraphPane.CurveList.Clear(); } zg.GraphPane.AddCurve("", line_x, line_y, in_color, SymbolType.Star); //((LineItem)zg.GraphPane.CurveList[0]).Line.Width = 3.0F; // zg..AddCurve("", time, data, Color.Red, SymbolType.Plus); zg.AxisChange(); zg.IsShowPointValues = true; //zg.GraphPane.Title = "Nano Force Sensor Readout"; zg.GraphPane.XAxis.Title = ""; zg.GraphPane.YAxis.Title = "nm"; zg.Invalidate(); }
private void CreateGraph(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; // Set the titles and axis labels myPane.Title.Text = "My Test Graph"; myPane.XAxis.Title.Text = "X Value"; myPane.YAxis.Title.Text = "My Y Axis"; var list = _GetData(); // Generate a blue curve with circle symbols, and "My Curve 2" in the legend LineItem myCurve = myPane.AddCurve( "My Curve", list, Color.Blue, SymbolType.Circle ); // Fill the area under the curve with a white-red gradient at 45 degrees myCurve.Line.Fill = new Fill( Color.White, Color.Red, 45F ); // Make the symbols opaque by filling them with white myCurve.Symbol.Fill = new Fill( Color.White ); // Fill the axis background with a color gradient myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45F ); // Fill the pane background with a color gradient myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45F ); // Calculate the Axis Scale Ranges zgc.AxisChange(); }
//初始化曲线控件上的曲线数量及名称 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); }
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 ) { GraphPane myPane = zgc.GraphPane; // Set the titles and axis labels myPane.Title.Text = "My Test Graph"; myPane.XAxis.Title.Text = "X Value"; myPane.YAxis.Title.Text = "My Y Axis"; // Make up some data points from the Sine function PointPairList list = new PointPairList(); for ( double x = 0; x < 36; x++ ) { double y = Math.Sin( x * Math.PI / 15.0 ); list.Add( x, y ); } // Generate a blue curve with circle symbols, and "My Curve 2" in the legend LineItem myCurve = myPane.AddCurve( "My Curve", list, Color.Blue, SymbolType.Circle ); // Fill the area under the curve with a white-red gradient at 45 degrees myCurve.Line.Fill = new Fill( Color.White, Color.Red, 45F ); // Make the symbols opaque by filling them with white myCurve.Symbol.Fill = new Fill( Color.White ); // Fill the axis background with a color gradient myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45F ); // Fill the pane background with a color gradient myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45F ); // Calculate the Axis Scale Ranges zgc.AxisChange(); }
public void CreateErrorChart(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; // Set the title and axis labels myPane.Title.Text = "Errors Found In the PCAP"; myPane.XAxis.Title.Text = "Stream ID"; myPane.YAxis.Title.Text = "Error Count"; // create the curves BarItem[] bars = new BarItem[_errorTotals.Length]; for(int i=0;i!=_errorTotals.Length;i++) { bars[i] = myPane.AddBar(i.ToString(), _errorTotals[i], Color.Bisque); } //BarItem myCurve = myPane.AddBar("curve 1", list, Color.Blue); //BarItem myCurve2 = myPane.AddBar("curve 2", list2, Color.Red); //BarItem myCurve3 = myPane.AddBar("curve 3", list3, Color.Green); // Fill the axis background with a color gradient myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F); zgc.AxisChange(); // expand the range of the Y axis slightly to accommodate the labels myPane.YAxis.Scale.Max += myPane.YAxis.Scale.MajorStep; // Create TextObj's to provide labels for each bar BarItem.CreateBarLabels(myPane, false, "f0"); }
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 DrawUniform(double a, double b) { // Получим панель для рисования GraphPane pane = zedGraph.GraphPane; // Очистим список кривых на тот случай, если до этого сигналы уже были нарисованы pane.CurveList.Clear(); // Создадим список точек PointPairList list = new PointPairList(); double xmin = a; double xmax = b; // Заполняем список точек for (double x = xmin; x <= xmax; x += 0.1) { // добавим в список точку list.Add(x, f_un(x, a, b)); } // Создадим кривую с названием "Sinc", // которая будет рисоваться голубым цветом (Color.Blue), // Опорные точки выделяться не будут (SymbolType.None) LineItem myCurve = pane.AddCurve("Sinc", list, Color.Blue, SymbolType.None); // Вызываем метод AxisChange (), чтобы обновить данные об осях. // В противном случае на рисунке будет показана только часть графика, // которая умещается в интервалы по осям, установленные по умолчанию zedGraph.AxisChange(); // Обновляем график zedGraph.Invalidate(); }
internal void Clear(bool undoZoom) { pane.Title.Text = ""; pane.XAxis.Title.Text = ""; pane.Y2Axis.Title.Text = ""; pane.CurveList.Clear(); chart1.AxisChange(); chart1.Refresh(); }
public ZedGraphFigure(ZedGraphControl zg) { this.ClientSize = new Size(500, 400); mZG = zg; mZG.Parent = this; mZG.Location = new Point(BorderSize, BorderSize); mZG.Size = new Size(ClientRectangle.Width - 2*BorderSize, ClientRectangle.Height - 2*BorderSize); mZG.AxisChange(); }
public static Bitmap GetGraph(List<int> data, List<DateTime> date, string xAxis, string yAxis, string graphName) { ZedGraphControl zedGraph = new ZedGraphControl(); if (data.Count == 0) { return null; } if (data.Count == 1) { data.Add(data[0]); date.Add(date[0].AddSeconds(1)); } GraphPane myPane = zedGraph.GraphPane; myPane.CurveList.Clear(); PointPairList list1 = new PointPairList(); DateTime l, r; l = date.First(); r = date.Last(); for (int i = 0; i < data.Count; i++) { list1.Add(date[i].ToOADate(), data[i]); } LineItem myCurve = myPane.AddCurve("Line1", list1, Color.Red, SymbolType.Diamond); myPane.XAxis.Type = AxisType.Date; myPane.YAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.DashOff = 0; myPane.YAxis.MajorGrid.Color = Color.DarkGray; myPane.XAxis.Scale.Min = l.ToOADate(); myPane.XAxis.Scale.Max = r.ToOADate(); myPane.XAxis.Scale.Format = "dd-MMM-yy"; myPane.XAxis.Title.Text = xAxis; myPane.YAxis.Title.Text = yAxis; myPane.Title.Text = graphName; myPane.Legend.IsVisible = false; zedGraph.Enabled = false; myCurve.Line.Width = 4.0F; myCurve.Line.Color = Color.FromArgb(189, 43, 43); myCurve.Line.Fill = new Fill(Color.FromArgb(100, 207, 236, 255), Color.FromArgb(200, 145, 213, 255), 90F); myCurve.Symbol.Size = 12.0F; myCurve.Symbol.Fill = new Fill(Color.FromArgb(145, 16, 16)); myCurve.Symbol.Border.Color = Color.FromArgb(99, 4, 4); zedGraph.AxisChange(); zedGraph.Invalidate(); Bitmap bmp = zedGraph.MasterPane.GetImage(1024, 768, 96); return bmp; }
/// <summary> /// /// </summary> /// <param name="myGraphControl"></param> /// <param name="coor_x"></param> /// <param name="coor_y"></param> /// <param name="title"></param> /// <param name="Xtitle"></param> /// <param name="Ytitle"></param> public void MyDrawPic1(ZedGraph.ZedGraphControl myGraphControl, double[] coor_x, double[] coor_y, string title, string Xtitle, string Ytitle) { GraphPane myPane = myGraphControl.GraphPane; myPane.Legend.IsVisible = false; // myPane.CurveList.Clear(); //myPane.Title.Text = title; //myPane.XAxis.Title.Text = Xtitle; //myPane.YAxis.Title.Text = Ytitle; PointPairList list = new PointPairList(); int N = coor_x.Length; for (int i = 0; i < N; i++) { double x = coor_x[i]; double y = coor_y[i]; list.Add(x, y);//�������� } LineItem myCurve = myPane.AddCurve(title, list, Color.Black, SymbolType.None); myCurve.Symbol.Fill = new Fill(Color.White); myCurve.Line.Width = 2; //myCurve.IsX2Axis = false; //myCurve.IsY2Axis = false; myPane.XAxis.MajorGrid.IsVisible = false; myPane.YAxis.Scale.FontSpec.FontColor = Color.Black; myPane.YAxis.Title.FontSpec.FontColor = Color.Black; myPane.YAxis.MajorTic.IsOpposite = false; myPane.YAxis.MinorTic.IsOpposite = false; myPane.YAxis.MajorGrid.IsZeroLine = false; myPane.YAxis.Scale.Align = AlignP.Inside; myPane.YAxis.Scale.Min = -30; myPane.YAxis.Scale.Max = 30; myPane.Y2Axis.IsVisible = false; myPane.Y2Axis.Scale.FontSpec.FontColor = Color.Black; myPane.Y2Axis.Title.FontSpec.FontColor = Color.Black; myPane.Y2Axis.MajorTic.IsOpposite = false; myPane.Y2Axis.MinorTic.IsOpposite = false; myPane.Y2Axis.MajorGrid.IsVisible = false; myPane.Y2Axis.Scale.Align = AlignP.Inside; myPane.Chart.Fill = new Fill(Color.White, Color.White, 45.0f); myGraphControl.IsShowPointValues = true; myGraphControl.PointValueEvent += new ZedGraph.ZedGraphControl.PointValueHandler(MyPointValueHandler); myGraphControl.ZoomEvent += new ZedGraph.ZedGraphControl.ZoomEventHandler(MyZoomEvent); myGraphControl.AxisChange(); myGraphControl.RestoreScale(myPane); myGraphControl.Invalidate(); }
public void initialDateAxis(ZedGraph.ZedGraphControl zedChart) { try { if (this.m_dtLine1 == null && this.m_dtLine2 == null) { return; } GraphPane myPane = zedChart.GraphPane; // Set the titles and axis labels myPane.Title = this.m_strTitle; //myPane. myPane.XAxis.Title = this.m_xAxisTitle; myPane.YAxis.Title = this.m_yAxisTitle; double[] dDatas = new double[this.m_dtLine1.Rows.Count]; for (int i = 0; i < this.m_dtLine1.Rows.Count; i++) { dDatas[i] = double.Parse(m_dtLine1.Rows[i]["y"].ToString().Trim()); } string[] strLabels = new string[this.m_dtLine1.Rows.Count]; for (int i = 0; i < this.m_dtLine1.Rows.Count; i++) { if (this.isO(i)) { strLabels[i] = m_dtLine1.Rows[i]["x"].ToString().Trim(); } } myPane.CurveList.Clear(); LineItem myCurve = myPane.AddCurve(this.m_strLine1Name, null, dDatas, Color.Black, SymbolType.Circle); myPane.XAxis.Type = AxisType.Text; // Set the XAxis labels myPane.XAxis.TextLabels = strLabels; //myPane.XAxis.ScaleFontSpec.Angle = 40; myPane.XAxis.ScaleFontSpec.Size = 10; myPane.YAxis.ScaleFontSpec.Size = 10; myCurve.Symbol.Size = 4; zedChart.AxisChange(); zedChart.Invalidate(); } catch (Exception ex) { cSaveErr.CSaveErr.msgboxErr(ex.ToString()); } }
public Graph(ZedGraphControl zedGraphControl1, string graphTitle, string xAxisTitle, string yAxisTitle, string name1,string name2,string name3) { this.zedGraphControl1 = zedGraphControl1; myPane = zedGraphControl1.GraphPane; myPane.Title.Text = graphTitle; myPane.XAxis.Title.Text = xAxisTitle; myPane.YAxis.Title.Text = yAxisTitle; // Save 1200 points. At 50 ms sample rate, this is one minute // The RollingPointPairList is an efficient storage class that always // keeps a rolling set of point data without needing to shift any data values //RollingPointPairList list1 = new RollingPointPairList(70000); //RollingPointPairList list2 = new RollingPointPairList(70000); //RollingPointPairList list3 = new RollingPointPairList(70000); // Initially, a curve is added with no data points (list is empty) // Color is blue, and there will be no symbol // LineItem curve1 = myPane.AddCurve(name1, list1, Color.Red, SymbolType.None); // LineItem curve2 = myPane.AddCurve(name2, list2, Color.Blue, SymbolType.None); // LineItem curve3 = myPane.AddCurve(name3, list3, Color.Green, SymbolType.None); // curve1.Line.Width = 1.75F; // curve2.Line.Width = 1.75F; // curve3.Line.Width = 1.75F; // Console.WriteLine(zedGraphControl1.GraphPane.CurveList[0].Label.Text); // Console.WriteLine(curve1.Label.Text); //foreach (String s in hashTable.Keys) //{ // curves.Add(myPane.AddCurve(s,new RollingPointPairList(70000),Color.Red,SymbolType.None)); //} //curve.Line.Fill = new Fill(Color.White, Color.Red, 45F); //curve.Line.Width = 2F; // Just manually control the X axis range so it scrolls continuously // instead of discrete step-sized jumps myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = 50; myPane.XAxis.Scale.MinorStep = 0; myPane.XAxis.Scale.MajorStep = 3; // Scale the axes zedGraphControl1.AxisChange(); // Save the beginning time for reference tickStart = Environment.TickCount; }
public static void SetReflectogramZedgraphStyle(ZedGraphControl zedGraph) { try { GraphPane graphpane = zedGraph.GraphPane; graphpane.Border.Color = SystemColors.Control; graphpane.Fill.Color = SystemColors.Control; graphpane.IsFontsScaled = false; // Set the titles and axis labels graphpane.Title.Text = "Рефлектограмма"; graphpane.XAxis.Title.Text = "Дискрет вермени"; graphpane.YAxis.Title.Text = "U, ед. АЦП"; // Show the x axis grid graphpane.XAxis.MajorGrid.IsVisible = true; graphpane.XAxis.Scale.Max = 4100; // turn off the opposite tics so the Y tics don't show up on the Y2 axis graphpane.YAxis.MajorTic.IsOpposite = false; graphpane.YAxis.MinorTic.IsOpposite = false; // Don't display the Y zero line graphpane.YAxis.MajorGrid.IsZeroLine = false; // Align the Y axis labels so they are flush to the axis graphpane.YAxis.Scale.Align = AlignP.Inside; // Manually set the axis range // Fill the axis background with a gradient graphpane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f); graphpane.IsBoundedRanges = true; // Enable scrollbars if needed zedGraph.IsAutoScrollRange = true; zedGraph.IsScrollY2 = true; // OPTIONAL: Show tooltips when the mouse hovers over a point zedGraph.IsShowPointValues = true; // Tell ZedGraph to calculate the axis ranges // Note that you MUST call this after enabling IsAutoScrollRange, since AxisChange() sets // up the proper scrolling parameters zedGraph.AxisChange(); } catch (Exception ex) { FileWorker.WriteEventFile(DateTime.Now, "ALayout", "SetReflectogramZedgraphStyle", ex.Message); } }
public void CreateChart(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; // Set the titles and axis labels myPane.Title.Text = "My Test Date Graph"; myPane.XAxis.Title.Text = "Date"; myPane.YAxis.Title.Text = "My Y Axis"; // Make up some data points from the Sine function PointPairList list = new PointPairList(); PointPairList list2 = new PointPairList(); for (int i = 0; i < 36; i++) { double x = new XDate(1995, i + 1, 1); double y = Math.Sin((double)i * Math.PI / 15.0); double y2 = 2 * y; list.Add(x, y); list2.Add(x, y2); } // Generate a blue curve with circle symbols, and "My Curve 2" in the legend LineItem myCurve2 = myPane.AddCurve("My Curve 2", list, Color.Blue, SymbolType.Circle); // Fill the area under the curve with a white-red gradient at 45 degrees myCurve2.Line.Fill = new Fill(Color.Red, Color.Pink, 90F); myCurve2.Line.FillFromBottom = true; // Make the symbols opaque by filling them with white myCurve2.Symbol.Fill = new Fill(Color.White); // Generate a red curve with diamond symbols, and "My Curve" in the legend LineItem myCurve = myPane.AddCurve("My Curve", list2, Color.MediumVioletRed, SymbolType.Diamond); // Fill the area under the curve with a white-green gradient //myCurve.Line.Fill = new Fill(Color.White, Color.Green); // Make the symbols opaque by filling them with white myCurve.Symbol.Fill = new Fill(Color.White); // Set the XAxis to date type myPane.XAxis.Type = AxisType.Date; // Fill the axis background with a color gradient myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45F); // Calculate the Axis Scale Ranges zgc.AxisChange(); }
public void Generate(ref ZedGraph.ZedGraphControl graph, String _query, Definition _report, List <Field> _fields) { GraphPane myPane = graph.GraphPane; myPane.Fill = new Fill(Color.FromArgb(210, 210, 210), Color.FromArgb(240, 250, 240)); myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 210), -45F); myPane.Legend.Position = ZedGraph.LegendPos.Right; myPane.Legend.FontSpec.Size = 7; myPane.Title.Text = _report.LABEL.ToString(); myPane.XAxis.Title.Text = ((Field)_fields[0]).ALIAS.ToString(); myPane.YAxis.Title.Text = ((Field)_fields[1]).ALIAS.ToString(); DataTable DT = new DataTable(); DT = SynapseCore.Database.DBFunction.GetTableFromQuery(_query); double[] y = new double[DT.Rows.Count]; string[] x = new string[DT.Rows.Count]; int i = 0; foreach (DataRow dr in DT.Rows) { x[i] = dr[0].ToString(); y[i] = double.Parse(dr[1].ToString()); i++; } BarItem myCurve = myPane.AddBar("Curve 1", null, y, Color.White); myPane.XAxis.Scale.TextLabels = x; myPane.XAxis.Scale.FontSpec.Angle = 90; myPane.XAxis.Scale.FontSpec.Size = 8; myCurve.Bar.Fill = new Fill(Color.White, Color.SteelBlue, 45.0f); // Draw the X tics between the labels instead of at the labels myPane.XAxis.MajorTic.IsBetweenLabels = true; myPane.Legend.IsVisible = false; // Set the XAxis to Text type myPane.XAxis.Type = AxisType.Text; graph.AxisChange(); }
private void Form1_Load(object sender, System.EventArgs e) { z1.IsShowPointValues = true; z1.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]); } z1.GraphPane.AddCurve("Sine Wave", x, y, Color.Red, SymbolType.Square); z1.AxisChange(); z1.Invalidate(); }
private void CreateGraph(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; myPane.Title.Text = "Temperature Graph"; myPane.YAxis.Title.Text = "Temperature"; myPane.XAxis.Title.Text = "Time"; myPane.XAxis.Type = AxisType.Date; LineItem curve1 = myPane.AddCurve("NewK", list1, Color.Red, SymbolType.None); LineItem curve2 = myPane.AddCurve("OldK", list2, Color.Blue, SymbolType.None); LineItem curve3 = myPane.AddCurve("OldT", list3, Color.Green, SymbolType.None); LineItem curve4 = myPane.AddCurve("OldJ", list4, Color.Purple, SymbolType.None); LineItem curve5 = myPane.AddCurve("OldE", list5, Color.Orange, SymbolType.None); zgc.AxisChange(); }
private static void CreateGraph(ZedGraphControl zgc, GraphModel graphModel) { // get a reference to the GraphPane var myPane = zgc.GraphPane; // Set the Titles myPane.Title.Text = graphModel.TitleText; myPane.XAxis.Title.Text = graphModel.XTitleText; myPane.YAxis.Title.Text = graphModel.YTitleText; // Generate a red curve with diamond // symbols, and "Porsche" in the legend myPane.AddCurve(string.Empty, graphModel.Values, Color.Red, SymbolType.Circle); // Tell ZedGraph to refigure the // axes since the data have changed zgc.AxisChange(); }
public void Generate(ref ZedGraph.ZedGraphControl graph, String _query, Definition _report, List <Field> _fields) { GraphPane myPane = graph.GraphPane; myPane.Fill = new Fill(Color.FromArgb(210, 210, 210), Color.FromArgb(240, 250, 240)); myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 210), -45F); myPane.Legend.Position = ZedGraph.LegendPos.Right; myPane.Legend.FontSpec.Size = 12; myPane.Title.Text = _report.LABEL.ToString(); myPane.XAxis.Title.Text = ((Field)_fields[0]).ALIAS.ToString(); DataTable DT = new DataTable(); DT = SynapseCore.Database.DBFunction.GetTableFromQuery(_query); List <PointPairList> allY = new List <PointPairList>(); for (int y = 1; y < DT.Rows[0].ItemArray.Count(); y++) { allY.Add(new PointPairList()); } foreach (DataRow dr in DT.Rows) { for (int y = 1; y < dr.ItemArray.Count(); y++) { ((PointPairList)allY[y - 1]).Add(double.Parse(dr[0].ToString()), double.Parse(dr[y].ToString())); } } Random random = new Random(); foreach (PointPairList ppl in allY) { int r = random.Next(0, 255); int g = random.Next(0, 255); int b = random.Next(0, 255); string curveTitle = ((Field)_fields[allY.IndexOf(ppl) + 1]).ALIAS.ToString(); myPane.AddCurve(curveTitle, ppl, Color.FromArgb(r, g, b), SymbolType.Diamond); } myPane.Legend.IsVisible = true; graph.AxisChange(); }
public void ConfigGraphPane(ZedGraphControl zgc, Form f, PaneLayout pl, List<ChartInfo> chInfo) { MasterPane master = zgc.MasterPane; master.PaneList.Clear(); master.Title.IsVisible = true; foreach (ChartInfo ci in chInfo) { var pane = new GraphPane(); master.PaneList.Add(pane); ConfigGraphPane(pane, ci.Title, ci.XAxisTitle, ci.YAxisTitle); } using (Graphics g = zgc.CreateGraphics()) { master.SetLayout(g, pl); master.AxisChange(g); } zgc.AxisChange(); }
// Build the Chart private void CreateGraphHR(ZedGraphControl zgc) { // get a reference to the GraphPane GraphPane myPane = zgc.GraphPane; // Set the Titles myPane.Title.Text = "Heart Rate"; myPane.XAxis.Title.Text = "seconds"; myPane.YAxis.Title.Text = "bpm"; myPane.Legend.IsVisible = false; PointPairList list1 = new PointPairList(); LineItem myCurve = myPane.AddCurve("HR", list1, Color.Red, SymbolType.Square); zedGraphControlHR.ScrollMinX = 0; zgc.AxisChange(); }
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; }
public void CreateScatterplot(ZedGraphControl zgc, double[,] graph) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the titles myPane.Title.IsVisible = false; myPane.XAxis.Title.Text = _sourceColumns[0]; myPane.YAxis.Title.Text = _sourceColumns[1]; // Classification problem PointPairList list1 = new PointPairList(); // Z = -1 PointPairList list2 = new PointPairList(); // Z = +1 for (int i = 0; i < graph.GetLength(0); i++) { if (graph[i, 2] == 0) list1.Add(graph[i, 0], graph[i, 1]); if (graph[i, 2] == 1) list2.Add(graph[i, 0], graph[i, 1]); } // Add the curve LineItem myCurve = myPane.AddCurve("G1", list1, Color.Blue, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Blue); myCurve = myPane.AddCurve("G2", list2, Color.Green, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Green); // Fill the background of the chart rect and pane //myPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f); //myPane.Fill = new Fill(Color.White, Color.SlateGray, 45.0f); myPane.Fill = new Fill(Color.WhiteSmoke); zgc.AxisChange(); zgc.Invalidate(); }
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 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(); }
public void InitializeGraph(ZedGraph.ZedGraphControl graph) { graph.MouseWheel += BreathGraph_MouseWheel; GraphPane myPane = graph.GraphPane; graph.IsShowPointValues = true; // Mouse over시 data 표시 graph.PointValueFormat = "G"; myPane.Fill.Color = System.Drawing.Color.WhiteSmoke; myPane.Legend.IsVisible = false; // Legend myPane.Border.IsVisible = false; myPane.Title.IsVisible = false; myPane.XAxis.Scale.Format = "0.000"; myPane.XAxis.Scale.MajorStep = 1.000; myPane.YAxis.Scale.Format = "0.0"; myPane.XAxis.Scale.Max = 4.0; // x축 최대치 myPane.XAxis.Scale.Min = -4.0; myPane.YAxis.Scale.Max = 10.0; myPane.YAxis.Scale.Min = -10.0; myPane.XAxis.MajorGrid.IsVisible = true; myPane.XAxis.MajorGrid.Color = System.Drawing.Color.LightGray; myPane.XAxis.MajorGrid.DashOff = 0.0F; myPane.XAxis.MinorGrid.IsVisible = true; myPane.XAxis.MinorGrid.DashOn = 4.0F; myPane.XAxis.MinorGrid.Color = System.Drawing.Color.LightGray; myPane.YAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.Color = System.Drawing.Color.LightGray; myPane.YAxis.MajorGrid.DashOff = 0.0F; myPane.XAxis.Title.IsVisible = false; myPane.YAxis.Title.IsVisible = false; graph.AxisChange(); graph.Invalidate(); myPane.YAxis.Scale.MaxAuto = true; myPane.YAxis.Scale.MinAuto = true; }
/////////////////////////////////////////////////////////////////////////////////////////////// // Build the Chart private void CreateGraph(ZedGraphControl zgc) { // get a reference to the GraphPane GraphPane myPane = zgc.GraphPane; // Set the Titles myPane.Title.Text = microphone.title; myPane.XAxis.Title.Text = ""; myPane.YAxis.Title.Text = ""; myPane.XAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.IsVisible = true; myPane.YAxis.MajorGrid.IsZeroLine = false; myPane.XAxis.Scale.Min = -1; myPane.XAxis.Scale.Max = 1; // По оси Y установим автоматический подбор масштаба myPane.YAxis.Scale.MinAuto = true; myPane.YAxis.Scale.MaxAuto = true; // Создаем список точек RadarPointList points = new RadarPointList(); // Т.к. в списке будет 4 точки, то и окружность будет разбиваться на 4 части // Обход точек будет осуществляться по часовой стрелке points.Clockwise = true; // Первая точка - сверху над началом координат. Расстояние до центра = 1. Второй параметр в большинстве случаев не используется for (int i = 0; i < pointsArray.Length; i++) { points.Add(pointsArray[i], 1); } // Добавляем кривую по этим четырем точкам LineItem myCurve = myPane.AddCurve("", points, Color.Black, SymbolType.None); // Отметим начало координат черным квадратиком BoxObj box = new BoxObj(-0.005, 0.005, 0.01, 0.01, Color.Black, Color.Black); myPane.GraphObjList.Add(box); zgc.AxisChange(); zgc.Invalidate(); }
/// <summary> /// Draws the values. /// </summary> /// <param name="functionVector">The function vector.</param> /// <param name="zedGraphControl">The zed graph control.</param> /// <param name="title">The title.</param> /// <param name="color">The color.</param> private void DrawValues(double[] functionVector, ZedGraphControl zedGraphControl, String title, Color color) { var graphPane = zedGraphControl.GraphPane; graphPane.XAxis.Title.Text = "Count number"; graphPane.YAxis.Title.Text = "Value of the function"; graphPane.Title.Text = title; graphPane.CurveList.Clear(); var pointList = new PointPairList(); for (var i = 0; i < functionVector.Length; i++) { pointList.Add(i, functionVector[i]); } graphPane.AddCurve(String.Empty, pointList, color); zedGraphControl.AxisChange(); zedGraphControl.Invalidate(); }
public void art(ZedGraph.ZedGraphControl zedGraphControl1) { zedGraphControl1.GraphPane.CurveList.Clear(); PointPairList list_x = new PointPairList(); PointPairList list_z = new PointPairList(); node itl = this.head; while (itl != null) { list_x.Add(itl.data.x, 0); list_z.Add(itl.data.x, itl.data.z); itl = itl.next; } LineItem Curve1 = zedGraphControl1.GraphPane.AddCurve("x", list_x, Color.Green, SymbolType.Plus); LineItem Curve2 = zedGraphControl1.GraphPane.AddCurve("z", list_z, Color.Blue, SymbolType.Star); zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); }
private void draw(int[] x, int[] y, int[] z, ZedGraphControl zgcHist, string filename) { GraphPane pane = zgcHist.GraphPane; pane.CurveList.Clear(); PointPairList list = new PointPairList(); PointPairList list2 = new PointPairList(); for (long j = 0; j < x.Length; j++) { list.Add(x[j], y[j]); list2.Add(x[j], z[j]); } pane.AddBar("Histogram", list, Color.Black); pane.AddCurve("The mean", list2, Color.Coral, SymbolType.None); pane.YAxis.Scale.Min = 0; pane.YAxis.Scale.Max = 1.1*y.Max(); pane.XAxis.Scale.Min = -100; pane.XAxis.Scale.Max = 100; zgcHist.AxisChange(); zgcHist.Invalidate(); }
private void CreateGraph(ZedGraphControl zgc) { // get a reference to the GraphPane GraphPane myPane = zgc.GraphPane; // Set the Titles myPane.Title.Text = "My Position"; myPane.XAxis.Title.Text = "Asset"; myPane.YAxis.Title.Text = "$"; // Make up some data arrays based on the Sine function double x, y1, y2; PointPairList list1 = new PointPairList(); PointPairList list2 = new PointPairList(); for (int i = 0; i < 36; i++) { x = (double)i + 5; y1 = 1.5 + Math.Sin((double)i * 0.2); y2 = 3.0 * (1.5 + Math.Sin((double)i * 0.2)); list1.Add(x, y1); list2.Add(x, y2); } // Generate a red curve with diamond // symbols, and "Porsche" in the legend LineItem myCurve = myPane.AddCurve("Porsche", list1, Color.Red, SymbolType.Diamond); myCurve.Line.Width = 2.0F; // Generate a blue curve with circle // symbols, and "Piper" in the legend LineItem myCurve2 = myPane.AddCurve("Piper", list2, Color.Blue, SymbolType.Circle); myCurve2.Line.Width = 2.0F; // Tell ZedGraph to refigure the axes since the data have changed zgc.AxisChange(); }
private void CreateGraph(ZedGraph.ZedGraphControl zgc) { // get a reference to the GraphPane GraphPane myPane = zgc.GraphPane; // Set the Titles myPane.Title.Text = "My Test Graph\n(For CodeProject Sample)"; myPane.XAxis.Title.Text = "My X Axis"; myPane.YAxis.Title.Text = "My Y Axis"; myPane.XAxis.Scale.MajorStep = 5; // Make up some data arrays based on the Sine function double x, y1, y2; PointPairList list1 = new PointPairList(); PointPairList list2 = new PointPairList(); for (int i = 0; i < 36; i++) { x = (double)i + 5; y1 = 1.5 + Math.Sin((double)i * 0.2); y2 = 3.0 * (1.5 + Math.Sin((double)i * 0.2)); list1.Add(x, y1); list2.Add(x, y2); } // Generate a red curve with diamond // symbols, and "Porsche" in the legend LineItem myCurve = myPane.AddCurve("Porsche", list1, System.Drawing.Color.Red, SymbolType.Diamond); // Generate a blue curve with circle // symbols, and "Piper" in the legend LineItem myCurve2 = myPane.AddCurve("Piper", list2, System.Drawing.Color.Blue, SymbolType.Circle); // Tell ZedGraph to refigure the // axes since the data have changed zgc.AxisChange(); }
//кнопка "Построить гистограмму" private void button5_Click(object sender, EventArgs e) { if (filename == "") { MessageBox.Show("Вы не выбрали изображение!"); } else { tabControl2.SelectTab(tabPage5); Image image = new Bitmap(filename); // Получим панель для рисования GraphPane pane = zedGraph.GraphPane; // Очистим список кривых на тот случай, если до этого сигналы уже были нарисованы pane.CurveList.Clear(); // Создадим список точек /*PointPairList list = analysis.imgHistogram(image, 0); * LineItem myCurve = pane.AddCurve("Изображение", list, Color.Red, SymbolType.None);*/ PointPairList list_R = analysis.imgHistogram(image, 0); PointPairList list_G = analysis.imgHistogram(image, 1); PointPairList list_B = analysis.imgHistogram(image, 2); LineItem myCurve_R = pane.AddCurve("R", list_R, Color.Red, SymbolType.None); LineItem myCurve_G = pane.AddCurve("G", list_G, Color.Green, SymbolType.None); LineItem myCurve_B = pane.AddCurve("B", list_B, Color.Blue, SymbolType.None); pane.XAxis.Title.Text = "Тональный диапазон"; pane.YAxis.Title.Text = "Частота пикселей"; pane.Title.Text = "Гистограмма изображения"; // Вызываем метод AxisChange (), чтобы обновить данные об осях. // В противном случае на рисунке будет показана только часть графика, // которая умещается в интервалы по осям, установленные по умолчанию zedGraph.AxisChange(); // Обновляем график zedGraph.Invalidate(); } }
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); }
public static void CreateChartForDouble(ZedGraphControl zgc ,double[] data, string titleName ,string lblName, Color color,SymbolType symType ) { GraphPane mypan = zgc.GraphPane ; mypan .Title.Text = titleName ; mypan .XAxis .Title .IsVisible = false ; mypan .YAxis .Title .IsVisible = false ; PointPairList list = new PointPairList(); for (int i = 0; i < data.Length ; i++) { double x =(double ) i; double y1 = data[i]; list.Add(x, y1); } mypan .Y2Axis .IsVisible = true ; mypan .XAxis .MajorGrid .IsVisible = true ; mypan .YAxis .MajorGrid .IsVisible = true ; mypan .XAxis .MinorGrid .IsVisible = true ; mypan .YAxis .MinorGrid .IsVisible = true ; LineItem myItem = mypan.AddCurve(lblName ,list ,color,symType); zgc.AxisChange(); }
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); }
// Build the Chart private void CreateGraph(ZedGraphControl zgc) { // get a reference to the GraphPane GraphPane myPane = zgc.GraphPane; // Set the Titles myPane.Title.Text = "Wykres prezentujący wzrost kapitału"; myPane.XAxis.Title.Text = "oś lat"; myPane.YAxis.Title.Text = "oś kapitału w złotych"; // Make up some data arrays based on the Sine function double x, y1; PointPairList list1 = new PointPairList(); for (int i = 0; i <= 20; i++) { x = i ; y1 = ZmienneGlobalne.wplata * ((Math.Pow(1 + ZmienneGlobalne.procent, x * ZmienneGlobalne.kapitalizacje) - 1) / ZmienneGlobalne.procent) * (1 + ZmienneGlobalne.procent); list1.Add(x, y1); x = i + 1 ; } // Generate a red curve with diamond // symbols, and "Porsche" in the legend LineItem myCurve = myPane.AddCurve("Twój kapitał po n lat", list1, Color.Red, SymbolType.Diamond); // Tell ZedGraph to refigure the // axes since the data have changed zgc.AxisChange(); }
private void DrawGraph() { GraphPane pane = zedGraph.GraphPane; pane.CurveList.Clear(); // Количество столбцов int itemscount = 9; // Сгенерируем данные для оси X (длин столбцов) double[] barLength = GenerateData(itemscount); double[] barPosition = new double[itemscount]; // Заполним данные по оси Y (положения столбцов) for (int i = 0; i < itemscount; i++) { barPosition[i] = i + 1; } // !!! Создадим гистограмму. // Обратите внимание на порядок следования массивов: // сначала идут данные по оси X (длины столцов), потом по оси Y (положения столбцов) // Для вертикальных гистограмм значения по осям X и Y имеют противоположные значения. pane.AddBar("", barLength, barPosition, Color.Blue); // Этот параметр указывает, что базовой осью для гистограммы будет ось Y, // то есть положения столбцов соответствуют значениям по оси Y. pane.BarSettings.Base = BarBase.Y; // Обновим данные об осях zedGraph.AxisChange(); // Обновляем график zedGraph.Invalidate(); }
private void Draw(int[] x, int[] y, int[] z, ZedGraphControl zgcHist, string filename) { GraphPane pane = zgcHist.GraphPane; pane.CurveList.Clear(); PointPairList list = new PointPairList(); PointPairList list2 = new PointPairList(); for (long j = 0; j < x.Length; j++) { list.Add(x[j], y[j]); list2.Add(x[j], z[j]); } pane.AddBar("Гистограмма", list, Color.IndianRed); pane.AddCurve("Ожидаемый результат", list2, Color.Crimson, SymbolType.None); pane.YAxis.Scale.Min = 0; pane.YAxis.Scale.Max = 1.1*y.Max(); pane.XAxis.Scale.Min = -100; pane.XAxis.Scale.Max = 100; pane.Title.Text = filename; zgcHist.AxisChange(); zgcHist.Invalidate(); }
/// <summary> /// build the chart /// </summary> /// <param name="zgc"></param> public void CreateGraph(ZedGraphControl zgc) { //--get a reference to the graphPane--// this.myPane = zgc.GraphPane; //--set the titles--// this.myPane.Title.Text = "Measured LRF Data"; this.myPane.XAxis.Title.Text = "Lateral distance (m)"; this.myPane.YAxis.Title.Text = "Height (m)"; //--manually set the x axis range--// this.myPane.XAxis.Scale.Min = -4.0; this.myPane.XAxis.Scale.Max = 4.0; this.myPane.XAxis.MajorGrid.IsVisible = true; //--manually set the y axis range--// this.myPane.YAxis.Scale.Min = -0.2; this.myPane.YAxis.Scale.Max = 1.0; this.myPane.YAxis.MajorGrid.IsVisible = true; this.myPane.YAxis.MajorGrid.IsZeroLine = false; //--scale the axes--// zgc.AxisChange(); }
public void CreateChart(ZedGraphControl zgc) { Console.WriteLine("sim CreateChart"); GraphPane myPane = zgc.GraphPane; zgc.IsAntiAlias = false; // Set the titles and axis labels myPane.Title.Text = "Servo Output"; myPane.XAxis.Title.Text = "Time"; myPane.YAxis.Title.Text = "Output"; LineItem myCurve; myCurve = myPane.AddCurve("Roll", list, Color.Red, SymbolType.None); myCurve = myPane.AddCurve("Pitch", list2, Color.Blue, SymbolType.None); myCurve = myPane.AddCurve("Rudder", list3, Color.Green, SymbolType.None); myCurve = myPane.AddCurve("Throttle", list4, Color.Orange, SymbolType.None); // Show the x axis grid myPane.XAxis.MajorGrid.IsVisible = true; myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = 5; // 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 = true; // Align the Y axis labels so they are flush to the axis myPane.YAxis.Scale.Align = AlignP.Inside; // Manually set the axis range //myPane.YAxis.Scale.Min = -1; //myPane.YAxis.Scale.Max = 1; // Fill the axis background with a gradient //myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f); // Sample at 50ms intervals timer_servo_graph.Interval = 200; //timer_servo_graph.Enabled = true; //timer_servo_graph.Start(); // Calculate the Axis Scale Ranges zgc.AxisChange(); tickStart = Environment.TickCount; }
public void CreateChart(ZedGraphControl zgc,string Title, string XAxis, string YAxis) { GraphPane myPane = zgc.GraphPane; // Set the titles and axis labels myPane.Title.Text = Title; myPane.XAxis.Title.Text = XAxis; myPane.YAxis.Title.Text = YAxis; LineItem myCurve; myCurve = myPane.AddCurve("Accel X", list1, Color.Red, SymbolType.None); myCurve = myPane.AddCurve("Accel Y", list2, Color.Green, SymbolType.None); myCurve = myPane.AddCurve("Accel Z", list3, Color.SandyBrown, SymbolType.None); myCurve = myPane.AddCurve("Gyro X", list4, Color.Blue, SymbolType.None); myCurve = myPane.AddCurve("Gyro Y", list5, Color.Black, SymbolType.None); myCurve = myPane.AddCurve("Gyro Z", list6, Color.Violet, SymbolType.None); // Show the x axis grid myPane.XAxis.MajorGrid.IsVisible = true; myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = 5; // 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 = true; // Align the Y axis labels so they are flush to the axis myPane.YAxis.Scale.Align = AlignP.Inside; // Manually set the axis range //myPane.YAxis.Scale.Min = -1; //myPane.YAxis.Scale.Max = 1; // Fill the axis background with a gradient myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f); // Sample at 20ms intervals timer1.Interval = 100; timer1.Enabled = true; timer1.Start(); // Calculate the Axis Scale Ranges zgc.AxisChange(); tickStart = Environment.TickCount; }
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(); }
//获取 弯曲试验 结果的 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); } }
public override void DrawGraph() { string graphTitle; //饼组成部分标签 string[] labels = null; //饼组成部分的值 double[] values = null; //合计 double total = 0; if (base.XAxisScaleRefrence == DataTableStruct.Rows) { labels = new string[base.DataSource.Rows.Count]; values = new double[base.DataSource.Rows.Count]; for (int i = 0; i < base.DataSource.Rows.Count; i++) { labels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString(); if (Convert.IsDBNull(base.DataSource.Rows[i][base.ShowValueColumns[index].ColumnField])) { values[i] = 0; } else { values[i] = Convert.ToDouble(base.DataSource.Rows[i][base.ShowValueColumns[index].ColumnField]); total += values[i]; } } graphTitle = base.ShowValueColumns[index].ColumnName; } else { labels = new string[base.ShowValueColumns.Length]; values = new double[base.ShowValueColumns.Length]; for (int i = 0; i < base.ShowValueColumns.Length; i++) { labels[i] = base.ShowValueColumns[i].ColumnName; if (Convert.IsDBNull(base.DataSource.Rows[index][base.ShowValueColumns[i].ColumnField])) { values[i] = 0; } else { values[i] = Convert.ToDouble(base.DataSource.Rows[index][base.ShowValueColumns[i].ColumnField]); } total += values[i]; } graphTitle = base.DataSource.Rows[index][base.CNNameColumn].ToString(); } #region 显示图形 base.GraphContainer.Controls.Clear(); ZedGraph.ZedGraphControl grphTx = new ZedGraph.ZedGraphControl(); grphTx.IsEnableHZoom = false; grphTx.IsEnableVZoom = false; grphTx.IsEnableWheelZoom = false; grphTx.Dock = System.Windows.Forms.DockStyle.Fill; ZedGraph.GraphPane myPane = grphTx.GraphPane; myPane.Title.Text = graphTitle; //字体 //myPane.Title.FontSpec.IsItalic = true; //myPane.Title.FontSpec.Size = 24f; //myPane.Title.FontSpec.Family = "Verdana"; myPane.Fill = new Fill(Color.White, Color.Goldenrod, 45.0f); myPane.Chart.Fill.IsVisible = false; myPane.Legend.Position = LegendPos.Float; myPane.Legend.Location = new Location(0.95f, 0.15f, CoordType.PaneFraction, AlignH.Right, AlignV.Top); myPane.Legend.FontSpec.Size = 10f; myPane.Legend.IsHStack = false; //画饼状部分 for (int i = 0; i < labels.Length; i++) { Color color; if (base.Colors == null) { color = GetColor(); } else { color = base.Colors[i]; } PieItem segment = myPane.AddPieSlice(values[i], color, color, 45f, 0, labels[i]); } CurveList curves = myPane.CurveList; TextObj text = new TextObj("合计:\n" + total.ToString(), 0.18F, 0.40F, CoordType.PaneFraction); text.Location.AlignH = AlignH.Center; text.Location.AlignV = AlignV.Bottom; text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill = new Fill(Color.White, Color.FromArgb(255, 100, 100), 45F); text.FontSpec.StringAlignment = StringAlignment.Center; myPane.GraphObjList.Add(text); // Create a drop shadow for the total value text item TextObj text2 = new TextObj(text); text2.FontSpec.Fill = new Fill(Color.Black); text2.Location.X += 0.008f; text2.Location.Y += 0.01f; myPane.GraphObjList.Add(text2); grphTx.AxisChange(); base.GraphContainer.Controls.Add(grphTx); #endregion }
/// <summary> /// 图形描绘 /// </summary> public override void DrawGraph() { #region 图形所需数据 //线条数组[线条数] [每条线的刻度值] double[][] lines; //X轴刻度 double[] xAixsScale; //线条标注 string[] labels; //X轴刻度标注 string[] xAxisScaleLabels; if (base.XAxisScaleRefrence == DataTableStruct.Rows) { xAixsScale = new double[base.DataSource.Rows.Count]; xAxisScaleLabels = new string[base.DataSource.Rows.Count]; for (int i = 0; i < base.DataSource.Rows.Count; i++) { xAixsScale[i] = i; xAxisScaleLabels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString(); } //要绘制的线条数为数据列数 lines = new double[base.ShowValueColumns.Length][]; //线条标注 labels = new string[lines.Length]; for (int i = 0; i < base.ShowValueColumns.Length; i++) { labels[i] = base.ShowValueColumns[i].ColumnName; } //填充每条线的数据值 for (int i = 0; i < lines.Length; i++) { lines[i] = new double[xAixsScale.Length]; for (int j = 0; j < base.DataSource.Rows.Count; j++) { if (Convert.IsDBNull(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField])) { lines[i][j] = 0; } else { lines[i][j] = Convert.ToDouble(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField]); } } } } else { xAixsScale = new double[base.ShowValueColumns.Length]; xAxisScaleLabels = new string[base.ShowValueColumns.Length]; for (int i = 0; i < base.ShowValueColumns.Length; i++) { xAixsScale[i] = i; xAxisScaleLabels[i] = base.ShowValueColumns[i].ColumnName; } //要绘制的线条数为数据集的纪录数 lines = new double[base.DataSource.Rows.Count][]; //线条标注 labels = new string[lines.Length]; for (int i = 0; i < base.DataSource.Rows.Count; i++) { labels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString(); } //填充每条线的数据值 for (int i = 0; i < lines.Length; i++) { lines[i] = new double[xAixsScale.Length]; for (int j = 0; j < base.ShowValueColumns.Length; j++) { if (Convert.IsDBNull(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField])) { lines[i][j] = 0; } else { lines[i][j] = Convert.ToDouble(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField]); } } } } int maxXaisxScale = xAixsScale.Length; //Console.Beep(); #endregion #region 显示图形 base.GraphContainer.Controls.Clear(); ZedGraph.ZedGraphControl grphTx = new ZedGraph.ZedGraphControl(); grphTx.IsEnableHZoom = false; grphTx.IsEnableVZoom = false; grphTx.IsEnableWheelZoom = false; grphTx.Dock = System.Windows.Forms.DockStyle.Fill; ZedGraph.GraphPane myPane = grphTx.GraphPane; myPane.Title.Text = base.GraphTitle; myPane.XAxis.Title.Text = base.XAxisTitle; myPane.YAxis.Title.Text = base.YAxisTitle; myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F); //线条显示 for (int i = 0; i < lines.Length; i++) { Color color; if (base.Colors == null) { color = GetColor(); } else { color = base.Colors[i]; } ZedGraph.LineItem myCurve = myPane.AddCurve(labels[i], xAixsScale, lines[i], color); myCurve.Symbol.Fill = new Fill(Color.White); } //X轴属性 myPane.XAxis.Scale.Min = 0; //X轴刻度起始值 myPane.XAxis.Scale.Max = maxXaisxScale; //X轴刻度最大值 myPane.XAxis.Scale.TextLabels = xAxisScaleLabels; //x轴刻度中文标注 myPane.XAxis.Type = AxisType.Text; //类型 myPane.XAxis.Scale.FontSpec.Angle = 90; //文字方向 myPane.XAxis.Scale.FontSpec.Size = 11F; //文字大小 // Display the Y axis grid lines myPane.YAxis.MajorGrid.IsVisible = true; myPane.YAxis.MinorGrid.IsVisible = true; BoxObj box = new BoxObj(0, 100, 1, 30, Color.Empty, Color.FromArgb(150, Color.LightGreen)); box.Fill = new Fill(Color.White, Color.FromArgb(200, Color.LightGreen), 45.0F); box.ZOrder = ZOrder.E_BehindCurves; box.IsClippedToChartRect = true; box.Location.CoordinateFrame = CoordType.XChartFractionYScale; myPane.GraphObjList.Add(box); TextObj text = new TextObj("", 0.95f, 85, CoordType.AxisXYScale, AlignH.Right, AlignV.Center); text.FontSpec.Fill.IsVisible = false; text.FontSpec.Border.IsVisible = false; text.FontSpec.IsBold = true; text.FontSpec.IsItalic = true; text.Location.CoordinateFrame = CoordType.XChartFractionYScale; text.IsClippedToChartRect = true; myPane.GraphObjList.Add(text); myPane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F); grphTx.AxisChange(); base.GraphContainer.Controls.Add(grphTx); #endregion }