MSChart绘图控件中折线图和柱形图画法
首先在前台拖入一个名为chart1的MSChart控件
//折线图
string strLegend = "Legend1";
Legend lg = new Legend(strLegend);
lg.IsDockedInsideChartArea = false;
lg.TitleAlignment = System.Drawing. StringAlignment.Center;
chart1.Legends.Add(lg); ChartArea ca = new ChartArea();
ca.AxisX.MajorGrid.Enabled = false;
ca.AxisX.MajorTickMark.Enabled = false;
ca.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.NotSet;
int index = ;
Series MyScore = new Series( "我的得分" );
MyScore.ChartType = SeriesChartType.Line;
MyScore.Legend = "Legend1";
MyScore.ChartArea = "ChartArea1";
MyScore.BorderWidth = ;
Series HighScore = new Series( "最高分" );
HighScore.ChartType = SeriesChartType.Line;
HighScore.Legend = "Legend1";
HighScore.ChartArea = "ChartArea1";
MyScore.BorderWidth = ;
Series AvgScore = new Series( "平均分" );
AvgScore.ChartType = SeriesChartType.Line;
AvgScore.Legend = "Legend1";
AvgScore.ChartArea = "ChartArea1";
MyScore.BorderWidth = ;
foreach (DataRow dr in m_table.Rows)
{
DataPoint dp;
if (dr["MyScore" ] == null)
continue;
dp = new DataPoint (index, Convert.ToDouble(dr["MyScore" ]));
dp.AxisLabel = dr[ "Name"].ToString();
dp.Label = Convert.ToInt32(dr["MyScore" ]).ToString();
dp.BorderWidth = ;
dp.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle .Star10;
MyScore.Points.Add(dp);
dp = new DataPoint (index, Convert.ToDouble(dr["HighScore" ]));
dp.AxisLabel = dr[ "Name"].ToString();
dp.Label = Convert.ToInt32(dr["HighScore" ]).ToString();
dp.BorderWidth = ;
dp.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle .Star10;
HighScore.Points.Add(dp);
dp = new DataPoint (index, Convert.ToDouble(dr["AvgScore" ]));
dp.AxisLabel = dr[ "Name"].ToString();
dp.Label = Convert.ToInt32(dr["AvgScore" ]).ToString();
dp.BorderWidth = ;
dp.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle .Star10;
AvgScore.Points.Add(dp);
index++;
}
chart1.Series.Add(MyScore);
chart1.Series.Add(HighScore);
chart1.Series.Add(AvgScore);
chart1.ChartAreas.Add(ca);
//柱形图
string strLegend = "Legend1" ;
Legend lg = new Legend(strLegend);
lg.IsDockedInsideChartArea = false;
lg.TitleAlignment = System.Drawing.StringAlignment .Center;
chart1.Legends.Add(lg); ChartArea ca = new ChartArea();
ca.AxisX.MajorGrid.Enabled = false;
ca.AxisX.MajorTickMark.Enabled = false;
ca.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.NotSet;
int index = ;
foreach (DataRow dr in dt.Rows)
{
Series s = new Series(dr["CourseTermName" ].ToString());
s.ChartType = SeriesChartType.Column;
s.Legend = "Legend1";
s.ChartArea = "ChartArea1";
DataPoint dp;
dp = new DataPoint (index, Convert.ToDouble(dr["Score" ]));
dp.AxisLabel = dr[ "CourseTermName"].ToString();
dp.Label = Convert.ToInt32(dr["Score" ]).ToString();
dp.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle .Star10;
s.Points.Add(dp);
chart1.Series.Add(s);
index++;
}
chart1.ChartAreas.Add(ca);
设置序列的MarkerStyle可以 显示出数据点标记,它是一个枚举,有多个样式,圆点、三角、矩形什么的,甚至可以通过MarkerImage来指定一个图形作为数据点,属性方面可以通过 MarkerSize和MarkerBorderWidth来指定数据点大小,MarkerColor和MarkerBorderColor来指定数据点 颜色。
希望对大家有帮助。以上都是我在项目中实现过的。
MSChart绘图控件中折线图和柱形图画法的更多相关文章
- VS2010 使用TeeChart绘图控件 - 之二 - 绘制图形(折线图,柱状图)
1.前期准备 具体可见VS2010 使用TeeChart绘图控件 - 之一 控件和类的导入 1. 1 添加TeeChart控件,给控件添加变量m_TeeChart 添加TeeChart控件,右击控件, ...
- 怎样在VS2013/MFC中使用TeeChart绘图控件
TeeChart作为一款强大好用的绘图控件,通过它可以绘制出各式各样的图表,包括2D的,还有3D的,绘制的图表美观实用,这里主要讲述如何在VS2013/MFC中使用TeeChart控件,顺便说一下在V ...
- WPF 在绘图控件(Shape)中添加文字 [2018.7.15]
原文:WPF 在绘图控件(Shape)中添加文字 [2018.7.15] Q:使用Shape的子类Ellipse画一个圆,如何在圆中添加文字? A:Shape类中不包含Text属性.可使用Shape类 ...
- paper 139:qt超强绘图控件qwt - 安装及配置
qwt是一个基于LGPL版权协议的开源项目, 可生成各种统计图.它为具有技术专业背景的程序提供GUI组件和一组实用类,其目标是以基于2D方式的窗体部件来显示数据, 数据源以数值,数组或一组浮点数等方式 ...
- C# 导出一个控件的矢量图
调用Control.DrawToBitmap(Bitmap) 方法是很容易得到控件的图形的. 但是bitmap是栅格化图形.栅格化图形有很多缺点,比如文件体积比较大. 放大后失真. 不易编辑等等. 这 ...
- VS2010 使用TeeChart绘图控件 - 之一 - 控件和类的导入
vs2010的用法和vc6有很大的不同,特别是在一些函数调用那里,当然.控件导入也是很不一样的 安装好控件后就可以在工程里加入teechart控件了 加入方法有如下几种: 1.添加Teechart控件 ...
- PaintView 绘图控件解析
博客地址:博客园,版权所有,转载须联系作者. GitHub地址:JustWeTools 最近做了个绘图的控件,实现了一些有趣的功能. 先上效果图: PaintView画图工具: 1.可直接使用设定按钮 ...
- Flex 列表控件中的操作
主要操作包括:显示提示,使用图标,编辑列表条目中数据. 1.使用数据提示: 当鼠标停留在条目上时,可以显示该条目的相关数据提示. 当利用滚动条时,可以显示滚动条的相关提示. 在列表控件中使用showD ...
- 修复duilib CEditUI控件和CWebBrowserUI控件中按Tab键无法切换焦点的bug
转载请说明原出处,谢谢~~:http://blog.csdn.net/zhuhongshu/article/details/41556615 在duilib中,按tab键会让焦点在Button一类的控 ...
随机推荐
- php : 自定义分页类
Page.class.php : <?php namespace Tools; class Page { private $total; //数据表中总记录数 private $listRows ...
- github项目配置
准备工作: 下载一个git: https://git-scm.com/downloads 1.登陆到github 登陆地址:https://github.com/login 2.创建新项目 3.配置 ...
- 微软亚洲实验室一篇超过人类识别率的论文:Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification ImageNet Classification
在该文章的两大创新点:一个是PReLU,一个是权值初始化的方法.下面我们分别一一来看. PReLU(paramter ReLU) 所谓的PRelu,即在 ReLU激活函数的基础上加入了一个参数,看一个 ...
- eclipse导入android项目红叉和红色感叹号怎么解决
解决办法如下:第一步:你要确保这个项目没有问题,有的项目本身就有问题,例如:xml文件,java程序等本身就有错.第二步:在Eclipse菜单中选择“Project”----〉Clean 解决不了,下 ...
- hub config
@echo off title Selenium_Hub cd /d %~dp0 java -jar selenium-server-standalone-2.48.2.jar -role hub - ...
- python3 密码生成器
用random模块实现按照要求生成一定个数和一定位数的密码: #Author by Andy #_*_ coding:utf-8 _*_ import random checkcode='' code ...
- 严重:Error listenerStart
转自: http://1985wanggang.blog.163.com/blog/static/7763833200942611050436/ 近日浏览论坛,发现好多人提问,都说在运行web程序时, ...
- checkbox点击后出现div
HTML: <div class="msg_editUrl_function"> <label class="labelChecked" fo ...
- 游戏外挂四之利用CE和OD查找被选中怪物和怪物列表
合肥程序员群:49313181. 合肥实名程序员群:128131462 (不愿透露姓名和信息者勿加入)Q Q:408365330 E-Mail:egojit@qq.com 这一节我们利 ...
- Unity3D 中的3种坐标系
Unity3D Script API : Camera 若干文章: 1.Screen VS Viewport What is the difference 2.Screen,Viewport有什麽區別 ...