我编程动态 生成的 Chart控件不能显示 Legend

stringconnstring="server=.;uid=sa;pwd=123;database=WebLog";using(SqlConnectionconn=ne... string connstring = "server=.;uid=sa;pwd=123;database=WebLog";
using (SqlConnection conn = new SqlConnection(connstring))
{
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "select sc_status as Status ,COUNT(*) as Num from Backups group by sc_status";

Chart Chart1 = new Chart();
Chart1.Visible = true;
SqlDataReader reader = cmd.ExecuteReader();
this.Controls.Add(Chart1);
Chart1.BackColor = Color.Gray;
Chart1.BackSecondaryColor = Color.WhiteSmoke;
Chart1.BackGradientStyle = GradientStyle.DiagonalRight;
Chart1.BorderlineDashStyle = ChartDashStyle.Solid;
Chart1.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
Chart1.BorderlineColor = Color.Gray;
// format the chart area
ChartArea aaa = new ChartArea();

Series ss = new Series();

Chart1.ChartAreas.Add(aaa);
Chart1.ChartAreas[0].BackColor = Color.Wheat;
Chart1.Location = new Point(50, 30);
Chart1.Height = 426;
Chart1.Width = 576;
// add and format the title
Chart1.Titles.Add("响应情况");

Chart1.Series.Add(ss);
Chart1.Titles[0].Font = new Font("Utopia", 16);
Chart1.Series[0].Points.DataBindXY(reader, "Status", reader, "Num");
Chart1.Series[0].ChartType = SeriesChartType.Column;
Chart1.Series[0].IsValueShownAsLabel = true;
Chart1.Series[0].IsVisibleInLegend = true;
Chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
Chart1.ChartAreas[0].AxisX.IntervalAutoMode = IntervalAutoMode.VariableCount;
Chart1.Series[0].IsXValueIndexed = true;

reader.Close();
}
展开
 我来答
匿名用户
2012-03-26
展开全部
貌似是webform的? protected void Page_Load(object sender, EventArgs e) { if (this.IsPostBack) { if (ViewState["hasbt"] != null && (bool)ViewState["hasbt"] == true) { AddBT(); } } } protected void Button1_Click(object sender, EventArgs e) { AddBT(); } private void AddBT() { Button bt = new Button(); bt.Text = "测试"; bt.ID = "bt"; bt.Click += new EventHandler(bt_Click); Panel1.Controls.Add(bt); this.ViewState["hasbt"] = true; } void bt_Click(object sender, EventArgs e) { Response.Write("<scritp>alert('成功了');</script>"); } ~
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友9a7ddea
2012-03-31
知道答主
回答量:11
采纳率:0%
帮助的人:3.9万
展开全部
chart1.Legends[0].Enabled = true;加上就可以用了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式