原創(chuàng)|其它|編輯:郝浩|2010-05-11 11:09:19.000|閱讀 3983 次
概述:DevExpress的PivotGrid控件,無論是WinForm的XtraPivotGrid,還是WebForm的AspxPivotGrid,都能夠?qū)崿F(xiàn)強(qiáng)大的多維分析功能,完全可以當(dāng)成一個決策分析工具來使用,然而,美中不足的就是沒有關(guān)聯(lián)到圖形圖表Chart。雖然有了分析的結(jié)果,但是沒有圖形圖表更加直觀地表達(dá)效果。因此,在DevExpress 控件包使用方面有多年研究的慧都控件網(wǎng)愿把PivotGrid控件的使用心得分享給大家。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
DevExpress的PivotGrid控件,無論是WinForm的XtraPivotGrid,還是WebForm的AspxPivotGrid,都能夠?qū)崿F(xiàn)強(qiáng)大的多維分析功能,完全可以當(dāng)成一個決策分析工具來使用,然而,美中不足的就是沒有關(guān)聯(lián)到圖形圖表Chart。雖然有了分析的結(jié)果,但是沒有圖形圖表更加直觀地表達(dá)效果。因此,在DevExpress 控件包使用方面有多年研究的慧都控件網(wǎng)愿把PivotGrid控件的使用心得分享給大家。
為了把PivotGrid連接到Chart,首先利用PivotGrid自帶的編程接口獲取篩選屬性,形成交差表,再使用Office Web Control(OWC)來展示圖形。
OWC顯示圖形的例子
引用DLL
using OWC11;
//創(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();
//mychartSpace.DataSource = oleReader;
//mychartSpace.Border.DashStyle = ChartLineDashStyleEnum.chLineRoundDot;
//在圖表空間內(nèi)添加一個圖表對象
ChChart mychart = mychartSpace.Charts.Add(0);
mychart.Border.DashStyle = ChartLineDashStyleEnum.chLineSolid;
//設(shè)置每塊餅的數(shù)據(jù)
for (int i = 0; i < Count.Length; i++)
{
if (i != Count.Length - 1)
{
strDataName += Month[i] + "\t";
strData += Count[i].ToString() + "\t";
}
else
{
strDataName += Month[i];
strData += Count[i].ToString();
}
}
//設(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);
//mychart.Axes[1].Font.Bold = true;
mychart.Legend.Border.DashStyle = ChartLineDashStyleEnum.chLineDash;
//顯示百分比
ChDataLabels mytb = mychart.SeriesCollection[0].DataLabelsCollection.Add();
//mytb.HasPercentage = true;
//生成圖片
mychartSpace.ExportPicture(Server.MapPath(".") + @"\test.gif", "gif", 500, 450);
//加載圖片
顯示的效果圖
獲取Pivot各個區(qū)域Area的值
#region 獲取相應(yīng)Area內(nèi)容
protected System.Collections.Generic.ICollection<PivotGridField> GetFilterFields(ASPxPivotGrid _grid)
{
return GetFieldsByArea(_grid, DevExpress.XtraPivotGrid.PivotArea.FilterArea);
}
protected System.Collections.Generic.ICollection<PivotGridField> GetColumnFields(ASPxPivotGrid _grid)
{
return GetFieldsByArea(_grid, DevExpress.XtraPivotGrid.PivotArea.ColumnArea);
}
protected System.Collections.Generic.ICollection<PivotGridField> GetRowFields(ASPxPivotGrid _grid)
{
return GetFieldsByArea(_grid, DevExpress.XtraPivotGrid.PivotArea.RowArea);
}
protected System.Collections.Generic.ICollection<PivotGridField> GetDataFields(ASPxPivotGrid _grid)
{
return GetFieldsByArea(_grid, DevExpress.XtraPivotGrid.PivotArea.DataArea);
}
protected System.Collections.Generic.ICollection<PivotGridField> GetFieldsByArea(ASPxPivotGrid _grid, DevExpress.XtraPivotGrid.PivotArea _area)
{
System.Collections.Generic.List<PivotGridField> _list = new List<PivotGridField>();
foreach (DevExpress.Web.ASPxPivotGrid.PivotGridField _field in _grid.Fields)
{
if (_field.Area == _area)
{
_list.Add(_field);
}
}
return _list;
}
#endregion
是Windows和ASP.NET控件套包、IDE報表生成工具和企業(yè)應(yīng)用程序框架。長期占據(jù)著慧都科技控件銷量榜的第一位置。在慧都控件網(wǎng)的推動下,DXperience幫助中國軟件企業(yè)開發(fā)出很多優(yōu)秀的軟件產(chǎn)品 DXperience其產(chǎn)品的品牌、質(zhì)量,是全球公認(rèn)的。慧都控件網(wǎng)為 DXperience提供了全面的技術(shù)支持服務(wù),同時提供。
同時,慧都為DevExpress for .NET用戶量身打造了一款中文資源包,DevExpress 官方漢化資源 , 您只需極少花費便可獲得這套完整、專業(yè)的漢化資源,從而使您的產(chǎn)品實現(xiàn)全面漢化。
(慧都控件網(wǎng)版權(quán)所有,轉(zhuǎn)載請注明出處,否則追究法律責(zé)任)
標(biāo)簽:
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@ke049m.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)