![c#-ms-chart-控件使用方法匯總(附統(tǒng)計(jì)圖)_第1頁(yè)](http://file4.renrendoc.com/view/53570ea19da71db486239825e9735497/53570ea19da71db486239825e97354971.gif)
![c#-ms-chart-控件使用方法匯總(附統(tǒng)計(jì)圖)_第2頁(yè)](http://file4.renrendoc.com/view/53570ea19da71db486239825e9735497/53570ea19da71db486239825e97354972.gif)
![c#-ms-chart-控件使用方法匯總(附統(tǒng)計(jì)圖)_第3頁(yè)](http://file4.renrendoc.com/view/53570ea19da71db486239825e9735497/53570ea19da71db486239825e97354973.gif)
![c#-ms-chart-控件使用方法匯總(附統(tǒng)計(jì)圖)_第4頁(yè)](http://file4.renrendoc.com/view/53570ea19da71db486239825e9735497/53570ea19da71db486239825e97354974.gif)
![c#-ms-chart-控件使用方法匯總(附統(tǒng)計(jì)圖)_第5頁(yè)](http://file4.renrendoc.com/view/53570ea19da71db486239825e9735497/53570ea19da71db486239825e97354975.gif)
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、精選優(yōu)質(zhì)文檔傾情為你奉上精選優(yōu)質(zhì)文檔傾情為你奉上專心專注專業(yè)專心專注專業(yè)精選優(yōu)質(zhì)文檔傾情為你奉上專心專注專業(yè)第一個(gè)簡(jiǎn)單的chart:創(chuàng)建曲線圖 chart1.Series.Clear(); Series series = new Series(Spline); series.ChartType = SeriesChartType.Spline; series.BorderWidth = 3; series.ShadowOffset = 2; / Populate new series with data series.Points.AddY(67); series.Points.AddY(57
2、); 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);同時(shí)顯示2條曲線/ Populate series with random dataRandom random = new Random();for (int
3、pointIndex = 0; pointIndex 10;pointIndex+)Chart1.SeriesSeries1.Points.AddY(random.Next(45, 95);Chart1.SeriesSeries2.Points.AddY(random.Next(5, 75);/ Set series chart typeChart1.SeriesSeries1.ChartType = SeriesChartType.Line;Chart1.SeriesSeries2.ChartType = SeriesChartType.Spline;/ Set point labelsCh
4、art1.SeriesSeries1.IsValueShownAsLabel = true;Chart1.SeriesSeries2.IsValueShownAsLabel = true;/ Enable X axis marginChart1.ChartAreasChartArea1.AxisX.IsMarginVisible = true;/ Enable 3D, and show data point marker linesChart1.ChartAreasChartArea1.Area3DStyle.Enable3D = true;Chart1.SeriesSeries1ShowMa
5、rkerLines = True;Chart1.SeriesSeries2ShowMarkerLines = True;顯示column類型圖,柱狀圖/ Create new data series and set its visual attributesChart1.Series.Clear();Series series = new Series(FlowRead);series.ChartType = SeriesChartType.Column;series.BorderWidth = 3;series.ShadowOffset = 2;/ Populate new series w
6、ith dataseries.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 collectionChart1.Series.Add(series);很多點(diǎn),效率還可以/ Fill series datadouble yV
7、alue = 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 typeChart1.SeriesSeries1.ChartType = SeriesChartType.FastLine; 日期,xy類型/ Create a new rand
8、om number generatorRandom rnd = new Random();/ Data points X value is using current dateDateTime date = DateTime.Now.Date;/ Add points to the stock chart seriesfor (int index = 0; index 10; index+)Chart1.SeriesSeries1.Points.AddXY(date,/ X value is a daternd.Next(40,50); /Close Y value/ Add 1 day to
9、 our X valuedate = date.AddDays(1);int-int的xy數(shù)據(jù)繪圖/ Create a new random number generatorRandom rnd = new Random();/ Add points to the stock chart seriesfor (int index = 0; index 10; index+)Chart1.SeriesSeries1.Points.AddXY(rnd.Next(10,90),/ X value is a daternd.Next(40,50); /Close Y value數(shù)據(jù)庫(kù)數(shù)據(jù),dateti
10、me-int類型 Chart1.Series.Clear(); OleDbConnection conn = new OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Application.StartupPath + db.mdb + ;Persist Security Info=False); OleDbCommand cmd = conn.CreateCommand(); conn.Open(); cmd.CommandText = select 時(shí)間,序號(hào) from pub_log_read order by
11、 序號(hào) asc; /DataSet ds = new DataSet(); /OleDbDataAdapter da = new OleDbDataAdapter(); /da.SelectCommand = cmd; /da.Fill(ds, tbscore); OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Chart1.DataBindTable(dr, 時(shí)間); dr.Close();數(shù)據(jù)庫(kù)數(shù)據(jù)2,string-int類型 Chart1.Series.Clear(); OleDbConne
12、ction conn = new OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Application.StartupPath + db.mdb + ;Persist Security Info=False); OleDbCommand cmd = conn.CreateCommand(); conn.Open(); cmd.CommandText = select 賬號(hào),count(賬號(hào)) as 次數(shù) from pub_log_read group by 賬號(hào) order by 賬號(hào) asc; /DataSet
13、 ds = new DataSet(); /OleDbDataAdapter da = new OleDbDataAdapter(); /da.SelectCommand = cmd; /da.Fill(ds, tbscore); OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Chart1.DataBindTable(dr, 賬號(hào)); dr.Close();數(shù)據(jù)庫(kù)綁定3-string-int型 Chart1.Series.Clear(); Chart1.Series.Add(Series1);
14、OleDbConnection conn = new OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Application.StartupPath + db.mdb + ;Persist Security Info=False); OleDbCommand cmd = conn.CreateCommand(); cmd.CommandText = select 賬號(hào),count(賬號(hào)) as 次數(shù) from pub_log_read group by 賬號(hào) order by 賬號(hào) asc; conn.Open()
15、; DataSet ds = new DataSet(); OleDbDataAdapter da = new OleDbDataAdapter(); da.SelectCommand = cmd; da.Fill(ds, tbscore); Chart1.DataSource = ds; Chart1.SeriesSeries1.XValueMember = 賬號(hào); Chart1.SeriesSeries1.YValueMembers = 次數(shù); / Data bind to the selected data source Chart1.DataBind(); conn.Close();數(shù)
16、據(jù)庫(kù)4,只綁定y Chart1.Series.Clear(); Chart1.Series.Add(序號(hào)); OleDbConnection conn = new OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Application.StartupPath + db.mdb + ;Persist Security Info=False); OleDbCommand cmd = conn.CreateCommand(); conn.Open(); cmd.CommandText = select 序號(hào) from p
17、ub_log_read order by 序號(hào) asc; /DataSet ds = new DataSet(); /OleDbDataAdapter da = new OleDbDataAdapter(); /da.SelectCommand = cmd; /da.Fill(ds, tbscore); OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Chart1.Series0.Points.DataBindY(dr); dr.Close();數(shù)據(jù)庫(kù)5,綁定xy Chart1.Series.Cl
18、ear(); Chart1.Series.Add(序號(hào)); OleDbConnection conn = new OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Application.StartupPath + db.mdb + ;Persist Security Info=False); OleDbCommand cmd = conn.CreateCommand(); conn.Open(); cmd.CommandText = select 賬號(hào),count(賬號(hào)) as 次數(shù) from pub_log_re
19、ad group by 賬號(hào) order by 賬號(hào) desc; /DataSet ds = new DataSet(); /OleDbDataAdapter da = new OleDbDataAdapter(); /da.SelectCommand = cmd; /da.Fill(ds, tbscore); OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Chart1.Series0.Points.DataBindXY(dr,賬號(hào),dr,次數(shù)); dr.Close();數(shù)據(jù)庫(kù)6,支持顯示參數(shù)
20、Chart1.Series.Clear(); Chart1.Series.Add(S1); OleDbConnection conn = new OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Application.StartupPath + db.mdb + ;Persist Security Info=False); OleDbCommand cmd = conn.CreateCommand(); conn.Open(); cmd.CommandText = SELECT * FROM REPSALES WH
21、ERE Year=2004; /DataSet ds = new DataSet(); /OleDbDataAdapter da = new OleDbDataAdapter(); /da.SelectCommand = cmd; /da.Fill(ds, tbscore); OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Chart1.Series0.Points.DataBind(dr, name, sales, Tooltip=Year, Label=CommissionsC2); dr.C
22、lose();數(shù)據(jù)庫(kù)7,支持多l(xiāng)ine Chart1.Series.Clear(); Chart1.Series.Add(S1); OleDbConnection conn = new OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data Source= + Application.StartupPath + db.mdb + ;Persist Security Info=False); OleDbCommand cmd = conn.CreateCommand(); conn.Open(); cmd.CommandText = SELEC
23、T * FROM REPSALES; /DataSet ds = new DataSet(); /OleDbDataAdapter da = new OleDbDataAdapter(); /da.SelectCommand = cmd; /da.Fill(ds, tbscore); OleDbDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); Chart1.DataBindCrossTable(dr, Name, Year, Sales, Label=CommissionsC); dr.Close();數(shù)據(jù)庫(kù)
24、8,按照行添加數(shù)據(jù)/ Resolve the address to the Access database stringfileNameString = this.MapPath(.);fileNameString += .datachartdata.mdb; /Initialize a connectionstring stringmyConnectionString = PROVIDER=Microsoft.Jet.OLEDB.4.0;DataSource= + fileNameString; / Definethe databasequery stringmySelectQuery=SE
25、LECT * FROM SALESCOUNTS; / Createa database connection object using the connectionstringOleDbConnection myConnection = newOleDbConnection(myConnectionString); / Create adatabase command on the connection usingquery OleDbCommandmyCommand = new OleDbCommand(mySelectQuery, myConnection); / Open theconn
26、ectionmyCommand.Connection.Open(); /Initializes a new instance of the OleDbDataAdapter classOleDbDataAdapter myDataAdapter = new OleDbDataAdapter();myDataAdapter.SelectCommand = myCommand; /Initializes a new instance of the DataSet class DataSetmyDataSet = new DataSet(); / Addsrows in the DataSetmyD
27、ataAdapter.Fill(myDataSet,Query);foreach(DataRow row in myDataSet.TablesQuery.Rows) / For each Row add a new seriesstring seriesName = rowSalesRep.ToString();Chart1.Series.Add(seriesName);Chart1.SeriesseriesName.ChartType = SeriesChartType.Line;Chart1.SeriesseriesName.BorderWidth = 2;for(int colInde
28、x = 1; colIndex myDataSet.TablesQuery.Columns.Count; colIndex+)/ For each column (column 1 and onward) add the value as apointstring columnName =myDataSet.TablesQuery.ColumnscolIndex.ColumnName;int YVal = (int) rowcolumnName;Chart1.SeriesseriesName.Points.AddXY(columnName, YVal); DataGrid.DataSource
29、 = myDataSet;DataGrid.DataBind(); / Closesthe connection to the data source. This is the preferred / method ofclosing any open connection.myCommand.Connection.Close();使用xml數(shù)據(jù)/ resolve the address to the XML document stringfileNameString = this.MapPath(.); stringfileNameSchema = this.MapPath(.);fileN
30、ameString += .datadata.xml;fileNameSchema += .datadata.xsd; /Initializes a new instance of the DataSet class DataSetcustDS = new DataSet(); / Read XMLschema into the DataSet.custDS.ReadXmlSchema( fileNameSchema ); / ReadXML schema and data into the DataSet.custDS.ReadXml( fileNameString ); /Initiali
31、zes a new instance of the DataView class DataViewfirstView = new DataView(custDS.Tables0); / Sincethe DataView implements and IEnumerable, pass the reader directlyinto / theDataBindTable method with the name of the column used for the Xvalue.Chart1.DataBindTable(firstView, Name);使用excel數(shù)據(jù)/ resolve t
32、he address to the Excel file stringfileNameString = this.MapPath(.);fileNameString += .dataExcelData.xls; / Createconnection object by using the preceding connection string. string sConn= Provider=Microsoft.Jet.OLEDB.4.0;Data Source= +fileNameString + ;Extended Properties=Excel8.0;HDR=YES;OleDbConne
33、ction myConnection = new OleDbConnection( sConn );myConnection.Open(); / Thecode to follow uses a SQL SELECT command to display the data fromthe worksheet. / Createnew OleDbCommand to return data from worksheet. OleDbCommandmyCommand = new OleDbCommand( Select * From data1$A1:E25,myConnection ); / c
34、reatea databasereaderOleDbDataReader myReader =myCommand.ExecuteReader(CommandBehavior.CloseConnection); /Populate the chart with data in the fileChart1.DataBindTable(myReader, HOUR); / closethe reader and the connectionmyReader.Close();myConnection.Close();使用csv數(shù)據(jù)/ Filename of the CSV file string f
35、ile= DataFile.csv; / Getthe path of the CSV file string path= this.MapPath(.); path +=.data; / Createa select statement and a connection string. stringmySelectQuery = Select * from + file; stringConStr = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=+path+ ;Extended Properties=Text;HDR=No;FMT=Delimit
36、ed;OleDbConnection myConnection = new OleDbConnection(ConStr); / Createa database command on the connection using query OleDbCommandmyCommand = new OleDbCommand(mySelectQuery, myConnection); / Openthe connection and create the readermyCommand.Connection.Open();OleDbDataReader myReader =myCommand.Exe
37、cuteReader(CommandBehavior.CloseConnection); / Column1 is a time value, column 2 is a double / Databindthe reader to the chart using the DataBindXY methodChart1.Series0.Points.DataBindXY(myReader, 1, myReader,2); / Closeconnection and data readermyReader.Close();myConnection.Close();數(shù)組繪圖/ Initialize
38、 an array of doublesdouble yval = 2, 6, 4, 5, 3 ;/ Initialize an array of stringsstring xval = Peter, Andrew, Julie, Mary, Dave ;/ Bind the double array to the Y axis points of the Default dataseriesChart1.SeriesSeries1.Points.DataBindXY(xval, yval);數(shù)據(jù)庫(kù)9,dataview/ Resolve the address to the Access d
39、atabase stringfileNameString = this.MapPath(.);fileNameString += .datachartdata.mdb; /Initialize a connectionstring stringmyConnectionString = PROVIDER=Microsoft.Jet.OLEDB.4.0;DataSource= + fileNameString; / Definethe databasequery stringmySelectQuery=SELECT * FROM REPS; / Createa database connectio
40、n object using the connectionstringOleDbConnection myConnection = newOleDbConnection(myConnectionString); / Create adatabase command on the connection usingquery OleDbCommandmyCommand = new OleDbCommand(mySelectQuery, myConnection); / Open theconnectionmyCommand.Connection.Open(); /Initializes a new
41、 instance of the OleDbDataAdapter classOleDbDataAdapter custDA = new OleDbDataAdapter();custDA.SelectCommand = myCommand; /Initializes a new instance of the DataSet class DataSetcustDS = new DataSet(); / Addsrows in the DataSetcustDA.Fill(custDS, Customers); /Initializes a new instance of the DataVi
42、ew class DataViewfirstView = new DataView(custDS.Tables0); / Sincethe DataView implements IEnumerable, pass the dataview directlyinto/ the DataBind method with thename of the Columns selected in thequeryChart1.SeriesDefault.Points.DataBindXY(firstView,Name,firstView, Sales); / Closesthe connection to the data source. This is the preferred/ method of closing any openconnection.myCommand.Connection.Close();指定坐標(biāo)軸的數(shù)據(jù)顯示范圍/ Create a new random number generatorRandom rnd = new Random();/ Add points
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 木材運(yùn)輸時(shí)間保障合同
- 三農(nóng)產(chǎn)品包裝與儲(chǔ)存方案設(shè)計(jì)
- 生產(chǎn)流程標(biāo)準(zhǔn)化與持續(xù)改進(jìn)實(shí)踐
- 食品飲料行業(yè)品質(zhì)控制與安全保障指南
- 駕校場(chǎng)地出租合同
- 場(chǎng)調(diào)查委托合同協(xié)議書
- 冷卻塔填料采購(gòu)合同
- 全新攪拌樁合同
- 2025年河南貨運(yùn)從業(yè)資格考試模擬考試題庫(kù)答案大全
- 小學(xué)二年級(jí)數(shù)學(xué)上冊(cè)口算筆算天天練
- 新版ISO22301BCM體系手冊(cè)
- 55項(xiàng)臨床護(hù)理技術(shù)操作標(biāo)準(zhǔn)(49-55項(xiàng))
- 中國(guó)主要蜜源植物蜜源花期和分布知識(shí)
- 電化學(xué)免疫傳感器的應(yīng)用
- 數(shù)據(jù)中心基礎(chǔ)知識(shí)培訓(xùn)-2024鮮版
- 第4課+中古時(shí)期的亞洲(教學(xué)設(shè)計(jì))-【中職專用】《世界歷史》(高教版2023基礎(chǔ)模塊)
- 保障性住房建設(shè)資金來(lái)源與運(yùn)作機(jī)制
- 金點(diǎn)子活動(dòng)總結(jié)匯報(bào)
- 原料驗(yàn)收標(biāo)準(zhǔn)知識(shí)培訓(xùn)課件
- 江蘇春節(jié)風(fēng)俗 南京夫子廟、鹽水鴨與昆曲
- Unit4MyfamilyStorytime(課件)人教新起點(diǎn)英語(yǔ)三年級(jí)下冊(cè)
評(píng)論
0/150
提交評(píng)論