How to draw real-time graph of C #
This article will explain in detail how to draw real-time graphs in C#. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The details are as follows:
/ / definition of drawing section Int32 Draw_Top;// painting Y start point Int32 Draw_Left;// painting X start point Int32 Draw_EdgeWidth;//X edge width Int32 Draw_EdgeHeight;//Y edge height Int32 Draw_RangeWidth;// painting range width Int32 Draw_RangeHeight;// painting range height Double [] XTDYData = new Double [21]; Int32 ICountDraw=0 Int32 IActualWidth, IActualHeight; Int32 Draw_AdjustX = 20; Int32 Draw_AdjustY = 20; Point StartPoint = new Point (); Point EndPoint = new Point (); Point ZeroPoint = new Point (); Int32 IScalesY = 11; Int32 IScalesX = 21; Int32 IIncrementX; Pen pSpecial = new Pen (Color.Black,1); Pen pCommon = new Pen (Color.Black,2) Font FontTitle = new Font ("Microsoft Yahei", 12); / / the font Font FontText = new Font ("Microsoft Yahei", 9); / / the font SolidBrush SBTitle = new SolidBrush (Color.Red); SolidBrush SBText = new SolidBrush (Color.Black)
Draw a curve in the event of data reception:
/ / display trend graph ICountDraw = ICountDraw + 1; if (ICountDraw = = 21) {for (int iTunes 1)