1、首先下載owc11 COM組件
http://www.microsoft.com/downloads/details.aspx?FamilyID=7287252c-402e-4f72-97a5-e0fd290d4b76&displaylang=en
2、注冊owc11
在工程中添加 C:/Program Files/Common Files/Microsoft Shared/Web Components/11 文件下的owc11.dll引用
3、在工程中添加
using OWC11;
4、開始coding 舉例如下:
代碼如下:
public class ChartFactory
{
public ChartFactory()
{
InitTypeMap();
//
// TODO: 在此處添加構造函數邏輯
//
}
protected System.Web.UI.WebControls.Image imgHondaLineup;
private string[] chartCategoriesArr;
private string[] chartValuesArr;
private OWC11.ChartChartTypeEnum chartType = OWC11.ChartChartTypeEnum.chChartTypeColumn3D;//默認值
private static Hashtable chartMap = new Hashtable();
private static string chartTypeCh = "垂直柱狀圖" ;
private static string chartTitle = "";
private void InitTypeMap()
{
chartMap.Clear();
OWC11.ChartChartTypeEnum[] chartTypes = new OWC11.ChartChartTypeEnum[]{ ChartChartTypeEnum.chChartTypeColumnClustered,
ChartChartTypeEnum.chChartTypeColumn3D,
ChartChartTypeEnum.chChartTypeBarClustered,
ChartChartTypeEnum.chChartTypeBar3D,
ChartChartTypeEnum.chChartTypeArea,
ChartChartTypeEnum.chChartTypeArea3D,
ChartChartTypeEnum.chChartTypeDoughnut,
ChartChartTypeEnum.chChartTypeLineStacked,
ChartChartTypeEnum.chChartTypeLine3D,
ChartChartTypeEnum.chChartTypeLineMarkers,
ChartChartTypeEnum.chChartTypePie,
ChartChartTypeEnum.chChartTypePie3D,
ChartChartTypeEnum.chChartTypeRadarSmoothLine,
ChartChartTypeEnum.chChartTypeSmoothLine};
string[] chartTypesCh = new string [] {"垂直柱狀統計圖","3D垂直柱狀統計圖","水平柱狀統計圖","3D水平柱狀統計圖","區域統計圖","3D區域統計圖","中空餅圖","折線統計圖","3D折線統計圖","折線帶點統計圖","餅圖","3D餅圖","網狀統計圖","弧線統計圖"};
for(int i=0;i<chartTypes.Length;i++)
{
chartMap.Add(chartTypesCh[i],chartTypes[i]);
}
}
public ChartSpaceClass BuildCharts ()
{
string chartCategoriesStr = String.Join ("/t", chartCategoriesArr);
string chartValuesStr = String.Join ("/t", chartValuesArr);
OWC11.ChartSpaceClass oChartSpace = new OWC11.ChartSpaceClass ();
// ------------------------------------------------------------------------
// Give pie and doughnut charts a legend on the bottom. For the rest of
// them let the control figure it out on its own.
// ------------------------------------------------------------------------
chartType = (ChartChartTypeEnum)chartMap[chartTypeCh];
新聞熱點
疑難解答
圖片精選