System.Windows.Forms.DataVisualization.Charting.Chart
//创建圖形式的ChartSystem.Windows.Forms.DataVisualization.Charting.Chart chart1 = new System.Windows.Forms.DataVisualization.Charting.Chart();//定义一个chartSystem.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();//定义一个绘图区域System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();chartArea1.AxisY.LabelStyle.Format = "0%";//定义一个数据列chartArea1.Name = "ChartArea1";//其实没有必要,可以使用chart1。ChartAreas[0]就可以了chart1.ChartAreas.Add(chartArea1);//完成Chart和chartArea的关联//System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();//legend1.Name = "图标";//chart1.Legends.Add(legend1);chart1.Name = "chart1";//series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Column;//定於為線性還是餅形//设置线性Random rd = new Random();double[] num = new double[20];//for (int i = 0; i < 20; i++)//{// int valuey = rd.Next(1,1);// DataPoint point = new DataPoint((i + 1), valuey);// series1.Points.Add(point);//}DataPoint point = new DataPoint(( 1), 0.02);series1.Points.Add(point);//产生点的坐标//chart1.Titles[0].Text = "";series1.ChartArea = "ChartArea1";//chartArea1.AxisX.Title = "日期";//Title ttl = new Title("");//chart1.Titles.Add(ttl);//series1.ChartArea = "ChartArea1";//series1.BorderWidth = 1;//series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;//series1.Font = new System.Drawing.Font("Microsoft JhengHei",Convert.ToSingle( 10.0));//series1.IsValueShownAsLabel = false;//series1.IsVisibleInLegend = true;//series1.Legend = "Legend1";////series1.LegendText = "2018";//series1.MarkerSize = 5;//series1.BorderWidth = 2;////series1.MarkerColor = Color.Gray;//series1.Color = Color.Gray;////series1.Name = "Series1";////series1.ToolTip = "#VAL";chartArea1.AxisY.Title = "值";chartArea1.AxisX.Interval = 1;chartArea1.AxisY.Interval =0.0012;chartArea1.AxisY.Minimum = 0;//series1.Legend = "图标";series1.Name = "Series1";chart1.Text = "测试";//chart1.Size = new System.Drawing.Size(700, 500);chart1.Size = new System.Drawing.Size(1100, 600);//chart1.Location = new System.Drawing.Point(50,120);series1.Color = Color.Blue;chart1.Text = "ceshi";//chart1.Titles[0].Text = "fff";//chart1.Size = new System.Drawing.Size(1, 1);Legend Legend1 = new Legend();//初始化一个图例的实例Legend1.Alignment = System.Drawing.StringAlignment.Center;Legend1.BackImageAlignment = System.Windows.Forms.DataVisualization.Charting.ChartImageAlignmentStyle.Top;Legend1.BorderDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dot;Legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Bottom;//Legend1.Font = new System.Drawing.Font("Microsoft JhengHei", 10.0, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte));Legend1.IsTextAutoFit = true;Legend1.ItemColumnSpacing = 30;Legend1.MaximumAutoSize = Convert.ToSingle(30.0);Legend1.Name = "Legend1";Legend1.TitleFont = new System.Drawing.Font("Microsoft JhengHei",Convert.ToSingle( 10.0));chart1.Legends.Add(Legend1);chart1.Series.Add(series1);//这一句很重要,缺少的话绘图区域将显示空白//chart1.SizeChanged += new System.EventHandler(DoSizeChanged);//chart1.AllowDrop = true;chart1.BackColor = Color.FromArgb(243, 223, 193);//设置chart背景颜色chartArea1.BackColor = Color.FromArgb(243, 223, 193);//设置c绘图区域背景颜色series1.BorderWidth = 2;series1.IsValueShownAsLabel = true;//是否显示Y的值this.groupBox1.Controls.Add(chart1);this.panel1.Controls.Add(chart1);chart1.Visible = true;//this.label10.Visible = true;//this.label10.Text = "【" + tn.Name + "】图";chart1.Titles.Add("【wqqqd】图");//为Chart1添加标题chartArea1.AxisX.IsMarginVisible = true;//是否显示X轴两端的空白//2、在上述chart的基础上添加一条线Control[] controls = this.panel1.Controls.Find("chart1", true);//找到已经有的Chart1System.Windows.Forms.DataVisualization.Charting.Chart ch = (System.Windows.Forms.DataVisualization.Charting.Chart)controls[0];System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();//新定义一个数据项Random rd1 = new Random();//for (int i = 0; i < ch.Series[0].Points.Count; i++)//{// int valuey = rd.Next(1, 1);// DataPoint point = new DataPoint((i + 2), valuey);// series2.Points.Add(point);//}DataPoint point1 = new DataPoint((1), 0.02);series2.Points.Add(point1);series2.Color = Color.FromArgb(rd1.Next(100, 255), rd1.Next(0, 150), rd1.Next(0, 255));series2.BorderWidth = 2;//series2.ChartType = ((System.Windows.Forms.DataVisualization.Charting.Chart)this.panel1.Controls[0]).Series[0].ChartType;series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn;//定於為線性還是餅形// series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bar;//设置图表的类型(饼状、线状等等)//series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Bar;//设置图表的类型(饼状、线状等等)//定义线性和原有的线条形状一致series2.IsValueShownAsLabel = false;ch.Series.Add(series2);//添加数据列//3、减少一条曲线//Control[] controls1 = this.panel1.Controls.Find("chart1", true);//System.Windows.Forms.DataVisualization.Charting.Chart ch1 = (System.Windows.Forms.DataVisualization.Charting.Chart)controls[0];//if (ch1.Series.Count > 1)//{// //MessageBox.Show(this, "去掉一条线!", "信息提示");// int i = ch1.Series.Count - 1;// while (i > 1)// {// if (ch1.Series[i].Points.Count > 0)// {// break;// }// i -= 1;// }// ch1.Series[i].Points.Clear();// //this.toolStripStatusLabel2.Text = "减少对比曲线完成!";//}//else//{// MessageBox.Show(this, "绘图区域至少要有一条线!", "信息提示");//}
System.Windows.Forms.DataVisualization.Charting.Chart相关推荐
- c#使用System.Windows.Forms.DataVisualization.Charting.dll绘制图表实例
首先下载System.Windows.Forms.DataVisualization.Charting.dll,然后引用到项目中 手动在代码中创建chart类型并将其添加到某个控件中(control. ...
- System.Windows.Forms.Timer在线程中的注意事项
在WinForm中使用System.Windows.Forms.Timer对象,如果是在单线程中使用,则直接设置该对象的Enabled属性值即可启动计时器,但如果是在多线程窗体中在多线程引发的事件中调 ...
- System.Windows.Forms.ListView : Control
#region 程序集 System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ...
- System.Timers.Timer与System.Windows.Forms.Timer 区别
根据msdn解释:System.Threading.Timer 是一个简单的轻量计时器,它使用回调方法并由线程池线程提供服务. 不建议将其用于 Windows 窗体,因为其回调不在用户界面线程上进行. ...
- C# WinForm编程之System.Windows.Forms.DataGridViewRow.DataBoundItem Property
Namespace: System.Windows.Forms Assembly: System.Windows.Forms.dll 获取用于填充行的数据绑定对象. 下面的代码示例演示如何使用 Dat ...
- System.Windows.Forms命名空间的MessageBox.show()用法大全
摘要: // 显示消息窗口(也称为对话框)向用户展示消息. 这是一个模式窗口,可阻止应用程序中的其他操作,直到用户将其关闭. System.Windows.Forms.MessageB ...
- System.Windows.Forms.Timer与System.Timers.Timer的区别
.NET Framework里面提供了三种Timer: System.Windows.Forms.Timer System.Timers.Timer System.Threading.Timer VS ...
- System.Timers.Timer 嵌套 System.Windows.Forms.Timer的问题
如题"System.Timers.Timer 嵌套 System.Windows.Forms.Timer的问题",最近在项目中在类uc_Map中启用了System.Timers.T ...
- “FormCRUD.csProj.FormMain.Name”隐藏了继承的成员“System.Windows.Forms.Control.Name”。如果是有意隐藏,请使用关键字 new。...
"FormCRUD.csProj.FormMain.Name"隐藏了继承的成员"System.Windows.Forms.Control.Name".如果是有意 ...
最新文章
- Fluke OTDR新增SmartLoop双向测试功能
- Tianchi数据集最全更新!
- Linux的shell scripts的shell脚本练习
- Failed to start mongod.service: Unit mongod.service not found
- java使用不存在的字符串_jpa – java.lang.IllegalArgumentException:您试图使用查询字符串中不存在的字符串名称设置参数值...
- 互联网1分钟 |1127
- MySQL——查询数据库、数据表总记录数
- C语言enum(枚举)、指针、函数指针
- Psych101(part2)--Day2
- Altium Designer 20,新功能有哪些?
- 网站服务器需要定期重启吗,定期服务器重启的好处和障碍
- resharper license server
- 百度之星大赛启动,聚焦目标检测,总奖池11.2万!
- Oracle开发›如何取出每个分组的第一条记
- ERP财务报表快消失了?用它做财务系统根本不够用
- cocos2dx 3.x(移动修改精灵坐标MoveTo与MoveBy)
- 记一次2048小游戏开发
- [网络安全自学篇] 二十三.基于机器学习的恶意请求识别及安全领域中的机器学习
- 网吧操作系统制作与优化
- 无法启动WORKSTATION服务解决方案