我整个下午都在谷歌上搜索一些相关的东西,但都无济于事,所以我希望你们中的一些人能帮助我。
我正在使用一个asp:wizard用户控件,它从用户那里收集各种值,并在最终的“结果页”上以表格的形式显示这些值。
我已经创建了一个单独的"GraphEngine“类,它接受一个Bool参数来决定要创建的图表类型(线条/堆叠柱)。
//T13 is selection of line/stacked column chart type.
public Chart GetChart(bool T13)
{
Chart chart = new Chart();
//define some shared properties no matter which ChartType.
chart.Width = 900;
chart.Height = 500;
chart.ChartAreas.Add("ChartArea1");
chart.Series.Add("Costs");
chart.Series.Add("Stages");
chart.Legends.Add("Legend1");
if (T13 == true)
{
//chart = charttype1 and add values from Dictionary<string, bool>
}
else
{
//chart = charttype2 and add values..............
}
return chart;
}然后,我在向导控件(acsx.cs文件)的最后一步调用GetChart。
GraphEngine GE = new GraphEngine(GraphData);
System.Web.UI.DataVisualization.Charting.Chart Chart = GE.GetChart(t13);
//What should I be saying here to render Chart as "Chart" rather than literal
LiteralGraph.Text = GE.GetChart(getSetGraphData, t13).ToString();我不确定如何呈现图表
.ascx页面上有一个ID为" Chart“的图表--不应该只填充从GE.GetChart(t13);返回的信息吗?
注意:如果我在用户控件向导步骤中创建/定义了所有的图表值和轴等,它会返回正常,但我需要分离图形生成,因为在ascx.cs文件中有很多代码行(验证等),所以我想将我的150多行从其中分离出来。这可能是做事情的“正确”方式吧?
提前谢谢。
发布于 2013-06-12 00:11:09
如果要返回实际的图表控件,则需要将其添加到窗体上的控件集合中。例如,将LiteralGraph而不是文本设置为面板,然后您可以这样做:
LiteralGraph.Controls.Add(GE.GetChart(getSetGraphData, t13));https://stackoverflow.com/questions/17048799
复制相似问题