ASP.. NET饼图交互性
本文关键字:交互性 NET ASP | 更新日期: 2023-09-27 18:17:44
我在尝试在ASP中添加交互性时遇到了一些问题。净图表。我想在饼图系列中添加点击功能。代码工作良好,但我是不确定如何添加点击功能。
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());
}
}
我遵循了网站文档中显示的示例,但它不适合我,也没有错误信息。
你可能想看看这篇文章,看看它是否是你正在寻找的:如何从饼图中创建一个项目(点)的鼠标点击事件?