ASP.NET 2.0中使用OWC生成图表(2)
2、生成饼状图
protected void page_load(object sender, eventargs e)
{
//创建x坐标的值,表示月份
int[] month ={ 1, 2, 3 };
//创建y坐标的值,表示销售额
double[] count ={ 120, 240, 220 };
string strdataname = "";
string strdata = "";
//创建图表空间
chartspace mychartspace = new chartspace();
//在图表空间内添加一个图表对象
chchart mychart = mychartspace.charts.add(0);
//设置每块饼的数据
for (int i = 0; i < count.length; i++)
{
strdataname += month[i] + " ";
strdata += count[i].tostring() + " ";
}
//设置图表类型,本例使用柱形
mychart.type = chartcharttypeenum.chcharttypepie;
//设置图表的一些属性
//是否需要图例
mychart.haslegend = true;
//是否需要主题
mychart.hastitle = true;
//主题内容
mychart.title.caption = "一季度总结";
//添加图表块
mychart.seriescollection.add(0);
//设置图表块的属性
//分类属性
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(".") + @" est.gif", "gif", 500, 450);
//加载图片
image1.imageurl = server.mappath(".") + @" est.gif";
}
|
Tag: 图表
文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。