ImageVerifierCode 换一换
格式:DOCX , 页数:17 ,大小:19.56KB ,
资源ID:28570305      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/28570305.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(c#mschart简单例子.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

c#mschart简单例子.docx

1、c#mschart简单例子c# mschart 简单例子2010-04-16 18:43:14|分类: 控件 |标签: |字号大中小订阅 第一个简单的chart: spline/ Create new data series and set its visual attributes Series series = new Series(Spline); series.ChartType = SeriesChartType.Spline; series.BorderWidth = 3; series.ShadowOffset = 2; / Populate new series with da

2、ta series.Points.AddY(67); series.Points.AddY(57); series.Points.AddY(83); series.Points.AddY(23); series.Points.AddY(70); series.Points.AddY(60); series.Points.AddY(90); series.Points.AddY(20); / Add series into the charts series collection Chart1.Series.Add(series);同时显示2条曲线/ Populate series with r

3、andom data Random random = new Random(); for (int pointIndex = 0; pointIndex 10; pointIndex+) Chart1.SeriesSeries1.Points.AddY(random.Next(45, 95); Chart1.SeriesSeries2.Points.AddY(random.Next(5, 75); / Set series chart type Chart1.SeriesSeries1.ChartType = SeriesChartType.Line; Chart1.SeriesSeries2

4、.ChartType = SeriesChartType.Spline; / Set point labels Chart1.SeriesSeries1.IsValueShownAsLabel = true; Chart1.SeriesSeries2.IsValueShownAsLabel = true; / Enable X axis margin Chart1.ChartAreasChartArea1.AxisX.IsMarginVisible = true; / Enable 3D, and show data point marker lines Chart1.ChartAreasCh

5、artArea1.Area3DStyle.Enable3D = true; Chart1.SeriesSeries1ShowMarkerLines = True; Chart1.SeriesSeries2ShowMarkerLines = True;显示column类型图/ Create new data series and set its visual attributes Series series = new Series(FlowRead); series.ChartType = SeriesChartType.Column; series.BorderWidth = 3; seri

6、es.ShadowOffset = 2; / Populate new series with data series.Points.AddY(67); series.Points.AddY(57); series.Points.AddY(83); series.Points.AddY(23); series.Points.AddY(70); series.Points.AddY(60); series.Points.AddY(90); series.Points.AddY(20); / Add series into the charts series collection Chart1.S

7、eries.Add(series);很多点,效率还可以/ Fill series data double yValue = 50.0; Random random = new Random(); for (int pointIndex = 0; pointIndex 20000; pointIndex+) yValue = yValue + (random.NextDouble() * 10.0 - 5.0); Chart1.SeriesSeries1.Points.AddY(yValue); / Set fast line chart type Chart1.SeriesSeries1.Ch

8、artType = SeriesChartType.FastLine; 日期,xy类型/ Create a new random number generator Random rnd = new Random(); / Data points X value is using current date DateTime date = DateTime.Now.Date; / Add points to the stock chart series for (int index = 0; index 10; index+) Chart1.SeriesSeries1.Points.AddXY(

9、date, / X value is a date rnd.Next(40, 50); / Close Y value / Add 1 day to our X value date = date.AddDays(1); int-int的xy数据绘图/ Create a new random number generator Random rnd = new Random(); / Add points to the stock chart series for (int index = 0; index 10; index+) Chart1.SeriesSeries1.Points.AddX

10、Y( rnd.Next(10, 90), / X value is a date rnd.Next(40, 50); / Close Y value 数据库数据,datetime-int类型string connStr = server=localhost;database=seis_project;uid=seisprjs;pwd=seisprjs; SqlConnection myConn = new SqlConnection(connStr); string selStr = select 时间,序号 from pub_log_read order by 序号 asc; SqlComm

11、and myCmd = myConn.CreateCommand(); myCmd.CommandText = selStr; myConn.Open(); SqlDataReader sdr = myCmd.ExecuteReader(CommandBehavior.CloseConnection); / Since the reader implements and IEnumerable, pass the reader directly into / the DataBindTable method with the name of the Column to be used as t

12、he XValue Chart1.DataBindTable(sdr, 时间); sdr.Close(); myConn.Close();数据库数据2,string-int类型string connStr = server=localhost;database=seis_project;uid=seisprjs;pwd=seisprjs; SqlConnection myConn = new SqlConnection(connStr); string selStr = select 帐号,count(帐号) as 次数 from pub_log_read group by 帐号 order

13、by 帐号 asc; SqlCommand myCmd = myConn.CreateCommand(); myCmd.CommandText = selStr; myConn.Open(); SqlDataReader sdr = myCmd.ExecuteReader(CommandBehavior.CloseConnection); / Since the reader implements and IEnumerable, pass the reader directly into / the DataBindTable method with the name of the Colu

14、mn to be used as the XValue Chart1.DataBindTable(sdr, 帐号); sdr.Close(); myConn.Close();数据库绑定3-error?string connStr = server=localhost;database=seis_project;uid=seisprjs;pwd=seisprjs; SqlConnection myConn = new SqlConnection(connStr); string selStr = select 帐号,count(帐号) as 次数 from pub_log_read group

15、by 帐号 order by 帐号 asc; SqlCommand myCmd = myConn.CreateCommand(); myCmd.CommandText = selStr; myConn.Open(); / Set chart data source Chart1.DataSource = myCmd; / Set series members names for the X and Y values Chart1.SeriesSeries1.XValueMember = 帐号; Chart1.SeriesSeries1.YValueMembers = 次数; / Data bi

16、nd to the selected data source Chart1.DataBind(); myConn.Close();数据库4,只绑定ystring connStr = server=localhost;database=seis_project;uid=seisprjs;pwd=seisprjs; SqlConnection myConn = new SqlConnection(connStr); string selStr = select 序号 from pub_log_read order by 序号 asc; SqlCommand myCmd = myConn.Creat

17、eCommand(); myCmd.CommandText = selStr; myConn.Open(); SqlDataReader sdr = myCmd.ExecuteReader(CommandBehavior.CloseConnection); / Since the reader implements and IEnumerable, pass the reader directly into / the DataBindTable method with the name of the Column to be used as the XValue Chart1.Series0

18、.Points.DataBindY(sdr); sdr.Close(); myConn.Close();数据库5,绑定xystring connStr = server=localhost;database=seis_project;uid=seisprjs;pwd=seisprjs; SqlConnection myConn = new SqlConnection(connStr); string selStr = select 帐号,count(帐号) as 次数 from pub_log_read group by 帐号 order by 帐号 desc; SqlCommand myCm

19、d = myConn.CreateCommand(); myCmd.CommandText = selStr; myConn.Open(); SqlDataReader sdr = myCmd.ExecuteReader(CommandBehavior.CloseConnection); / Since the reader implements and IEnumerable, pass the reader directly into / the DataBindTable method with the name of the Column to be used as the XValu

20、e Chart1.Series0.Points.DataBindXY(sdr, 帐号,sdr,次数); sdr.Close(); myConn.Close();数据库6,支持显示参数/ Resolve the address to the Access database string fileNameString = this.MapPath(.); fileNameString += .datachartdata.mdb; / Initialize a connection string string myConnectionString = PROVIDER=Microsoft.Jet.O

21、LEDB.4.0;Data Source= + fileNameString; / Define the database query string mySelectQuery=SELECT * FROM REPSALES WHERE Year=2004; / Create a database connection object using the connection string OleDbConnection myConnection = new OleDbConnection(myConnectionString); / Create a database command on th

22、e connection using query OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection); / Open the connection myCommand.Connection.Open(); / Create a database reader OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); / Since the reader implements and IEnume

23、rable, pass the reader directly into / the DataBind method with the name of the Columns assigned to the appropriate property Chart1.SeriesSeries1.Points.DataBind( myReader, Name, Sales, Tooltip=Year, Label=CommissionsC2); / Close the reader and the connection myReader.Close(); myConnection.Close();数

24、据库7,支持多line/ Resolve the address to the Access database string fileNameString = this.MapPath(.); fileNameString += .datachartdata.mdb; / Initialize a connection string string myConnectionString = PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source= + fileNameString; / Define the database query string mySel

25、ectQuery=SELECT * FROM REPSALES; / Create a database connection object using the connection string OleDbConnection myConnection = new OleDbConnection(myConnectionString); / Create a database command on the connection using query OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);

26、 / Open the connection myCommand.Connection.Open(); / Create a database reader OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); / Data bind chart to a table where all rows are grouped in series by the Name column Chart1.DataBindCrossTable( myReader, Name, Year, Sales, Label=CommissionsC); / Close the reader and the connection myReader.Close(); myConnection

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1