文件名称:动态折线图绘制
文件大小:119KB
文件格式:ZIP
更新时间:2015-03-31 06:15:22
动态折线图绘制
private void mpanelXaxisPaint(object sender, PaintEventArgs e) { try { int temp = 0; //Consider the graphics object of the x axis panel. Graphics g = e.Graphics; pnlXAxis.BackColor = Color.FromName(XAxisBackColor.Name); //The smoothing mode is set to Antialias which gives very smooth effect g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; int j = 0; //If scroll bar visible then calculate the number of //moves the scroll bar as scrolled. if (!scrollBar.Visible) temp = Convert.ToInt32(totalPointTime) * GridSpacingX; else temp = Convert.ToInt32(totalPointTime) * GridSpacingX - (((this.scrollBar.Maximum - this.scrollBar.LargeChange) - noOfMoves) * GridSpacingX); if (j < 0) return; for (int i = (this.pnlXAxis.Width - temp - this.panelExtra.Width); i <= this.pnlXAxis.Width && j >= 0; i += GridSpacingX, j++) { if (j >= this.values.timeCount) return; //Draw the string by calculating the x and y values. if (Convert.ToInt32(this.values.GetTIMEIndex(j, "Time")) % XValueDisplayInterval == 0) { g.DrawString(this.values.GetTIMEIndex(j, "Time"), new Font("Arial", 8f, FontStyle.Regular), Brushes.Black, new PointF(i-3, this.pnlXAxis.Height / 12)); } } } catch (Exception ex) { //Log the error } }
【文件预览】:
DemoAndCode
----WindowsLineGraph.zip(74KB)
----Line_Graph_Demo.zip(44KB)