[英]ASP.NET pie chart interactivity
I am having some problem when trying to add interactivity in ASP.NET charts. 尝试在ASP.NET图表中添加交互性时遇到一些问题。 I want to add the click function in pie chart series.
我想在饼图系列中添加点击功能。 The code is working fine but I am not sure how to add click function .
代码工作正常,但我不知道如何添加单击功能 。
protected void populateCategoryPieChart()
{
try
{
Chart2.Visible = true;
Chart2.Titles.Clear();
string query = string.Format("//sensitive data", Convert.ToInt64(sessionDdl.SelectedValue));
DataTable dt = getData(query);
int[] c = new int[dt.Rows.Count];
string[] x = new string[dt.Rows.Count];
int[] y = new int[dt.Rows.Count];
for (int i = 0; i < dt.Rows.Count; i++)
{
c[i] = Convert.ToInt32(dt.Rows[i][0]);
x[i] = obj.getCategoryByID(Convert.ToInt64(dt.Rows[i][0])).Name;
y[i] = Convert.ToInt32(dt.Rows[i][1]);
}
populateCategoryList(c);
Chart2.Series["Category"].Points.DataBindXY(x, y);
Chart2.Series["Category"].Label = "#VALX";
Chart2.Series["Category"].LabelForeColor = Color.Black;
Chart2.Series["Category"]["PieLabelStyle"] = "Outside";
Title title = new Title("Most Viewed Category", Docking.Top, new Font("Verdana", 13), Color.Black);
Chart2.Titles.Add(title);
Chart2.Legends.Add("Legend1");
Chart2.Legends[0].Enabled = true;
Chart2.Legends[0].Docking = Docking.Bottom;
Chart2.Legends[0].Alignment = StringAlignment.Center;
Chart2.Series["Category"].LegendText = "#VALX (#PERCENT)";
Chart2.DataManipulator.Sort(PointSortOrder.Descending, Chart2.Series["Category"]);
Chart2.Series["Category"].ChartType = SeriesChartType.Pie;
Chart2.ChartAreas["ChartArea2"].Area3DStyle.Enable3D = true;
Chart2.Legends[0].Enabled = true;
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
I have followed the example shown in the site documentation but it is not working for me and there was no error message. 我已经按照站点文档中显示的示例进行操作,但它不适合我,并且没有错误消息。
您可能需要查看此帖子以查看它是否是您要查找的内容: 如何从饼图中为项目(点)创建鼠标单击事件?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.