本文介绍了asp.net中的图表控件示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! HI先生, 你能举一个关于图表控件和系列属性的完整例子。解决方案 使用以下演示进行图表控制..... on .aspx page: <%@ 注册 汇编 = System.Web.DataVisualization,Version = 4.0.0.0,Culture =中性,PublicKeyToken = 31bf3856ad364e35 命名空间 = System.Web.UI.DataVisualization .Charting TagPrefix = asp %> < !DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd > < html xmlns = http: //www.w3.org/1999/xhtml\"> < head runat = server > < title> < / title > < / head > < body> < form id = form1 runat = server > < div> < asp:图表ID = chartForMarks runat = server Width = 500px > < Series> < asp:Series Name = NumberInMath XValueMember = 名称 YValueMembers = NumberInMath IsVisibleInLegend = true ChartType = Pie > < / asp:系列 > < / 系列 > < ChartAreas> < asp:ChartArea Name = ChartArea1 Area3DStyle-Enable3D = true > < AxisX LineColor = DarkGreen > < MajorGrid LineColor = LightGreen /> < / AxisX > < AxisY LineColor = DarkGreen > < MajorGrid LineColor = LightGreen /> ; < / AxisY > < Area3DStyle Enable3D = True > < / Area3DStyle > < / asp:ChartArea > < / ChartAreas > < Legends> < asp:Legend> < / asp:图例 > < / 传奇 > < / asp:Chart > < / div > < / 表格 > < / body > < / html > on .cs page: protected void Page_Load( object sender,EventArgs e) { if (!IsPostBack) { CreatePIChartForMarks(); } } 私有 void CreatePIChartForMarks( ) { var table = new DataTable(); table.Columns.Add( 名称, typeof ( string )); table.Columns.Add( NumberInMath, typeof ( long )); table.Columns.Add( Lbl); var row = table.NewRow(); 行[ 名称] = Girijesh; 行[ NumberInMath] = 33 ; table.Rows.Add(row); row = table.NewRow(); 行[ 名称] = Rajesh; 行[ NumberInMath] = 09 ; table.Rows.Add(row); row = table.NewRow(); 行[ 名称] = Pallav; row [ NumberInMath] = 98 ; table.Rows.Add(row); row = table.NewRow(); 行[ 名称] = Sharath; 行[ NumberInMath] = 37 ; table.Rows.Add(row); row = table.NewRow(); 行[ 名称] = Mahesh; 行[ NumberInMath] = 59 ; table.Rows.Add(row); row = table.NewRow(); 行[ 名称] = Lokesh; row [ NumberInMath] = 78 ; table.Rows.Add(row); chartForMarks.DataSource = table; chartForMarks.DataBind(); } JMD: - ) HI sir,Can u give one complete example on chart control and series properties. 解决方案 use following demo for chart control.....on .aspx page:<%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <div> <asp:Chart ID="chartForMarks" runat="server" Width="500px"> <Series> <asp:Series Name="NumberInMath" XValueMember="Name" YValueMembers="NumberInMath" IsVisibleInLegend="true" ChartType="Pie"> </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="ChartArea1" Area3DStyle-Enable3D="true"> <AxisX LineColor="DarkGreen"> <MajorGrid LineColor="LightGreen" /> </AxisX> <AxisY LineColor="DarkGreen"> <MajorGrid LineColor="LightGreen" /> </AxisY> <Area3DStyle Enable3D="True"></Area3DStyle> </asp:ChartArea> </ChartAreas> <Legends> <asp:Legend> </asp:Legend> </Legends> </asp:Chart> </div> </form></body></html>on .cs page:protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CreatePIChartForMarks(); } } private void CreatePIChartForMarks() { var table = new DataTable(); table.Columns.Add("Name", typeof(string)); table.Columns.Add("NumberInMath", typeof(long)); table.Columns.Add("Lbl"); var row = table.NewRow(); row["Name"] = "Girijesh"; row["NumberInMath"] = 33; table.Rows.Add(row); row = table.NewRow(); row["Name"] = "Rajesh"; row["NumberInMath"] = 09; table.Rows.Add(row); row = table.NewRow(); row["Name"] = "Pallav"; row["NumberInMath"] = 98; table.Rows.Add(row); row = table.NewRow(); row["Name"] = "Sharath"; row["NumberInMath"] = 37; table.Rows.Add(row); row = table.NewRow(); row["Name"] = "Mahesh"; row["NumberInMath"] = 59; table.Rows.Add(row); row = table.NewRow(); row["Name"] = "Lokesh"; row["NumberInMath"] = 78; table.Rows.Add(row); chartForMarks.DataSource = table; chartForMarks.DataBind(); }JMD:-) 这篇关于asp.net中的图表控件示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-15 21:54