using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Office.Interop.Owc11;
using System.Data.SqlClient;public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//声明对象
Microsoft.Office.Interop.Owc11.ChartSpace ThisChart = new Microsoft.Office.Interop.Owc11.ChartSpaceClass();
Microsoft.Office.Interop.Owc11.ChChart ThisChChart = ThisChart.Charts.Add(0);
//显示图例
ThisChChart.HasLegend = true;
//标题
ThisChChart.HasTitle = true;
ThisChChart.Title.Caption = "统计图";
//给定x,y轴图示说明
ThisChChart.Axes[0].HasTitle = true;
ThisChChart.Axes[1].HasTitle = true;
ThisChChart.Axes[0].Title.Caption = "月份";
ThisChChart.Axes[1].Title.Caption = "数量";
//图表类型
ThisChChart.Type = Microsoft.Office.Interop.Owc11.ChartChartTypeEnum.chChartTypeBarStacked; //旋转
ThisChChart.Rotation = 360;
ThisChChart.Inclination = 5; ThisChChart.Overlap = 100;
string strSeriesName = "图例";
string strCategory = "0.5" + "\t" + "0.7" + "\t" + "0.9" + "\t" + "0.10"+ "\t";
string strValue= "0.7" + "%" + '\t' + strSeriesName + "" + "0.8" +"%"+ '\t' + strSeriesName + "" + "0.4" +"%"+ '\t' + strSeriesName + "" + "1" + "%"+'\t';
Microsoft.Office.Interop.Owc11.ChSeries ThisChSeries = ThisChChart.SeriesCollection.Add(0);
ThisChSeries.Ungroup(true);
Microsoft.Office.Interop.Owc11.ChAxis seaxes = ThisChChart.Axes.Add(ThisChSeries.get_Scalings(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues));
seaxes.Position = Microsoft.Office.Interop.Owc11.ChartAxisPositionEnum.chAxisPositionRight;
seaxes.HasMajorGridlines = false;
seaxes.NumberFormat = "0.00%"; /**/////给定series的名字 ThisChSeries.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimSeriesNames, Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral.GetHashCode(), strSeriesName);
//给定分类
ThisChSeries.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimCategories, Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral.GetHashCode(), strCategory);
//给定值
ThisChSeries.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues, Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral.GetHashCode(), strValue); //添加图例的数据标记
ThisChSeries.DataLabelsCollection.Add();
ThisChSeries.DataLabelsCollection[0].HasValue = true;
ThisChSeries.DataLabelsCollection[0].HasPercentage = true;
try
{ ThisChart.ExportPicture(Server.MapPath("chart.gif"),"gif",600,350);
Response.Write( "<IMG SRC='" + Server.MapPath("chart.gif") + "'/>");
}
catch(Exception ee)
{}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.Office.Interop.Owc11;
using System.Data.SqlClient;public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//声明对象
Microsoft.Office.Interop.Owc11.ChartSpace ThisChart = new Microsoft.Office.Interop.Owc11.ChartSpaceClass();
Microsoft.Office.Interop.Owc11.ChChart ThisChChart = ThisChart.Charts.Add(0);
//显示图例
ThisChChart.HasLegend = true;
//标题
ThisChChart.HasTitle = true;
ThisChChart.Title.Caption = "统计图";
//给定x,y轴图示说明
ThisChChart.Axes[0].HasTitle = true;
ThisChChart.Axes[1].HasTitle = true;
ThisChChart.Axes[0].Title.Caption = "月份";
ThisChChart.Axes[1].Title.Caption = "数量";
//图表类型
ThisChChart.Type = Microsoft.Office.Interop.Owc11.ChartChartTypeEnum.chChartTypeBarStacked; //旋转
ThisChChart.Rotation = 360;
ThisChChart.Inclination = 5; ThisChChart.Overlap = 100;
string strSeriesName = "图例";
string strCategory = "0.5" + "\t" + "0.7" + "\t" + "0.9" + "\t" + "0.10"+ "\t";
string strValue= "0.7" + "%" + '\t' + strSeriesName + "" + "0.8" +"%"+ '\t' + strSeriesName + "" + "0.4" +"%"+ '\t' + strSeriesName + "" + "1" + "%"+'\t';
Microsoft.Office.Interop.Owc11.ChSeries ThisChSeries = ThisChChart.SeriesCollection.Add(0);
ThisChSeries.Ungroup(true);
Microsoft.Office.Interop.Owc11.ChAxis seaxes = ThisChChart.Axes.Add(ThisChSeries.get_Scalings(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues));
seaxes.Position = Microsoft.Office.Interop.Owc11.ChartAxisPositionEnum.chAxisPositionRight;
seaxes.HasMajorGridlines = false;
seaxes.NumberFormat = "0.00%"; /**/////给定series的名字 ThisChSeries.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimSeriesNames, Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral.GetHashCode(), strSeriesName);
//给定分类
ThisChSeries.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimCategories, Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral.GetHashCode(), strCategory);
//给定值
ThisChSeries.SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues, Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral.GetHashCode(), strValue); //添加图例的数据标记
ThisChSeries.DataLabelsCollection.Add();
ThisChSeries.DataLabelsCollection[0].HasValue = true;
ThisChSeries.DataLabelsCollection[0].HasPercentage = true;
try
{ ThisChart.ExportPicture(Server.MapPath("chart.gif"),"gif",600,350);
Response.Write( "<IMG SRC='" + Server.MapPath("chart.gif") + "'/>");
}
catch(Exception ee)
{}
}
}
http://www.isoftone.com/product/ichart/