您好,登錄后才能下訂單哦!
ASP.NET 2.0中如何使用OWC組件,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。
1、ASP.NET 2.0中的OWC組件生成柱狀圖
//創(chuàng)建X坐標(biāo)的值,表示月份 int[] Month = new int[3] { 1, 2, 3 }; //創(chuàng)建Y坐標(biāo)的值,表示銷售額 double[] Count = new double[3] { 120,240,220}; //創(chuàng)建圖表空間 ChartSpace mychartSpace = new ChartSpace(); //在圖表空間內(nèi)添加一個(gè)圖表對(duì)象 ChChart mychart = mychartSpace.Charts.Add(0); //設(shè)置圖表類型,本例使用柱形 mychart.Type = ChartChartTypeEnum. chChartTypeColumnClustered; //設(shè)置圖表的一些屬性 //是否需要圖例 mychart.HasLegend = true; //是否需要主題 mychart.HasTitle = true; //主題內(nèi)容 mychart.Title.Caption = "一季度總結(jié)"; //設(shè)置x,y坐標(biāo) mychart.Axes[0].HasTitle = true; mychart.Axes[0].Title.Caption = "月份"; mychart.Axes[1].HasTitle = true; mychart.Axes[1].Title.Caption = "銷量"; //添加三個(gè)圖表塊 mychart.SeriesCollection.Add(0); mychart.SeriesCollection.Add(0); mychart.SeriesCollection.Add(0); //設(shè)置圖表塊的屬性 //標(biāo)題 mychart.SeriesCollection[0].Caption = "一月份"; //X坐標(biāo)的值屬性 mychart.SeriesCollection[0].SetData (ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Month[0]); //y坐標(biāo)的值屬性 mychart.SeriesCollection[0].SetData (ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Count[0]); //第二個(gè)塊 mychart.SeriesCollection[1].Caption = "二月份"; //X坐標(biāo)的值屬性 mychart.SeriesCollection[1].SetData (ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Month[1]); //y坐標(biāo)的值屬性 mychart.SeriesCollection[1].SetData (ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Count[1]); //第三個(gè)塊 mychart.SeriesCollection[2].Caption = "三月份"; //X坐標(biāo)的值屬性 mychart.SeriesCollection[2].SetData (ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Month[2]); //y坐標(biāo)的值屬性 mychart.SeriesCollection[2].SetData(ChartDimensionsEnum. chDimValues, (int)ChartSpecialDataSourcesEnum.chDataLiteral, Count[2]); //生成圖片 mychartSpace.ExportPicture(Server.MapPath(".") + @"\test. jpg", "jpg", 500, 450); //加載圖片 Image1.ImageUrl = Server.MapPath(".") + @"\test.jpg"; }
2、ASP.NET 2.0中OWC組件生成餅狀圖
protected void Page_Load(object sender, EventArgs e) { //創(chuàng)建X坐標(biāo)的值,表示月份 int[] Month ={ 1, 2, 3 }; //創(chuàng)建Y坐標(biāo)的值,表示銷售額 double[] Count ={ 120, 240, 220 }; string strDataName = ""; string strData = ""; //創(chuàng)建圖表空間 ChartSpace mychartSpace = new ChartSpace(); //在圖表空間內(nèi)添加一個(gè)圖表對(duì)象 ChChart mychart = mychartSpace.Charts.Add(0); //設(shè)置每塊餅的數(shù)據(jù) for (int i = 0; i < Count.Length; i++) { strDataName += Month[i] + "\t"; strData += Count[i].ToString() + "\t"; } //設(shè)置圖表類型,本例使用柱形 mychart.Type = ChartChartTypeEnum.chChartTypePie; //設(shè)置圖表的一些屬性 //是否需要圖例 mychart.HasLegend = true; //是否需要主題 mychart.HasTitle = true; //主題內(nèi)容 mychart.Title.Caption = "一季度總結(jié)"; //添加圖表塊 mychart.SeriesCollection.Add(0); //設(shè)置圖表塊的屬性 //分類屬性 mychart.SeriesCollection[0].SetData (ChartDimensionsEnum.chDimCategories, (int)ChartSpecialDataSourcesEnum.chDataLiteral, strDataName); //值屬性 mychart.SeriesCollection[0].SetData (ChartDimensionsEnum.chDimValues, (int)ChartSpecialDataSourcesEnum. chDataLiteral, strData); //顯示百分比 ChDataLabels mytb= mychart.SeriesCollection[0]. DataLabelsCollection.Add(); mytb.HasPercentage = true; //生成圖片 mychartSpace.ExportPicture(Server.MapPath(".") + @"\test.gif", "gif", 500, 450); //加載圖片 Image1.ImageUrl = Server.MapPath(".") + @"\test.gif"; }
關(guān)于ASP.NET 2.0中如何使用OWC組件問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開,可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。