以编程方式创建图表时出错 [英] getting error while creating chart programmatically

查看:63
本文介绍了以编程方式创建图表时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我是ASP World的新手
我正努力以编程方式创建图表.
谁能指出我正确的方向.
这是我的代码和错误

hi all
i am new to asp world
i am truing to create chart programmatically.
can any one point me in right direction.
here is my code and error

string strcon = ConfigurationManager.ConnectionStrings["gallup"].ConnectionString;
        //SqlConnection myConnection = new SqlConnection(strcon);
        string mystr = "select * from project where year='2010'";
        SqlDataAdapter da = new SqlDataAdapter(mystr, strcon);
        DataTable table = new DataTable();
        da.Fill(table);
        DataView dv = table.DefaultView;

        
        Chart trychart = new Chart();
        Series tryseries = new Series();
        ChartArea trychartarea = new ChartArea();
        //chart.Series[0].ChartType = SeriesChartType.Pie;
        trychart.ChartAreas.Add(trychartarea);
        trychart.Series.Add(tryseries);
        trychart.Series[0].ChartType = SeriesChartType.Column;
        trychart.Series["tryseries"].Points.DataBindXY(dv, "month", dv, "total_projects");


在"SeriesCollection"中找不到名称为"tryseries"的图表元素.

Thanks


A chart element with the name ''tryseries'' could not be found in the ''SeriesCollection''.

thanks

推荐答案

tryseries是对象而不是Series的名称.您从未为自己的系列取个名字.要给您的系列起个名字,您应该实例化以下内容:

tryseries is the object and not the name of the Series. You never gave a name to your series. To give your series a name, you should instantiate something like this:

Series tryseries = new Series();
Series tryseries = new Series("tryseries");



请查看MSDN以获取文档.

http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.series.aspx [



Look at MSDN for documentation.

http://msdn.microsoft.com/en-us/library/system.web.ui.datavisualization.charting.series.aspx[^]


这篇关于以编程方式创建图表时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆