public void Init() { // Clear ZedGraph zedGraphControl.GraphPane.CurveList.Clear(); zedGraphControl.GraphPane.GraphObjList.Clear();; zedGraphControl.Invalidate(); // Init ZedGraph GraphPane myPane = zedGraphControl.GraphPane; myPane.Title.Text = "Check 03 Voltage of System (Volt)"; myPane.XAxis.Title.Text = "Time (s)"; myPane.YAxis.Title.Text = "Voltage (Volt)"; RollingPointPairList list = new RollingPointPairList(60000); RollingPointPairList list1 = new RollingPointPairList(600000); RollingPointPairList list2 = new RollingPointPairList(600000); LineItem curve = myPane.AddCurve("Volt 1", list, Color.Red, SymbolType.None); LineItem curve1 = myPane.AddCurve("Volt 2", list1, Color.Blue, SymbolType.None); LineItem curve2 = myPane.AddCurve("Volt 3", list2, Color.Green, SymbolType.None); myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = 30; myPane.XAxis.Scale.MinorStep = 1; myPane.XAxis.Scale.MajorStep = 5; myPane.YAxis.Scale.Min = 0; myPane.YAxis.Scale.Max = 15; myPane.AxisChange(); // Save the beginning time for reference TickStart = Environment.TickCount; }
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(); }
//Настройки графика 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(); }
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(); }
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(); }
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(); }
public static void UpdateGraph(this ZedGraphControl zgc) { // Tell ZedGraph to calculate the axis ranges // Note that you MUST call this after enabling IsAutoScrollRange, since AxisChange() sets // up the proper scrolling parameters zgc.AxisChange(); // Make sure the Graph gets redrawn zgc.Invalidate(); }
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; }
private void ClearGauge(int idx) { if (lblGuage1.InvokeRequired) { ClearDataCallback d = new ClearDataCallback(ClearGauge); this.Invoke(d, new object[] { idx }); } else { ZedGraph.ZedGraphControl currZG = null; System.Windows.Forms.Label currLabel = null; System.Windows.Forms.AGauge currGauge = null; if (idx == 1) { currZG = zg1; currLabel = lblGuage1; currGauge = gauge1; } if (idx == 2) { currZG = zg2; currLabel = lblGuage2; currGauge = gauge2; } if (idx == 3) { currZG = zg3; currLabel = lblGuage3; currGauge = gauge3; } if (currZG != null) { GraphPane myPane = currZG.GraphPane; myPane.Title.Text = "No data."; myPane.CurveList.Clear();// clear the graph currZG.Invalidate(); currZG.Refresh(); } if (currLabel != null) { currLabel.Text = "No data"; } if (currGauge != null) { currGauge.Value = 0; } } }
//метод очищает полотно для рисования public void Clear(ZedGraphControl control) { // Получим панель для рисования GraphPane pane = control.GraphPane; // Очистим список кривых pane.CurveList.Clear(); // Обновляем график control.Invalidate(); }
/// <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(); }
private void asignarGrafica(ZedGraphControl z, int i) { CurveList g = new CurveList(); g = h.getGrafica(i); if (g != null) { z.GraphPane.CurveList = g; z.Invalidate(); z.Refresh(); } }
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()); } }
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(); }
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(); }
internal void OnMouseUp(ZedGraphControl sender, MouseEventArgs e) { m_HighLight?.Close(); m_HighLight = null; var range = m_Max - m_Min; if (e.Location == m_Start || Vertical ? (e.Location.X <= m_Min || e.Location.X >= m_Max) : (e.Location.Y <= m_Min || e.Location.Y >= m_Max) || range == 0) { return; } var ratio = (float)((Vertical ? e.Location.X : e.Location.Y) - m_Min) / range; sender.MasterPane.SetProportion(this, ratio); sender.Invalidate(); sender.Refresh(); }
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(); }
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(); }
/// <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(); }
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 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 TCPProcessor_WholeFrameReceivedEvent() { if (MarkerList.listOfMarkers.Count != 0) { if (sampleCount == 0) { timeStart = MarkerList.listOfMarkers[footMarker].TimeStamp; sampleCount++; } time = (MarkerList.listOfMarkers[footMarker].TimeStamp - timeStart) / 1000.0; //Time is measured in seconds if (!continuePlotting) { endPlotting(); } else { zData.Add(time, MarkerList.listOfMarkers[footMarker].zCoordinate); yData.Add(time, MarkerList.listOfMarkers[footMarker].yCoordinate); xData.Add(time, MarkerList.listOfMarkers[footMarker].xCoordinate); // Keep the X scale at a rolling 30 second interval, with one // major step between the max X value and the end of the axis Scale xScale = zedGraphControl1.GraphPane.XAxis.Scale; if (time > xScale.Max - xScale.MajorStep) { xScale.Max = time + xScale.MajorStep; xScale.Min = xScale.Max - 6.0; } // Make sure the Y axis is rescaled to accommodate actual data zedGraphControl1.AxisChange(); // Force a redraw zedGraphControl1.Invalidate(); } } }
public ZedGraphProxy(ZedGraphControl chart) { Chart = chart; master = chart.MasterPane; master.Fill = new Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0f); master.PaneList.Clear(); master.Title.IsVisible = true; //master.Title.Text = ""; master.Margin.All = 10; master.InnerPaneGap = 0; myPane = new GraphPane(new Rectangle(25, 25, chart.Width - 50, chart.Height - 50), "", "", ""); // myPane.Title.Text = ""; myPane.XAxis.Title.Text = "Time, s"; myPane.Y2Axis.IsVisible = true; myPane.Fill.IsVisible = false; myPane.Chart.Fill = new Fill(Color.White, Color.LightYellow, 45.0F); myPane.Margin.All = 0; myPane.Margin.Top = 20; master.Add(myPane); y1List = new PointPairList(); y2List = new PointPairList(); var myCurve = myPane.AddCurve("", y1List, Color.Red, SymbolType.Circle); myCurve.IsVisible = false; myCurve = myPane.AddCurve("", y2List, Color.Green, SymbolType.Circle); myCurve.IsVisible = false; myCurve.IsY2Axis = true; chart.IsSynchronizeYAxes = true; chart.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(); }
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(); }
// Multiple stacked lines test private void CreateGraph_StackLine( ZedGraphControl z1 ) { GraphPane myPane = z1.GraphPane; PointPairList list = new PointPairList(); PointPairList list2 = new PointPairList(); PointPairList list3 = new PointPairList(); PointPairList list4 = new PointPairList(); for ( int i = 0; i < 36; i += 5 ) { double x = (double) i + 5; double y = 3.0 * ( 1.5 + Math.Sin( (double) i * 0.2 ) ) - 3.0; if ( i == 15 ) { list.Add( x, y ); //list2.Add( x, PointPair.Missing ); list2.Add( x, 1.0 ); list3.Add( x, 2 + Math.Sin( i * 0.2 + Math.PI ) ); list4.Add( x, 7.0 ); } else { list.Add( x, y ); list2.Add( x, 1.0 ); list3.Add( x, 2 + Math.Sin( i * 0.2 + Math.PI ) ); list4.Add( x, 7.0 ); } } LineItem myCurve = myPane.AddCurve( "line 1", list, Color.Black, SymbolType.Diamond ); LineItem myCurve2 = myPane.AddCurve( "line 2", list2, Color.Black, SymbolType.Square ); //LineItem myCurve3 = myPane.AddCurve( "line 3", list3, Color.Black, SymbolType.Circle ); myPane.LineType = LineType.Stack; myPane.YAxis.Color = Color.Red; myPane.XAxis.Scale.Align = AlignP.Inside; myPane.XAxis.Color = Color.Blue; myPane.YAxis.Scale.IsReverse = true; z1.AxisChange(); myPane.YAxis.Scale.MaxAuto = false; //int l = ColorSymbolRotator.COLORS.Length; //LineObj line = new LineObj(); //line.IsClippedToChartRect = true; LineItem myCurve4 = myPane.AddCurve( " line 4", list4, Color.Black, SymbolType.Triangle ); myCurve4.Label.Text = myCurve4.Label.Text.Trim(); //myCurve2.IsY2Axis = true; myCurve.Line.Fill = new Fill( Color.White, Color.Maroon, 45.0f ); myCurve2.Line.Fill = new Fill( Color.White, Color.Blue, 45.0f ); //myCurve3.Line.Fill = new Fill( Color.White, Color.Green, 45.0f ); myCurve4.Line.Fill = new Fill( Color.White, Color.Red, 45.0f ); myCurve.Symbol.Fill = new Fill( Color.White ); myCurve2.Symbol.Fill = new Fill( Color.White ); myCurve.Line.SmoothTension = 0.5f; myCurve2.Line.SmoothTension = 0.5f; myCurve.Line.IsSmooth = true; myCurve2.Line.IsSmooth = true; //myCurve3.Symbol.Fill = new Fill( Color.White ); //myCurve4.Symbol.Fill = new Fill( Color.White ); //EllipseObj ellipse = new EllipseObj( 20, 8, 10, 3, Color.Black, Color.White, Color.Blue ); //myPane.GraphObjList.Add( ellipse ); myPane.Legend.IsHStack = false; myPane.Legend.Position = LegendPos.Left; // Tell ZedGraph to calculate the axis ranges z1.AxisChange(); z1.Invalidate(); }
private void CreateGraph_StackedBars( ZedGraphControl z1 ) { GraphPane myPane = z1.GraphPane; PointPairList list = new PointPairList(); PointPairList list2 = new PointPairList(); PointPairList list3 = new PointPairList(); Random rand = new Random(); for ( int i = 0; i < 5; i++ ) { double x = (double) i / 3 + 4; double y = rand.NextDouble() * 1000; double y2 = rand.NextDouble() * 1000; double y3 = rand.NextDouble() * 1000; list.Add( x, y ); list2.Add( x, y2 ); list3.Add( x, y3 ); } 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 ); myCurve.Link.IsEnabled = true; myCurve.Link.Target = "_blank"; myCurve.Link.Title = "Curve 1"; myCurve.Link.Url = "http://zedgraph.org/wiki/"; myCurve2.Link.IsEnabled = true; myCurve2.Link.Target = "_blank"; myCurve2.Link.Title = "Curve 2"; myCurve2.Link.Url = "http://zedgraph.org/wiki/"; myCurve3.Link.IsEnabled = true; myCurve3.Link.Target = "_blank"; myCurve3.Link.Title = "Curve 3"; myCurve3.Link.Url = "http://zedgraph.org/wiki/"; myPane.BarSettings.Type = BarType.Stack; myPane.BarSettings.Base = BarBase.X; myPane.XAxis.MajorTic.IsBetweenLabels = true; string[] labels = { "one", "two", "three", "four", "five", "six" }; myPane.XAxis.Scale.TextLabels = labels; myPane.XAxis.Type = AxisType.Text; // Tell ZedGraph to calculate the axis ranges z1.AxisChange(); z1.Invalidate(); z1.LinkEvent += new ZedGraphControl.LinkEventHandler( z1_LinkEvent ); //z1.DoubleClickEvent += new ZedGraphControl.ZedMouseEventHandler( z1_DoubleClickEvent ); }
public void ShowDistributionChart(DataTable RawDataTable, ZedGraph.ZedGraphControl ZedChart0) { ZedChart0.GraphPane.CurveList.Clear(); ZedChart0.GraphPane.GraphItemList.Clear(); int nn = RawDataTable.Rows.Count; double[] dataY = new double[nn]; // double[] dataX=new double[nn]; double maxY = System.Convert.ToDouble(RawDataTable.Rows[0][0]); double minY = maxY; double sumY = 0; double sumY2 = 0; for (int i = 0; i < nn; i++) { dataY[i] = System.Convert.ToDouble(RawDataTable.Rows[i][0]); if (dataY[i] > maxY) { maxY = dataY[i]; } else if (dataY[i] < minY) { minY = dataY[i]; } sumY += dataY[i]; sumY2 += (dataY[i] * dataY[i]); } double meanY = sumY / nn; double VarY = (sumY2 - nn * meanY * meanY) / (nn - 1); double StdY = Math.Sqrt(VarY); double [] dataYn = new double[7] { 0, 0, 0, 0, 0, 0, 0 }; double[] dataX0 = new double[7] { 30, 30.5, 31, 31.5, 32, 32.2, 32.4 }; for (int i = 0; i < 7; i++) { dataX0[i] = minY + i * (maxY - minY) / 7 + (maxY - minY) / 14; } for (int i = 0; i < nn; i++) { if (dataY[i] == maxY) { dataYn[6]++; } else { dataYn[(int)(7 * (dataY[i] - minY) / (maxY - minY))]++; } } ZedChart0.GraphPane.AddBar("Data Distribution", dataX0, dataYn, Color.Blue); // Axis aa=ZedChart0.GraphPane.BarBaseAxis(); // ZedChart0.GraphPane.MinBarGap = (float)0.02; ZedChart0.GraphPane.ClusterScaleWidth = (float)(maxY - minY) / (7); PointPairList datanorm = new PointPairList(); // double[] datanorm = new double[100]; for (int i = 0; i < 100; i++) { double xi = 0; double yi = 0; xi = meanY - 4 * StdY + (8 * StdY) * i / 100; yi = Math.Exp(-(xi - meanY) * (xi - meanY) / VarY / 2) / Math.Sqrt(2 * Math.PI) / StdY; datanorm.Add(xi, yi * nn); } // ZedChart0.GraphPane.XAxis.Min = meanY - 6 * StdY; // ZedChart0.GraphPane.XAxis.Max=meanY + 6 * StdY; ZedChart0.GraphPane.AddCurve("norm", datanorm, Color.Green, SymbolType.None); // for (double x = meanY - 6 * StdY; x <= meanY + 6 * StdY; x += (12 * StdY) / 100) // { // } // ZedChart0.GraphPane.MinClusterGap = (float)0.002; // ZedChart0.GraphPane.AddBar ZedChart0.AxisChange(); ZedChart0.Invalidate(); }
public void CreateCurveGraph(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the titles and axis labels myPane.Title.Text = "Receiver Operating Characteristic Curve"; myPane.Title.FontSpec.Size = 24f; myPane.Title.FontSpec.Family = "Tahoma"; myPane.XAxis.Title.Text = "(1-Specificity)"; myPane.YAxis.Title.Text = "Sensitivity"; PointPairList list = new PointPairList(); if (rocCurve != null) { for (int i = 0; i < rocCurve.Points.Count; i++) { list.Add(1 - rocCurve.Points[i].Specificity, rocCurve.Points[i].Sensitivity); } } // Hide the legend myPane.Legend.IsVisible = false; // Add a curve LineItem curve = myPane.AddCurve("label", list, Color.Red, SymbolType.Circle); curve.Line.Width = 2.0F; curve.Line.IsAntiAlias = true; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.Size = 7; myPane.XAxis.Scale.Max = 1.0; myPane.XAxis.Scale.Min = 0.0; myPane.YAxis.Scale.Max = 1.0; myPane.YAxis.Scale.Min = 0.0; // Calculate the Axis Scale Ranges zgc.AxisChange(); zgc.Invalidate(); }
public void CreateResultScatterplot(ZedGraphControl zgc, double[][] inputs, double[] expected, double[] output) { 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, OK PointPairList list2 = new PointPairList(); // Z = +1, OK PointPairList list3 = new PointPairList(); // Z = -1, Error PointPairList list4 = new PointPairList(); // Z = +1, Error for (int i = 0; i < output.Length; i++) { if (output[i] == -1) { if (expected[i] == -1) list1.Add(inputs[i][0], inputs[i][1]); if (expected[i] == 1) list3.Add(inputs[i][0], inputs[i][1]); } else { if (expected[i] == -1) list4.Add(inputs[i][0], inputs[i][1]); if (expected[i] == 1) list2.Add(inputs[i][0], inputs[i][1]); } } // Add the curve LineItem myCurve = myPane.AddCurve("G1 Hits", 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 Hits", list2, Color.Green, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Green); myCurve = myPane.AddCurve("G1 Miss", list3, Color.Blue, SymbolType.Plus); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = true; myCurve.Symbol.Fill = new Fill(Color.Blue); myCurve = myPane.AddCurve("G2 Miss", list4, Color.Green, SymbolType.Plus); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = true; myCurve.Symbol.Fill = new Fill(Color.Green); // Fill the background of the chart rect and pane myPane.Fill = new Fill(Color.WhiteSmoke); zgc.AxisChange(); zgc.Invalidate(); }
public void CreateScatterplot(ZedGraphControl zgc, double[,] graph) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the titles myPane.Title.IsVisible = false; myPane.XAxis.Title.Text = columnNames[0]; myPane.YAxis.Title.Text = columnNames[1]; // Regression problem PointPairList list1 = new PointPairList(); for (int i = 0; i < graph.GetLength(0); i++) list1.Add(graph[i, 0], graph[i, 1]); // Add the curve LineItem myCurve = myPane.AddCurve("Y", list1, Color.Blue, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Blue); // Fill the background of the chart rect and pane myPane.Fill = new Fill(Color.WhiteSmoke); zgc.AxisChange(); zgc.Invalidate(); }
public static void DrawPeaks(IEnumerable<MergedNarrowPeak> peaks, int maxPeaksPerBar, int minPos, int maxPos, int width = 800, int height = 600) { Console.Write("Draw graph..."); // какие-то настройки Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); // подготовка формы и компонента var form = new Form {Width = width, Height = height}; var f = new ZedGraphControl { Anchor = AnchorStyles.Top, AutoSizeMode = AutoSizeMode.GrowAndShrink, Dock = DockStyle.Fill, Name = "qwe" }; f.GraphPane = new GraphPane(RectangleF.Empty, "Сгруппированные пики активности DNaseI в chr1", "p", "q"); // преобразуем данные int maxValue; var data = PrepareData(peaks, maxPeaksPerBar, ref minPos, ref maxPos, out maxValue); // подготовим оси // Y var yaxis = f.GraphPane.YAxis; yaxis.Type = AxisType.Log; yaxis.Scale.MaxAuto = false; yaxis.Scale.MinAuto = false; yaxis.Scale.Max = maxValue; yaxis.Scale.Min = 1; yaxis.Title = new AxisLabel("peakValue", null, 16, Color.Black, false, false, false); // X var xaxis = f.GraphPane.XAxis; xaxis.Scale.MaxAuto = false; xaxis.Scale.MinAuto = false; xaxis.Scale.Max = maxPos; xaxis.Scale.Min = minPos; xaxis.Type = AxisType.LinearAsOrdinal; xaxis.Title = new AxisLabel("chr1 position", null, 16, Color.Black, true, false, false); // Установим формат столбцов f.GraphPane.BarSettings.Type = BarType.SortedOverlay; var cs = new Color[data.Length]; for (int i = 0; i < data.Length; i++) cs[i] = Color.FromArgb((int) Math.Round(255.0*(i + 0.5)/data.Length), 0, 0, 0); // Добавим столбцы for (int i = 0; i < data.Length; i++) { var bar = f.GraphPane.AddBar("Совпад.№" + i, data[i], cs[i]); bar.Bar.Fill.Type = FillType.Solid; bar.Bar.Border.IsVisible = false; bar.Bar.Border.Width = 1500; } // Финальный штрих form.Controls.Add(f); f.AxisChange(); f.Invalidate(); Console.WriteLine("ok"); Application.Run(form); }
public void CreateGraph_junk5( ZedGraphControl zgc ) { GraphPane myPane = zgc.GraphPane; // Set the title and axis labels myPane.Title.Text = "Japanese Candlestick Chart Demo"; myPane.XAxis.Title.Text = "Trading Date"; myPane.YAxis.Title.Text = "Share Price, $US"; StockPointList spl = new StockPointList(); Random rand = new Random(); // First day is jan 1st XDate xDate = new XDate( 2006, 1, 1 ); double open = 50.0; for ( int i = 0; i < 1000; i++ ) { double x = xDate.XLDate; double close = open + rand.NextDouble() * 10.0 - 5.0; double hi = Math.Max( open, close ) + rand.NextDouble() * 5.0; double low = Math.Min( open, close ) - rand.NextDouble() * 5.0; StockPt pt = new StockPt( x, hi, low, open, close, 100000 ); spl.Add( pt ); open = close; if ( xDate.DateTime.Hour < 23 ) xDate.AddHours( 1.0 ); else { // Advance one day xDate.AddHours( 1.0 ); // but skip the weekends if ( XDate.XLDateToDayOfWeek( xDate.XLDate ) == 6 ) xDate.AddDays( 2.0 ); } } JapaneseCandleStickItem myCurve = myPane.AddJapaneseCandleStick( "trades", spl ); myCurve.Stick.IsAutoSize = true; myCurve.Stick.Color = Color.Blue; // Use DateAsOrdinal to skip weekend gaps myPane.XAxis.Type = AxisType.DateAsOrdinal; myPane.XAxis.Scale.Min = new XDate( 2006, 1, 1 ); myPane.XAxis.Scale.Format = "dd-MMM-yy hh:mm"; // pretty it up a little myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45.0f ); myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45.0f ); PointPairList ppl = new PointPairList(); for ( int i = 19; i < spl.Count; i++ ) { double avg = 0.0; for ( int j = 0; j < 20; j++ ) avg += spl.GetAt( i - j ).Close; ppl.Add( i + 1, avg / 20.0 ); } LineItem item = myPane.AddCurve( "MA-20", ppl, Color.Red ); item.IsOverrideOrdinal = true; item.Line.Width = 3; item.Symbol.Type = SymbolType.None; item.Line.IsSmooth = true; // Tell ZedGraph to calculate the axis ranges zgc.AxisChange(); zgc.Invalidate(); }
public void ShowXbarRChart(DataTable RawDataTable, int subgroupsize, ZedGraph.ZedGraphControl ZedxbarChart, ZedGraph.ZedGraphControl ZedRchart) { ZedRchart.GraphPane.CurveList.Clear(); ZedRchart.GraphPane.GraphItemList.Clear(); ZedxbarChart.GraphPane.CurveList.Clear(); ZedxbarChart.GraphPane.GraphItemList.Clear(); int nn = RawDataTable.Rows.Count; double[] dataY = new double[nn]; //double[] dataX=new double[nn]; for (int i = 0; i < nn; i++) { dataY[i] = (double)System.Convert.ToDouble(RawDataTable.Rows[i][0]); } // double[] showdataY = {1,2,4,3,2,3,4,4,1,23,12,12,12,12,1,56,323}; // double[] showdataX = { 0,1, 2, 3, 4, 5, 6, 7, 8 }; // this.pictureBox1.Image = createChartImage1(pictureBox1.Width, pictureBox1.Height,showdataY,0,4000); // this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource(RawDataTable.TableName, RawDataTable)); // this.reportViewer1.RefreshReport(); // subgroupsize = 5; ArrayList R = new ArrayList(); ArrayList mean = new ArrayList(); computeRangeMean(dataY, subgroupsize, R, mean); double[] RR = (double[])R.ToArray(Type.GetType("System.Double")); double[] mm = (double[])mean.ToArray(Type.GetType("System.Double")); double Ave_R = 0; double Ave_mean = 0; double UCL = 0; double LCL = 0; double UCLR = 0; double LCLR = 0; //defAxisBorderPenWidth=0.1; computeLimit(RR, mm, subgroupsize, ref Ave_R, ref Ave_mean, ref UCL, ref LCL, ref UCLR, ref LCLR); string printparameter_ss = string.Format("subgroupsize:{0}\nAve_R:{1}\nAve_mean:{2}\nUCL:{3}\nLCL:{4}\nUCLR:{5}\nLCLR:{6}", subgroupsize, Ave_R, Ave_mean, UCL, LCL, UCLR, LCLR); // printparameter_ss this.label1.Text = printparameter_ss; // zedGraphControl1.=0.1; // zedGraphControl1.GraphPane.AddCurve("line", showdataX, showdataY, Color.Red, SymbolType.None); // zedGraphControl1.GraphPane.AddCurve(); nn = R.Count; double[] showdataX = new double[nn]; for (int i = 0; i < nn; i++) { showdataX[i] = i; } ZedRchart.GraphPane.AddCurve("Data", null, (double[])R.ToArray(Type.GetType("System.Double")), Color.Blue, SymbolType.Circle); PointPairList lineAveR = new PointPairList(); lineAveR.Add(0, Ave_R); lineAveR.Add(nn, Ave_R); ZedRchart.GraphPane.AddCurve("Ave_R", lineAveR, Color.Green, SymbolType.None); PointPairList lineUCLR = new PointPairList(); lineUCLR.Add(0, UCLR); lineUCLR.Add(nn, UCLR); // zedGraphControl1.GraphPane.ScaledPenWidth(3, 1); ZedRchart.GraphPane.AddCurve("UCLR", lineUCLR, Color.Red, SymbolType.None); PointPairList lineLCLR = new PointPairList(); lineLCLR.Add(0, LCLR); lineLCLR.Add(nn, LCLR); ZedRchart.GraphPane.AddCurve("LCLR", lineLCLR, Color.Red, SymbolType.None); ZedRchart.GraphPane.Title = "R chart"; // zedGraphControl1.GraphPane. ZedRchart.GraphPane.YAxis.IsZeroLine = false; // zedGraphControl1.GraphPane.AxisBorder.IsVisible = false; // zedGraphControl1.GraphPane.PaneBorder.IsVisible = false; double minR = (double)R[0]; double maxR = (double)R[0]; foreach (double Ri in R) { if (Ri < minR) { minR = Ri; } else if (Ri > maxR) { maxR = Ri; } } double Ymin = minR < LCLR ? minR : LCLR - (maxR - minR) * 0.2; if (minR >= 0 && LCLR >= 0 && Ymin < 0) { ZedRchart.GraphPane.YAxis.Min = Ymin; } //ZedRchart.GraphPane.YAxis.Min = minR< LCLR?minR:LCLR - (maxR - minR) * 0.2; ZedRchart.AxisChange(); // double Ymin = ZedRchart.GraphPane.YAxis.Min; // double Ymax = ZedRchart.GraphPane.YAxis.Max; // zedGraphControl1.GraphPane.AddCurve("LCLR", lineLCLR, Color.Red, SymbolType.None); // zedGraphControl1.Refresh(); ZedRchart.Invalidate(); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// nn = mean.Count; // double[] showdataX = new double[nn]; for (int i = 0; i < nn; i++) { showdataX[i] = i; } ZedxbarChart.GraphPane.AddCurve("Data", null, (double[])mean.ToArray(Type.GetType("System.Double")), Color.Blue, SymbolType.Circle); PointPairList linemean = new PointPairList(); linemean.Add(0, Ave_mean); linemean.Add(nn, Ave_mean); ZedxbarChart.GraphPane.AddCurve("X_bar", linemean, Color.Green, SymbolType.None); PointPairList lineUCL = new PointPairList(); lineUCL.Add(0, UCL); lineUCL.Add(nn, UCL); // zedGraphControl1.GraphPane.ScaledPenWidth(3, 1); ZedxbarChart.GraphPane.AddCurve("UCL", lineUCL, Color.Red, SymbolType.None); PointPairList lineLCL = new PointPairList(); lineLCL.Add(0, LCL); lineLCL.Add(nn, LCL); ZedxbarChart.GraphPane.AddCurve("LCL", lineLCL, Color.Red, SymbolType.None); ZedxbarChart.GraphPane.Title = "X_Bar chart"; // zedGraphControl1.GraphPane. ZedxbarChart.GraphPane.YAxis.IsZeroLine = false; // zedGraphControl1.GraphPane.AxisBorder.IsVisible = false; // zedGraphControl1.GraphPane.PaneBorder.IsVisible = false; // double minM= (double)mean[0]; // double maxM = (double)mean[0]; // foreach (double meani in mean) // { // if (meani < minM) minM = meani; // else if (meani > maxM) maxM = meani; // } // Ymin= ZedxbarChart.GraphPane.YAxis.IsZeroLine = false; ZedxbarChart.AxisChange(); // ZedRchart.GraphPane.YAxis.MinAuto = false; // ZedxbarChart.GraphPane.YAxis.Min = minM < LCL ? minM : LCL - (maxM - minM) * 0.2 ; // ZedxbarChart.AxisChange(); // // double Ymin = ZedRchart.GraphPane.YAxis.Min; // double Ymax = ZedRchart.GraphPane.YAxis.Max; // zedGraphControl1.GraphPane.AddCurve("LCLR", lineLCLR, Color.Red, SymbolType.None); // zedGraphControl1.Refresh(); ZedxbarChart.Invalidate(); }
/// <summary> /// /// </summary> /// <param name="myGraphControl"></param> /// <param name="X1"></param> /// <param name="Y1"></param> /// <param name="X2"></param> /// <param name="Y2"></param> /// <param name="title"></param> /// <param name="Xtitle"></param> /// <param name="Ytitle"></param> public void MyDrawPic2(ZedGraph.ZedGraphControl myGraphControl, double[] X1, double[] Y1, double[] X2, double[] Y2, 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 listr1 = new PointPairList(); PointPairList listr2 = new PointPairList(); PointPairList listr3 = new PointPairList(); for (int i = 0; i < X1.Length; i++) { listr1.Add(Convert.ToDouble(X1[i].ToString("f6")), Convert.ToDouble(Y1[i].ToString("f6"))); } for (int i = 0; i < X2.Length; i++) { listr2.Add(Convert.ToDouble(X2[i].ToString("f6")), Convert.ToDouble(Y2[i].ToString("f6"))); } //add rack curve LineItem myCurveR1 = myPane.AddCurve("title", listr1, Color.Blue, SymbolType.None); LineItem myCurveR2 = myPane.AddCurve("title", listr2, Color.Blue, SymbolType.None); LineItem myCurveR3 = myPane.AddCurve("title", listr3, Color.Blue, SymbolType.None); myCurveR1.Line.Width = 2; myCurveR2.Line.Width = 2; myCurveR3.Line.Width = 2; myCurveR1.Symbol.Fill = new Fill(Color.White); myCurveR2.Symbol.Fill = new Fill(Color.White); myCurveR3.Symbol.Fill = new Fill(Color.White); myCurveR1.IsY2Axis = true; myCurveR2.IsY2Axis = true; myCurveR3.IsY2Axis = true; myPane.XAxis.MajorGrid.IsVisible = true; 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 = true; 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 = true; 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(); Application.DoEvents(); Thread.Sleep(10);//��ͣ0.05�� }
public void CreateComponentCumulativeDistributionGraph(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the titles and axis labels myPane.Title.Text = "Component Distribution"; myPane.Title.FontSpec.Size = 24f; myPane.Title.FontSpec.Family = "Tahoma"; myPane.XAxis.Title.Text = "Components"; myPane.YAxis.Title.Text = "Percentage"; PointPairList list = new PointPairList(); for (int i = 0; i < lda.Discriminants.Count; i++) { list.Add(lda.Discriminants[i].Index, lda.Discriminants[i].CumulativeProportion); } // Hide the legend myPane.Legend.IsVisible = false; // Add a curve LineItem curve = myPane.AddCurve("label", list, Color.Red, SymbolType.Circle); curve.Line.Width = 2.0F; curve.Line.IsAntiAlias = true; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.Size = 7; myPane.XAxis.Scale.MinAuto = true; myPane.XAxis.Scale.MaxAuto = true; myPane.YAxis.Scale.MinAuto = true; myPane.YAxis.Scale.MaxAuto = true; myPane.XAxis.Scale.MagAuto = true; myPane.YAxis.Scale.MagAuto = true; // Calculate the Axis Scale Ranges zgc.AxisChange(); zgc.Invalidate(); }
private void CreateGraph_VerticalLinearBars( ZedGraphControl z1 ) { GraphPane myPane = z1.GraphPane; PointPairList list = new PointPairList(); PointPairList list2 = new PointPairList(); PointPairList list3 = new PointPairList(); Random rand = new Random(); for ( int i = 0; i < 9; i++ ) { double x = (double) i / 3 + 4; double x2 = x + .2; double x3 = x + .4; double y = rand.NextDouble() * .1; double y2 = rand.NextDouble() * .1; double y3 = rand.NextDouble() * .1; list.Add( x, y ); list2.Add( x2, y2 ); list3.Add( x3, y3 ); } 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 ); //myCurve.IsOverrideOrdinal = true; //myPane.XAxis.MajorTic.IsBetweenLabels = true; //string[] labels = { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; //myPane.XAxis.Scale.TextLabels = labels; //myPane.XAxis.Type = AxisType.Text; z1.AxisChange(); //BarItem.CreateBarLabels( myPane, false, "f2" ); // Tell ZedGraph to calculate the axis ranges z1.AxisChange(); z1.Invalidate(); }
private Boolean removeGraphByName( ZedGraphControl z1, string sOpName ) { try { GraphPane gpane = z1.GraphPane; for ( int j = 0; j < gpane.CurveList.Count; j++ ) { string sCurCurveName = gpane.CurveList[j].Label.Text; if ( sCurCurveName == sOpName ) { gpane.CurveList.RemoveAt( j ); } } for ( int k = 0; k < gpane.Y2AxisList.Count; k++ ) { if ( gpane.Y2AxisList[k].Title.Text == sOpName ) gpane.Y2AxisList.RemoveAt( k ); } z1.AxisChange(); z1.Invalidate(); return false; } catch ( Exception ex ) { MessageBox.Show( ex.Message ); return false; } }
public void CreateScatterplot(ZedGraphControl zgc, double[][] graph, int n) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set graph pane object myPane.Title.Text = "Normal (Gaussian) Distributions"; myPane.XAxis.Title.Text = "X"; myPane.YAxis.Title.Text = "Y"; myPane.XAxis.Scale.Max = 10; myPane.XAxis.Scale.Min = -10; myPane.YAxis.Scale.Max = 10; myPane.YAxis.Scale.Min = -10; myPane.XAxis.IsAxisSegmentVisible = false; myPane.YAxis.IsAxisSegmentVisible = false; myPane.YAxis.IsVisible = false; myPane.XAxis.IsVisible = false; myPane.Border.IsVisible = false; // Create mixture pairs PointPairList list = new PointPairList(); for (int i = 0; i < graph.Length; i++) list.Add(graph[i][0], graph[i][1]); // Add the curve for the mixture points LineItem myCurve = myPane.AddCurve("Mixture", list, Color.Gray, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Gray); for (int i = 0; i < n; i++) { // Add curves for the clusters to be detected Color color = colors[i]; myCurve = myPane.AddCurve("D" + (i + 1), new PointPairList(), color, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(color); } // Fill the background of the chart rect and pane myPane.Fill = new Fill(Color.WhiteSmoke); zgc.AxisChange(); zgc.Invalidate(); }
private async void populateControls(ZedGraphControl zgc) { /////////////Show the gridView control with verious columns//////////////////// Double totalInvestment = 0.0; Double totalReturn = 0.0; this.mainFormLoadingCircle.Visible = true; dt = await Task.Run(() =>bLogic.getUserPurchaseTable(loggedUser.userName)); if (dt.Rows.Count > 0) { dt.Columns.Add("Total Return", typeof(System.Double)); dt.Columns.Add("Current Bid", typeof(System.Double)); dt.Columns.Add("Current Ask", typeof(System.Double)); List<Quote> quotes = new List<Quote>(); foreach (DataRow dr in dt.Rows) { quotes.Add(new Quote(dr["Symbol"].ToString())); } await Task.Run(() =>YahooStockEngine.Fetch(quotes)); int i = 0; double currPrice = 0.0; foreach (DataRow dr in dt.Rows) { if (quotes!= null && quotes[i] != null && quotes[i].Bid != null) { currPrice = (double)quotes[i].Bid; currPrice *= System.Convert.ToDouble(dr["Total Stocks"].ToString()); dr["Current Bid"] = (double)quotes[i].Bid; } else { currPrice = System.Convert.ToDouble(dr["Total Investment"]); dr["Current Bid"] = 0.0; } if (quotes != null && quotes[i] != null && quotes[i].Ask != null) { dr["Current Ask"] = (double)quotes[i].Ask; } else { currPrice = System.Convert.ToDouble(dr["Total Investment"]); dr["Current Ask"] = 0.0; } totalReturn += currPrice; totalInvestment += System.Convert.ToDouble(dr["Total Investment"]); dr["Total Return"] = currPrice; //.ToString (String.Format("#.##")); i++; } this.cashTextBox.Text = loggedUser.balance.ToString(String.Format("c")); this.returnTextBox.Text = totalReturn.ToString(String.Format("c")); this.investTextBox.Text = totalInvestment.ToString(String.Format("c")); double profitLoss = (totalReturn - totalInvestment); this.profitTextBox.Text = profitLoss.ToString(); this.stockDataGridView.DataSource = dt; this.stockDataGridView.Columns["Total Return"].DefaultCellStyle.Format = "c"; this.stockDataGridView.Columns["Current Bid"].DefaultCellStyle.Format = "c"; this.stockDataGridView.Columns["Current Ask"].DefaultCellStyle.Format = "c"; this.stockDataGridView.Columns["Total Investment"].DefaultCellStyle.Format = "c"; this.stockDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; } // end of if (dt.Rows.Count > 0) else { this.cashTextBox.Text = loggedUser.balance.ToString(String.Format("c")); this.returnTextBox.Text = totalReturn.ToString(String.Format("c")); this.investTextBox.Text = totalInvestment.ToString(String.Format("c")); double profitLoss = (totalReturn - totalInvestment); this.profitTextBox.Text = profitLoss.ToString(); this.stockDataGridView.DataSource = null; } /////////////Show the graph control with current selected row from the gridView//////////////////// populateGraphControl(); /////////////Show the Pie Chart control with all the stocks//////////////////// zgc.GraphPane.CurveList.Clear(); zgc.GraphPane.GraphObjList.Clear(); GraphPane myPane = zgc.GraphPane; // Set the Titles myPane.Title.Text = "Total assets distribution for " +loggedUser.firstName +" "+loggedUser.lastName; double[] totReturn = new double[dt.Rows.Count]; String[] companies = new String[dt.Rows.Count]; int j = 0; foreach (DataRow dr in dt.Rows) { totReturn[j] = System.Convert.ToDouble(dr["Total Return"].ToString()); companies[j] = dr["Name"].ToString(); j++; } myPane.AddPieSlices(totReturn, companies); // Fill the axis background with a gradient myPane.Chart.Fill = new Fill(Color.LightGreen, Color.DeepSkyBlue, 45.0f); myPane.Fill = new Fill(Color.LightGreen); //myPane.Legend.Position = LegendPos.Bottom; myPane.Legend.IsVisible = false; foreach (var x in myPane.CurveList.OfType<PieItem>()) { x.LabelType = PieLabelType.Name_Percent; x.Displacement = x.Value % 0.07; } zgc.IsShowPointValues = true; zgc.AxisChange(); zgc.Invalidate(); this.mainFormLoadingCircle.Visible = false; return; }
private void RefresheZedGraphs(ZedGraph.ZedGraphControl zg) { zg.AxisChange(); zg.Invalidate(); //zg.Refresh(); }
public void CreateScatterplot(ZedGraphControl zgc, double[] x, double[] y, double[] slr, double[] rlr, double[] inliersX, double[] inliersY) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the titles myPane.Title.IsVisible = false; myPane.Chart.Border.IsVisible = false; myPane.XAxis.Title.Text = "X"; myPane.YAxis.Title.Text = "Y"; myPane.XAxis.IsAxisSegmentVisible = true; myPane.YAxis.IsAxisSegmentVisible = true; myPane.XAxis.MinorGrid.IsVisible = false; myPane.YAxis.MinorGrid.IsVisible = false; myPane.XAxis.MinorTic.IsOpposite = false; myPane.XAxis.MajorTic.IsOpposite = false; myPane.YAxis.MinorTic.IsOpposite = false; myPane.YAxis.MajorTic.IsOpposite = false; myPane.XAxis.Scale.MinGrace = 0; myPane.XAxis.Scale.MaxGrace = 0; myPane.YAxis.Scale.MinGrace = 0; myPane.YAxis.Scale.MaxGrace = 0; PointPairList list1 = new PointPairList(x, y); PointPairList list2 = null; PointPairList list3 = null; PointPairList list4 = new PointPairList(inliersX, inliersY); if (slr != null) list2 = new PointPairList(x, slr); if (rlr != null) list3 = new PointPairList(x, rlr); if (inliersX != null) list4 = new PointPairList(inliersX, inliersY); LineItem myCurve; // Add the curves myCurve = myPane.AddCurve("Inliers", list4, Color.Blue, SymbolType.Circle); myCurve.Line.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Blue); myCurve = myPane.AddCurve("Points", list1, Color.Gray, SymbolType.Circle); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Gray); myCurve = myPane.AddCurve("Simple", list2, Color.Red, SymbolType.Circle); myCurve.Line.IsAntiAlias = true; myCurve.Line.IsVisible = true; myCurve.Symbol.IsVisible = false; myCurve = myPane.AddCurve("RANSAC", list3, Color.Blue, SymbolType.Circle); myCurve.Line.IsAntiAlias = true; myCurve.Line.IsVisible = true; myCurve.Symbol.IsVisible = false; zgc.AxisChange(); zgc.Invalidate(); }
private void DrawCurve(string Station, string Curve, int Sign) { try { ds = new DataSet(); list = new PointPairList(); myPane.CurveList.Clear(); if (Curve != "") { myPane.Title = m_Begin.ToShortDateString() + "日 至" + m_End.ToShortDateString() + "日 " + Station + " " + Curve + " 趋势曲线图"; bolCurve = true; } else { myPane.Title = "趋势曲线图"; } myPane.XAxis.Title = "时间"; myPane.YAxis.Title = ""; myPane.XAxis.Type = AxisType.Date; myPane.XAxis.ScaleFontSpec.Size = 8; myPane.YAxis.ScaleFontSpec.Size = 8; string Yaxis; if (Sign == 1) { for (int i = 0; i < lvCurve.Items.Count + 3; i++) { if (curveInfo[i].m_Chart == Curve) { chartInfo = curveInfo[i].m_Sqlname; Yaxis = curveInfo[i].m_Y; UStr = Yaxis; DBcon con = new DBcon(); string str = "select " + chartInfo + ",time from V_heatDatas where Name='" + Station + "' and time between '" + m_Begin + "' and '" + m_End + "' order by time"; SqlCommand cmd = new SqlCommand(str, con.GetConnection()); SqlDataAdapter adp = new SqlDataAdapter(str, con.GetConnection()); adp.Fill(ds); adp.Dispose(); SqlDataReader dr = cmd.ExecuteReader(); if (!dr.Read()) { return; } while (dr.Read()) { string time = dr.GetValue(1).ToString(); int yearlast = time.IndexOf("-", 0); int monthlast = time.IndexOf("-", yearlast + 1); int daylast = time.IndexOf(" ", monthlast + 1); int hourlast = time.IndexOf(":", daylast + 1); int minituelast = time.IndexOf(":", hourlast + 1); string year = time.Substring(0, 4); string month = time.Substring(yearlast + 1, monthlast - yearlast - 1); string day = time.Substring(monthlast + 1, daylast - monthlast - 1); string hour = time.Substring(daylast + 1, hourlast - daylast - 1); string minitue = time.Substring(hourlast + 1, minituelast - hourlast - 1); string second = time.Substring(minituelast + 1); double x = new XDate(Convert.ToInt32(year), Convert.ToInt32(month), Convert.ToInt32(day), Convert.ToInt32(hour), Convert.ToInt32(minitue), Convert.ToInt32(second)); double y = System.Convert.ToDouble(dr.GetValue(0)); list.Add(x, y); } dr.Close(); myPane.YAxis.Title = Yaxis; break; } } LineItem myCurve = myPane.AddCurve(Curve, list, Color.Blue, SymbolType.Circle); myCurve.Symbol.Fill = new Fill(Color.White); myCurve.Symbol.Size = 3; myPane.XAxis.Title = "时间(小时)"; myPane.AxisFill = new Fill(Color.White, Color.LightGray, 45F); zgCurve.IsShowPointValues = true; zgCurve.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler); zgCurve.AxisChange(); zgCurve.Invalidate(); } else if (Sign == 2) { for (int i = 0; i < lvCurve.Items.Count; i++) { if (typeInfo[i].m_TName == Curve) { string cID = typeInfo[i].m_TNum; string m_curve = ""; int z = 0; for (int j = 0; j < curveInfo.Length; j++) { if (System.Convert.ToInt32(cID) < 3) { if (curveInfo[j].m_Type == cID || curveInfo[j].m_Type == "5") { list = new PointPairList(); chartInfo = curveInfo[j].m_Sqlname; m_curve = m_curve + chartInfo + ","; Yaxis = curveInfo[j].m_Y; UStr = Yaxis; DBcon con = new DBcon(); string str = "select " + chartInfo + ",time from V_heatDatas where Name='" + Station + "' and time between '" + m_Begin + "' and '" + m_End + "' order by time"; SqlCommand cmd = new SqlCommand(str, con.GetConnection()); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { string time = dr.GetValue(1).ToString(); int yearlast = time.IndexOf("-", 0); int monthlast = time.IndexOf("-", yearlast + 1); int daylast = time.IndexOf(" ", monthlast + 1); int hourlast = time.IndexOf(":", daylast + 1); int minituelast = time.IndexOf(":", hourlast + 1); string year = time.Substring(0, 4); string month = time.Substring(yearlast + 1, monthlast - yearlast - 1); string day = time.Substring(monthlast + 1, daylast - monthlast - 1); string hour = time.Substring(daylast + 1, hourlast - daylast - 1); string minitue = time.Substring(hourlast + 1, minituelast - hourlast - 1); string second = time.Substring(minituelast + 1); double x = new XDate(Convert.ToInt32(year), Convert.ToInt32(month), Convert.ToInt32(day), Convert.ToInt32(hour), Convert.ToInt32(minitue), Convert.ToInt32(second)); double y = System.Convert.ToDouble(dr.GetValue(0)); list.Add(x, y); } // break; LineItem myCurve = myPane.AddCurve(curveInfo[j].m_Chart, list, m_Color[z], SymbolType.Circle); myCurve.Symbol.Fill = new Fill(Color.White); myCurve.Symbol.Size = 3; myPane.XAxis.Title = "时间(小时)"; myPane.YAxis.Title = Yaxis; myPane.AxisFill = new Fill(Color.White, Color.LightGray, 45F); zgCurve.IsShowPointValues = true; zgCurve.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler); zgCurve.AxisChange(); zgCurve.Invalidate(); z = ++z; } } else { if (curveInfo[j].m_Type == cID) { list = new PointPairList(); chartInfo = curveInfo[j].m_Sqlname; m_curve = m_curve + chartInfo + ","; Yaxis = curveInfo[j].m_Y; UStr = Yaxis; DBcon con = new DBcon(); string str = "select " + chartInfo + ",time from V_heatDatas where Name='" + Station + "' and time between '" + m_Begin + "' and '" + m_End + "' order by time"; SqlCommand cmd = new SqlCommand(str, con.GetConnection()); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { string time = dr.GetValue(1).ToString(); int yearlast = time.IndexOf("-", 0); int monthlast = time.IndexOf("-", yearlast + 1); int daylast = time.IndexOf(" ", monthlast + 1); int hourlast = time.IndexOf(":", daylast + 1); int minituelast = time.IndexOf(":", hourlast + 1); string year = time.Substring(0, 4); string month = time.Substring(yearlast + 1, monthlast - yearlast - 1); string day = time.Substring(monthlast + 1, daylast - monthlast - 1); string hour = time.Substring(daylast + 1, hourlast - daylast - 1); string minitue = time.Substring(hourlast + 1, minituelast - hourlast - 1); string second = time.Substring(minituelast + 1); double x = new XDate(Convert.ToInt32(year), Convert.ToInt32(month), Convert.ToInt32(day), Convert.ToInt32(hour), Convert.ToInt32(minitue), Convert.ToInt32(second)); double y = System.Convert.ToDouble(dr.GetValue(0)); list.Add(x, y); } // break; LineItem myCurve = myPane.AddCurve(curveInfo[j].m_Chart, list, m_Color[z], SymbolType.Circle); myCurve.Symbol.Fill = new Fill(Color.White); myCurve.Symbol.Size = 3; myPane.XAxis.Title = "时间(小时)"; myPane.YAxis.Title = Yaxis; myPane.AxisFill = new Fill(Color.White, Color.LightGray, 45F); zgCurve.IsShowPointValues = true; zgCurve.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler); zgCurve.AxisChange(); zgCurve.Invalidate(); z = ++z; } } } m_curve = m_curve + "time"; DBcon cond = new DBcon(); string strd = "select " + m_curve + " from V_heatDatas where Name='" + Station + "' and time between '" + m_Begin + "' and '" + m_End + "' order by time"; SqlDataAdapter adpd = new SqlDataAdapter(strd, cond.GetConnection()); adpd.Fill(ds); } } } lvCurve.SelectedItems.Clear(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
/// <summary> /// Creates the space mapping scatter plot using ZedGraph. /// </summary> /// private void createMappingScatterplot(ZedGraphControl zgc, double[,] graph) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the titles myPane.Title.Text = "Scatter Plot"; myPane.XAxis.Title.Text = "X"; myPane.YAxis.Title.Text = "Y"; myPane.XAxis.IsAxisSegmentVisible = false; myPane.YAxis.IsAxisSegmentVisible = false; PointPairList list1 = new PointPairList(); PointPairList list2 = new PointPairList(); PointPairList list3 = new PointPairList(); for (int i = 0; i < graph.GetLength(0); i++) { if (graph[i, 2] == 1.0) list1.Add(graph[i, 0], graph[i, 1]); if (graph[i, 2] == 2.0) list2.Add(graph[i, 0], graph[i, 1]); if (graph[i, 2] == 3.0) list3.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); myCurve = myPane.AddCurve("G3", list3, Color.Orange, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Orange); myCurve = myPane.AddCurve("M1", new PointPairList(), Color.Blue, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Blue); myCurve = myPane.AddCurve("M2", new PointPairList(), Color.Green, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Green); myCurve = myPane.AddCurve("M3", new PointPairList(), Color.Orange, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Yellow); // Fill the background of the chart rect and pane myPane.Fill = new Fill(Color.WhiteSmoke); zgc.AxisChange(); zgc.Invalidate(); }
public void initialDateAxis(ZedGraph.ZedGraphControl zedChart) { 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; // Make up some data points based on the Sine function PointPairList list = new PointPairList(); for (int i = 0; i < this.m_dtLine1.Rows.Count; i++) { DateTime dt = Convert.ToDateTime(this.m_dtLine1.Rows[i]["x"].ToString()); double x = (double)new XDate(dt.Year, dt.Month, dt.Day); double y = Convert.ToDouble(this.m_dtLine1.Rows[i]["y"].ToString()); list.Add(x, y); } PointPairList list1 = new PointPairList(); for (int i = 0; i < this.m_dtLine2.Rows.Count; i++) { DateTime dt = Convert.ToDateTime(this.m_dtLine2.Rows[i]["x"].ToString()); double x = (double)new XDate(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second); double y = Convert.ToDouble(this.m_dtLine2.Rows[i]["y"].ToString()); list1.Add(x, y); } int iCount = 0; string[] strXLabels; if (this.m_dtLine2.Rows.Count > this.m_dtLine1.Rows.Count) { iCount = this.m_dtLine2.Rows.Count; strXLabels = new string[iCount]; for (int i = 0; i < iCount; i++) { DateTime dt = Convert.ToDateTime(this.m_dtLine2.Rows[i]["x"].ToString()); if (this.m_strState != "Day") { strXLabels[i] = String.Format("{0}-{1}-{2}", dt.Year.ToString(), dt.Month.ToString(), dt.Day.ToString()); } else { strXLabels[i] = String.Format("{0}-{1}-{2} {3}:{4}:{5}", dt.Year.ToString(), dt.Month.ToString(), dt.Day.ToString(), dt.Hour.ToString(), dt.Minute.ToString(), dt.Second.ToString()); } } } else { iCount = this.m_dtLine1.Rows.Count; strXLabels = new string[iCount]; for (int i = 0; i < iCount; i++) { DateTime dt = Convert.ToDateTime(this.m_dtLine1.Rows[i]["x"].ToString()); if (this.m_strState != "Day") { strXLabels[i] = String.Format("{0}-{1}-{2}", dt.Year.ToString(), dt.Month.ToString(), dt.Day.ToString()); } else { strXLabels[i] = String.Format("{0}-{1}-{2} {3}:{4}:{5}", dt.Year.ToString(), dt.Month.ToString(), dt.Day.ToString(), dt.Hour.ToString(), dt.Minute.ToString(), dt.Second.ToString()); } } } myPane.CurveList.Clear(); // Generate a red curve with diamond // symbols, and "My Curve" in the legend LineItem myCurve = myPane.AddCurve(this.m_strLine1Name, list, Color.Black, SymbolType.Circle); // myCurve = myPane.AddCurve( this.m_strLine2Name, // list1, Color.Green , SymbolType.Default ); myPane.XAxis.Type = AxisType.Text; myPane.XAxis.TextLabels = strXLabels; myPane.XAxis.ScaleFontSpec.Size = 10; myPane.YAxis.ScaleFontSpec.Size = 10; myCurve.Symbol.Fill = new Fill(Color.White); myCurve.Symbol.Size = 4; zedChart.AxisChange(); zedChart.Invalidate(); }
public void CreateResultScatterplot(ZedGraphControl zgc, double[][] inputs, double[] expected, double[] output) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the titles myPane.Title.IsVisible = false; myPane.XAxis.Title.Text = columnNames[0]; myPane.YAxis.Title.Text = columnNames[1]; // Regression problem PointPairList list1 = new PointPairList(); // svm output PointPairList list2 = new PointPairList(); // expected output for (int i = 0; i < inputs.Length; i++) { list1.Add(inputs[i][0], output[i]); list2.Add(inputs[i][0], expected[i]); } // Add the curve LineItem myCurve = myPane.AddCurve("Model output", list1, Color.Blue, SymbolType.Diamond); myCurve.Line.IsVisible = true; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Blue); myCurve = myPane.AddCurve("Data output", list2, Color.Red, SymbolType.Diamond); myCurve.Line.IsVisible = false; myCurve.Symbol.Border.IsVisible = false; myCurve.Symbol.Fill = new Fill(Color.Red); // Fill the background of the chart rect and pane myPane.Fill = new Fill(Color.WhiteSmoke); zgc.AxisChange(); zgc.Invalidate(); }
// Traditional Open-High-Low-Close Bar chart private void CreateGraph_OHLCBar( ZedGraphControl z1 ) { GraphPane myPane = z1.GraphPane; myPane.Title.Text = "OHLC Chart Demo"; myPane.XAxis.Title.Text = "Trading Date"; myPane.YAxis.Title.Text = "Share Price, $US"; StockPointList spl = new StockPointList(); Random rand = new Random(); // First day is feb 1st XDate xDate = new XDate( 2006, 2, 1 ); double open = 50.0; for ( int i = 0; i < 20; i++ ) { double x = xDate.XLDate; double close = open + rand.NextDouble() * 10.0 - 5.0; double hi = Math.Max( open, close ) + rand.NextDouble() * 5.0; double low = Math.Min( open, close ) - rand.NextDouble() * 5.0; StockPt pt = new StockPt( x, hi, low, open, close, 100000 ); spl.Add( pt ); open = close; // Advance one day xDate.AddDays( 1.0 ); // but skip the weekends if ( XDate.XLDateToDayOfWeek( xDate.XLDate ) == 6 ) xDate.AddDays( 2.0 ); } //OHLCBarItem myCurve = myPane.AddOHLCBar( "trades", spl, Color.Black ); OHLCBarItem myCurve = myPane.AddOHLCBar( "trades", spl, Color.Blue ); //myCurve.Bar.Size = 20; myCurve.Bar.IsAutoSize = true; //myCurve.Bar.PenWidth = 2; //myCurve.Bar.IsOpenCloseVisible = false; Fill fill = new Fill( Color.Red, Color.Yellow, Color.Blue ); fill.RangeMin = 40; fill.RangeMax = 70; fill.Type = FillType.GradientByY; myCurve.Bar.GradientFill = fill; // Use DateAsOrdinal to skip weekend gaps myPane.XAxis.Type = AxisType.DateAsOrdinal; //myPane.XAxis.Type = AxisType.Date; //myPane.XAxis.Scale.MajorStep = 1.0; // pretty it up a little myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45.0f ); myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45.0f ); //BoxObj box = new BoxObj( 4, 60, 5, 50000 ); //myPane.GraphObjList.Add( box ); // Tell ZedGraph to calculate the axis ranges z1.AxisChange(); z1.Invalidate(); }
public void CreateBarGraph(ZedGraphControl zgc, double[] discriminants) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); myPane.Title.IsVisible = false; myPane.Legend.IsVisible = false; myPane.Border.IsVisible = false; myPane.Border.IsVisible = false; myPane.Margin.Bottom = 20f; myPane.Margin.Right = 20f; myPane.Margin.Left = 20f; myPane.Margin.Top = 30f; myPane.YAxis.Title.IsVisible = true; myPane.YAxis.IsVisible = true; myPane.YAxis.MinorGrid.IsVisible = false; myPane.YAxis.MajorGrid.IsVisible = false; myPane.YAxis.IsAxisSegmentVisible = false; myPane.YAxis.Scale.Max = 9.5; myPane.YAxis.Scale.Min = -0.5; myPane.YAxis.MajorGrid.IsZeroLine = false; myPane.YAxis.Title.Text = "Classes"; myPane.YAxis.MinorTic.IsOpposite = false; myPane.YAxis.MajorTic.IsOpposite = false; myPane.YAxis.MinorTic.IsInside = false; myPane.YAxis.MajorTic.IsInside = false; myPane.YAxis.MinorTic.IsOutside = false; myPane.YAxis.MajorTic.IsOutside = false; myPane.XAxis.MinorTic.IsOpposite = false; myPane.XAxis.MajorTic.IsOpposite = false; myPane.XAxis.Title.IsVisible = true; myPane.XAxis.Title.Text = "Relative class response"; myPane.XAxis.IsVisible = true; myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = 100; myPane.XAxis.IsAxisSegmentVisible = false; myPane.XAxis.MajorGrid.IsVisible = false; myPane.XAxis.MajorGrid.IsZeroLine = false; myPane.XAxis.MinorTic.IsOpposite = false; myPane.XAxis.MinorTic.IsInside = false; myPane.XAxis.MinorTic.IsOutside = false; myPane.XAxis.Scale.Format = "0'%"; // Create data points for three BarItems using Random data PointPairList list = new PointPairList(); for (int i = 0; i < discriminants.Length; i++) list.Add(discriminants[i] * 100, i); BarItem myCurve = myPane.AddBar("b", list, Color.DarkBlue); // Set BarBase to the YAxis for horizontal bars myPane.BarSettings.Base = BarBase.Y; zgc.AxisChange(); zgc.Invalidate(); }
// OHLC Bar Test private void CreateGraph_OHLCBarTest( ZedGraphControl z1 ) { GraphPane myPane = z1.GraphPane; myPane.Title.Text = "OHLC Chart Demo"; myPane.XAxis.Title.Text = "Trading Date"; myPane.YAxis.Title.Text = "Share Price, $US"; StockPointList spl = new StockPointList(); Random rand = new Random(); // First day is jan 1st XDate xDate = new XDate( 2006, 1, 1 ); double open = 50.0; for ( int i = 0; i < 50; i++ ) { double x = xDate.XLDate; double close = open + rand.NextDouble() * 10.0 - 5.0; double hi = Math.Max( open, close ) + rand.NextDouble() * 5.0; double low = Math.Min( open, close ) - rand.NextDouble() * 5.0; StockPt pt = new StockPt( x, hi, low, open, close, 100000 ); spl.Add( pt ); open = close; // Advance one day //xDate.AddMinutes( 1.0 ); xDate.AddDays( 1.0 ); // but skip the weekends //if ( XDate.XLDateToDayOfWeek( xDate.XLDate ) == 6 ) // xDate.AddMinutes( 2.0 ); } OHLCBarItem myCurve = myPane.AddOHLCBar( "trades", spl, Color.Blue); //myCurve.Bar.IsAutoSize = true; myCurve.Bar.Color = Color.Blue; // Use DateAsOrdinal to skip weekend gaps //myPane.XAxis.Type = AxisType.DateAsOrdinal; myPane.XAxis.Type = AxisType.Date; //myPane.XAxis.Scale.Min = new XDate( 2006, 1, 1 ); // pretty it up a little myPane.Chart.Fill = new Fill( Color.White, Color.LightGoldenrodYellow, 45.0f ); myPane.Fill = new Fill( Color.White, Color.FromArgb( 220, 220, 255 ), 45.0f ); // Tell ZedGraph to calculate the axis ranges z1.AxisChange(); z1.Invalidate(); //z1.PointValueEvent += new ZedGraphControl.PointValueHandler( z1_PointValueEvent ); }
void PaintGraph(ZedGraphControl zedGraph, List<double> MPoint, List<double> MPoint_2, string Name) { this.Controls.Add(zedGraph); GraphPane pane = zedGraph.GraphPane; pane.CurveList.Clear(); int labelsXfontSize = 20; int labelsYfontSize = 20; int titleXFontSize = 20; int titleYFontSize = 20; int legendFontSize = 20; int mainTitleFontSize = 20; pane.XAxis.Title.Text = "Время"; pane.YAxis.Title.Text = "Значение"; pane.Title.Text = Name; pane.XAxis.Scale.FontSpec.Size = labelsXfontSize; pane.YAxis.Scale.FontSpec.Size = labelsYfontSize; pane.XAxis.Title.FontSpec.Size = titleXFontSize; pane.YAxis.Title.FontSpec.Size = titleYFontSize; pane.Legend.FontSpec.Size = legendFontSize; pane.Title.FontSpec.Size = mainTitleFontSize; pane.Title.FontSpec.IsUnderline = true; PointPairList list = new PointPairList(); int xmin = 0; int xmax = MPoint.Count - 1; int xmin_limit = 0; double xmax_limit = MPoint_2.Max(); for (int i = xmin; i < xmax; i++) { list.Add(MPoint_2[i], MPoint[i]); } //pane.XAxis.Scale.Min = xmin_limit; //pane.XAxis.Scale.Max = xmax_limit; LineItem myCurve1 = pane.AddCurve(Name, list, Color.Red, SymbolType.Circle); zedGraph.AxisChange(); zedGraph.Invalidate(); }
// Currently not is use!!! private void timer1_Tick(object sender, EventArgs e) { string data = "sdf"; string[] stringData2 = data.Split(';'); /* * string[] hexValuesSplit = stringData.Split(' '); * int adcv1 = Convert.ToInt32(hexValuesSplit[4], 16); * int adcv2 = Convert.ToInt32(hexValuesSplit[5], 16); * int adcv3 = Convert.ToInt32(hexValuesSplit[6], 16); * int adcv4 = Convert.ToInt32(hexValuesSplit[7], 16); * * int adcv1 = Convert.ToInt32(hexValuesSplit[1], 16); * int adcv2 = Convert.ToInt32(hexValuesSplit[2], 16); * int adcv3 = Convert.ToInt32(hexValuesSplit[3], 16); * int adcv4 = Convert.ToInt32(hexValuesSplit[4], 16); * * int adcv1 = Convert.ToInt32(stringData2[0]); * int adcv2 = Convert.ToInt32(stringData2[0]); * int adcv3 = Convert.ToInt32(stringData2[0]); * int adcv4 = Convert.ToInt32(stringData2[0]); * */ int adcv1 = 0; int adcv2 = 0; int adcv3 = 0; int adcv4 = 0; string stringData = "123"; if (stringData.Length > 3) { adcv1 = Convert.ToInt32(stringData2[0]); } else { adcv1 = 200; adcv2 = 253; adcv3 = 251; adcv4 = 250; } //sqlinsert(adcv1, adcv2, adcv3, adcv4); label1.Text = Convert.ToString(adcv1 + " " + adcv2 + " " + adcv3 + " " + adcv4); counter = counter + 1; if (this.log == "true") { //filewrite file = new filewrite(); //file.write(counter + "," + adcv1 + "," + adcv2 + "," + adcv3 + "," + adcv4); } spl1.Add(counter, adcv1); spl2.Add(counter, adcv2); spl3.Add(counter, adcv3); spl4.Add(counter, adcv4); zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); zedGraphControl1.Refresh(); Invalidate(); /* * * stringData = Encoding.ASCII.GetString(data, 0, recv); * Console.WriteLine(stringData); * * while (true) * { * input = Console.ReadLine(); * if (input == "exit") * break; * server.Send(Encoding.ASCII.GetBytes(input)); * data = new byte[1024]; * recv = server.Receive(data); * stringData = Encoding.ASCII.GetString(data, 0, recv); * Console.WriteLine(stringData); * } * /**/ //server.Shutdown(SocketShutdown.Both); //server.Close(); }
public void CreateComponentDistributionGraph(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the GraphPane title myPane.Title.Text = "Component Proportion"; myPane.Title.FontSpec.Size = 24f; myPane.Title.FontSpec.Family = "Tahoma"; // Fill the pane background with a color gradient // myPane.Fill = new Fill(Color.White, Color.WhiteSmoke, 45.0f); // No fill for the chart background myPane.Chart.Fill.Type = FillType.None; myPane.Legend.IsVisible = false; // Add some pie slices for (int i = 0; i < lda.Discriminants.Count; i++) { myPane.AddPieSlice(lda.Discriminants[i].Proportion, colors[i % colors.Length], 0.1, lda.Discriminants[i].Index.ToString()); } myPane.XAxis.Scale.MinAuto = true; myPane.XAxis.Scale.MaxAuto = true; myPane.YAxis.Scale.MinAuto = true; myPane.YAxis.Scale.MaxAuto = true; myPane.XAxis.Scale.MagAuto = true; myPane.YAxis.Scale.MagAuto = true; // Calculate the Axis Scale Ranges zgc.AxisChange(); zgc.Invalidate(); }
//初始化试验结果曲线 private void initResultCurve(ZedGraph.ZedGraphControl zgControl) { #region //Random random = new Random(); //for (int pointIndex = 0; pointIndex < 50; pointIndex++) //{ // chart.Series[0].Points.AddY(random.Next(32, 95)); //} //// Set series chart type //chart.Series[0].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.FastLine; //// Set point labels //chart.Series[0].IsValueShownAsLabel = false; //chart.Series[0].IsVisibleInLegend = false; //// Enable X axis margin //chart.ChartAreas["Default"].AxisX.IsMarginVisible = false; //chart.Titles[0].Text = "力-位移"; //// Show as 3D //chart.ChartAreas["Default"].Area3DStyle.Enable3D = false; #endregion //_RPPList0 = new RollingPointPairList(50000); //ZedGraph //zedGraphControl1.IsAntiAlias = true; Legend l = zgControl.GraphPane.Legend; l.IsShowLegendSymbols = true; l.Gap = 0; l.Position = LegendPos.InsideTopLeft; l.FontSpec.Size = 16.0f; l.IsVisible = false; // Set the titles and axis labels _ResultPanel = zgControl.GraphPane; _ResultPanel.Margin.All = 8; _ResultPanel.Margin.Top = 15; _ResultPanel.Title.Text = ""; _ResultPanel.Title.IsVisible = false; _ResultPanel.IsFontsScaled = false; zgControl.IsZoomOnMouseCenter = false; zgControl.IsShowContextMenu = false; zgControl.IsShowPointValues = true; zgControl.MouseClick += new MouseEventHandler(zgControl_MouseClick); //XAxis //最后的显示值隐藏 _ResultPanel.XAxis.Scale.FontSpec.Size = 16.0f; _ResultPanel.XAxis.Title.FontSpec.Size = 16.0f; _ResultPanel.XAxis.Scale.FontSpec.Family = "宋体"; _ResultPanel.XAxis.Scale.FontSpec.IsBold = true; _ResultPanel.XAxis.Title.FontSpec.FontColor = Color.FromArgb(34, 67, 108); _ResultPanel.XAxis.Scale.FontSpec.FontColor = Color.FromArgb(34, 67, 108); _ResultPanel.XAxis.Title.Text = "X"; _ResultPanel.XAxis.Title.Gap = -0.5f; _ResultPanel.XAxis.Scale.AlignH = AlignH.Center; _ResultPanel.XAxis.Scale.LabelGap = 0; _ResultPanel.XAxis.Scale.Format = "0.0"; _ResultPanel.XAxis.Scale.MinGrace = 0.0; _ResultPanel.XAxis.Scale.MaxGrace = 0.05; _ResultPanel.XAxis.Scale.Min = 0; _ResultPanel.XAxis.Scale.MinAuto = false; _ResultPanel.XAxis.Scale.Max = 1; _ResultPanel.XAxis.Scale.MaxAuto = false; _ResultPanel.XAxis.MajorGrid.IsVisible = true; _ResultPanel.XAxis.MinorGrid.IsVisible = false; _ResultPanel.XAxis.MinorGrid.Color = Color.Silver; _ResultPanel.XAxis.MinorGrid.DashOff = 1; _ResultPanel.XAxis.MinorGrid.DashOn = 1; _ResultPanel.YAxis.Title.Text = "Y"; _ResultPanel.YAxis.Title.Gap = -0.5f; _ResultPanel.YAxis.Scale.FontSpec.FontColor = Color.FromArgb(34, 67, 108); _ResultPanel.YAxis.Title.FontSpec.FontColor = Color.FromArgb(34, 67, 108); _ResultPanel.YAxis.Scale.FontSpec.Size = 16.0f; _ResultPanel.YAxis.Title.FontSpec.Size = 16.0f; _ResultPanel.YAxis.Scale.FontSpec.Family = "宋体"; _ResultPanel.YAxis.Scale.FontSpec.IsBold = true; _ResultPanel.YAxis.Scale.Format = "0.0"; _ResultPanel.YAxis.Scale.MinGrace = 0.0; _ResultPanel.YAxis.Scale.MaxGrace = 0.05; _ResultPanel.YAxis.Scale.LabelGap = 0; // Align the Y2 axis labels so they are flush to the axis _ResultPanel.YAxis.Scale.AlignH = AlignH.Center; _ResultPanel.YAxis.Scale.Min = 0; _ResultPanel.YAxis.Scale.MinAuto = false; _ResultPanel.YAxis.Scale.Max = 1; _ResultPanel.YAxis.Scale.MaxAuto = false; _ResultPanel.YAxis.MajorGrid.IsVisible = true; _ResultPanel.YAxis.MinorGrid.IsVisible = false; _ResultPanel.YAxis.MinorGrid.Color = Color.Silver; _ResultPanel.YAxis.MinorGrid.DashOff = 1; _ResultPanel.YAxis.MinorGrid.DashOn = 1; zgControl.AxisChange(); zgControl.Invalidate(); }
/// <summary> /// Draws the graph /// </summary> /// <param name="zgc"> /// The control for the graph element /// </param> /// <param name="measurements"> /// Points of the graph /// </param> private void CreateGraph(ZedGraphControl zgc, string measurements, string xaxis, string yaxis) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); PointPairList list = new PointPairList(); myPane.Title.Text = "TelosB Graph"; //put the received data in the graph XmlDocument tempdoc = new XmlDocument(); tempdoc.LoadXml(measurements); XmlNodeList bookList = tempdoc.GetElementsByTagName("MeasurementValue"); double x = 1; foreach (XmlNode node in bookList) { string yyyy = node.InnerText.ToString(); double y = Convert.ToDouble(yyyy); x = x + 1; list.Add(x, y); } myPane.AddCurve("MyCurve", list, Color.Red, SymbolType.Square); myPane.XAxis.Title.Text = xaxis; myPane.YAxis.Title.Text = yaxis; zgc.AxisChange(); zgc.Invalidate(); }
/// <summary> /// /// </summary> private void DrawCurve() { if (LoadDatas()) { list = new PointPairList(); myPane.CurveList.Clear(); myPane.Title = //m_dtBegin.ToShortDateString()+ //"日 至"+m_dtEnd.ToShortDateString()+"日 "+ //m_name+" 热能曲线图"; string.Format("{0} 至 {1} {2} 热能曲线图", m_dtBegin.ToShortDateString(), m_dtEnd.ToShortDateString(), m_name ); myPane.XAxis.Title = "时间"; myPane.YAxis.Title = ""; myPane.XAxis.Type = AxisType.Date; myPane.XAxis.ScaleFontSpec.Size = 8; myPane.YAxis.ScaleFontSpec.Size = 8; for (int i = 0; i < m_FactDatas.Length; i++) { string time = m_FactDatas[i].x.ToString(); int yearlast = time.IndexOf("-", 0); int monthlast = time.IndexOf("-", yearlast + 1); int daylast = time.IndexOf(" ", monthlast + 1); int hourlast = time.IndexOf(":", daylast + 1); int minituelast = time.IndexOf(":", hourlast + 1); string year = time.Substring(0, 4); string month = time.Substring(yearlast + 1, monthlast - yearlast - 1); string day = time.Substring(monthlast + 1, daylast - monthlast - 1); string hour = time.Substring(daylast + 1, hourlast - daylast - 1); string minitue = time.Substring(hourlast + 1, minituelast - hourlast - 1); string second = time.Substring(minituelast + 1); double x = new XDate(Convert.ToInt32(year), Convert.ToInt32(month), Convert.ToInt32(day), Convert.ToInt32(hour), Convert.ToInt32(minitue), Convert.ToInt32(second)); double y = System.Convert.ToDouble(m_FactDatas[i].y); list.Add(x, y); } LineItem myCurve = myPane.AddCurve("实际曲线", list, Color.Blue, SymbolType.Circle); myCurve.Symbol.Fill = new Fill(Color.White); myCurve.Symbol.Size = 3; myPane.XAxis.Title = "时间"; myPane.YAxis.Title = "GJ"; myPane.AxisFill = new Fill(Color.White, Color.LightGray, 45F); zgCurve.IsShowPointValues = true; zgCurve.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler); zgCurve.AxisChange(); zgCurve.Invalidate(); list = new PointPairList(); for (int i = 0; i < m_FactDatas.Length; i++) { string time = m_IdeaDatas[i].x.ToString(); int yearlast = time.IndexOf("-", 0); int monthlast = time.IndexOf("-", yearlast + 1); int daylast = time.IndexOf(" ", monthlast + 1); int hourlast = time.IndexOf(":", daylast + 1); int minituelast = time.IndexOf(":", hourlast + 1); string year = time.Substring(0, 4); string month = time.Substring(yearlast + 1, monthlast - yearlast - 1); string day = time.Substring(monthlast + 1, daylast - monthlast - 1); string hour = time.Substring(daylast + 1, hourlast - daylast - 1); string minitue = time.Substring(hourlast + 1, minituelast - hourlast - 1); string second = time.Substring(minituelast + 1); double x = new XDate(Convert.ToInt32(year), Convert.ToInt32(month), Convert.ToInt32(day), Convert.ToInt32(hour), Convert.ToInt32(minitue), Convert.ToInt32(second)); double y = System.Convert.ToDouble(m_IdeaDatas[i].y); list.Add(x, y); } myCurve = myPane.AddCurve("理想曲线", list, Color.Red, SymbolType.Circle); myCurve.Symbol.Fill = new Fill(Color.White); myCurve.Symbol.Size = 3; myPane.XAxis.Title = "时间"; myPane.YAxis.Title = "GJ"; myPane.AxisFill = new Fill(Color.White, Color.LightGray, 45F); zgCurve.IsShowPointValues = true; zgCurve.PointValueEvent += new ZedGraphControl.PointValueHandler(MyPointValueHandler); zgCurve.AxisChange(); zgCurve.Invalidate(); } else { MessageBox.Show("该站满足条件的数据不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }