使用OWC生成饼状图和柱状图
2007-11-03 20:36
381 查看
代码在.net 1.1 和OWC 10下面测试通过。
XValue类似于"a\tb\tc\td\t"
YValue类似于"1\t3\t6\t2\t"
一、生成柱状图
private void CreatChart()
public void ChartPie()
{
//创建一个图形容器对象
OWC10.ChartSpace objCSpace = new OWC10.ChartSpaceClass();
objCSpace.Border.Color="white";
//在图形容器中增加一个图形对象
OWC10.ChChart objChart = objCSpace.Charts.Add(0);
//将图形的类型设置为柱状图的一种
objChart.Type = OWC10.ChartChartTypeEnum.chChartTypePie3D;
//在图形对象中添加一个系列
objChart.SeriesCollection.Add(0);
string type =Request.QueryString["type"]==null?"":Request.QueryString["type"].ToString();
string date=Request.QueryString["date"]==null?"":Request.QueryString["date"].ToString();
string[] strData = esWapper.getChartData(type,date);
//string[] strData = new string[2];
//给定需要的数据
//数据
string YValue = strData[1];
//分类
string XValue = strData[0];
//给定系列的名字
objChart.SeriesCollection[0].SetData (OWC10.ChartDimensionsEnum.chDimCategories,
+ (int)OWC10.ChartSpecialDataSourcesEnum.chDataLiteral, XValue);
//给定值
objChart.SeriesCollection[0].SetData (OWC10.ChartDimensionsEnum.chDimValues,
+ (int)OWC10.ChartSpecialDataSourcesEnum.chDataLiteral, YValue);
objChart.Inclination=55;
//将第三个扇区抽离出来
//Explosion:返回或设置指定饼图或圆环图扇面的分离程度值。有效范围为 0 到 1000。分离程度值等于图表半径的百分比。
//objChart.SeriesCollection[0].Points[2].Explosion = 45;
//增加数据值标签
objChart.SeriesCollection[0].DataLabelsCollection.Add();
//分类名
//objChart.SeriesCollection[0].DataLabelsCollection[0].HasCategoryName=true;
//系列名
//objChart.SeriesCollection[0].DataLabelsCollection[0].HasSeriesName=true;
//设置图例边框颜色
//设置显示图例
objChart.HasLegend=true;
//设置图例的位置,必须先把图例的显示属性设置为true
objChart.Legend.Position = OWC10.ChartLegendPositionEnum.chLegendPositionBottom;
objChart.Legend.Border.Color="#FFFFFF";
objChart.Legend.Font.Size=20;
//显示各部分的数值
objChart.SeriesCollection[0].DataLabelsCollection[0].HasValue = false;
//设置饼状图中字体的大小
objChart.SeriesCollection[0].DataLabelsCollection[0].Font.Size=14;
//显示各部分的百分比
objChart.SeriesCollection[0].DataLabelsCollection[0].HasPercentage = true;
//Response.Write(DateTime.Now.ToLongDateString());
Response.BinaryWrite((Byte[])(objCSpace.GetPicture("gif",800, 500)));
//Response.End();
}
XValue类似于"a\tb\tc\td\t"
YValue类似于"1\t3\t6\t2\t"
一、生成柱状图
private void CreatChart()
public void ChartPie()
{
//创建一个图形容器对象
OWC10.ChartSpace objCSpace = new OWC10.ChartSpaceClass();
objCSpace.Border.Color="white";
//在图形容器中增加一个图形对象
OWC10.ChChart objChart = objCSpace.Charts.Add(0);
//将图形的类型设置为柱状图的一种
objChart.Type = OWC10.ChartChartTypeEnum.chChartTypePie3D;
//在图形对象中添加一个系列
objChart.SeriesCollection.Add(0);
string type =Request.QueryString["type"]==null?"":Request.QueryString["type"].ToString();
string date=Request.QueryString["date"]==null?"":Request.QueryString["date"].ToString();
string[] strData = esWapper.getChartData(type,date);
//string[] strData = new string[2];
//给定需要的数据
//数据
string YValue = strData[1];
//分类
string XValue = strData[0];
//给定系列的名字
objChart.SeriesCollection[0].SetData (OWC10.ChartDimensionsEnum.chDimCategories,
+ (int)OWC10.ChartSpecialDataSourcesEnum.chDataLiteral, XValue);
//给定值
objChart.SeriesCollection[0].SetData (OWC10.ChartDimensionsEnum.chDimValues,
+ (int)OWC10.ChartSpecialDataSourcesEnum.chDataLiteral, YValue);
objChart.Inclination=55;
//将第三个扇区抽离出来
//Explosion:返回或设置指定饼图或圆环图扇面的分离程度值。有效范围为 0 到 1000。分离程度值等于图表半径的百分比。
//objChart.SeriesCollection[0].Points[2].Explosion = 45;
//增加数据值标签
objChart.SeriesCollection[0].DataLabelsCollection.Add();
//分类名
//objChart.SeriesCollection[0].DataLabelsCollection[0].HasCategoryName=true;
//系列名
//objChart.SeriesCollection[0].DataLabelsCollection[0].HasSeriesName=true;
//设置图例边框颜色
//设置显示图例
objChart.HasLegend=true;
//设置图例的位置,必须先把图例的显示属性设置为true
objChart.Legend.Position = OWC10.ChartLegendPositionEnum.chLegendPositionBottom;
objChart.Legend.Border.Color="#FFFFFF";
objChart.Legend.Font.Size=20;
//显示各部分的数值
objChart.SeriesCollection[0].DataLabelsCollection[0].HasValue = false;
//设置饼状图中字体的大小
objChart.SeriesCollection[0].DataLabelsCollection[0].Font.Size=14;
//显示各部分的百分比
objChart.SeriesCollection[0].DataLabelsCollection[0].HasPercentage = true;
//Response.Write(DateTime.Now.ToLongDateString());
Response.BinaryWrite((Byte[])(objCSpace.GetPicture("gif",800, 500)));
//Response.End();
}
相关文章推荐
- 使用OWC生成饼状图和柱状图
- ASP.NET 2.0中OWC生成柱状图和饼状图
- ASP.NET 2.0中OWC生成柱状图和饼状图
- 使用jfreechart生成柱状图、折线图、和饼状图
- jfreechart应用_经典例题_生成饼状图、生成单组柱状图、生成多组柱状图、生成堆积柱状图...
- 使用jfreeChart生成柱状图,折线图,饼图等
- JFreeChart生成柱状图、饼状图、折线图详解
- ASP.NET 2.0中使用OWC生成图表
- 使用OWC生成数据分析图表
- iOS:使用贝塞尔曲线绘制图表(折线图、柱状图、饼状图)
- 使用JFreeChart生成柱状图,不做任何注释,只求应用,生成的柱状图放在D:\\fruit.jpg
- 生成各种比例图像--柱状图与饼状图 可粘贴直接使用
- 使用 jfreechart 生成 曲线、柱状图、饼状图、分布图 展示到JSP
- Wpf/Wp/Silverlight-Chart图表控件:柱状图、饼状图等使用汇总
- 使用JFreeChart生成柱状图实例(生成图片)
- 使用Highcharts结合PHP与Mysql生成饼状图
- WPF、Silverlight项目中使用柱状图、饼状图、折线图
- 使用Highcharts结合PHP与Mysql生成饼状图
- 使用Highcharts结合PHP与Mysql生成饼状图
- C#中使用GDI+实现饼状图和柱状图跟数据库联接显示数据的方法