简体   繁体   中英

ASP.NET - How to add hyperlinks to pie chart sections?

I have a pie chart that uses data returned from a business rules method. Is it possible to allow users to click on the segments of the pie chart by adding hyperlinks to each segment?

I know how to do this in the aspx of the pie chart, but the datasource and series of the data is based on the data returned from the method. Would you use something like: foreach series with a switch statement for the hyperlink ?

How can I assign a hyperlink to the pie chart segments?

to redirect from specific section of pie chart:

Chart1.Series[0].Points[0].Url="/url1";

Chart1.Series[0].Points[1].Url="/url2";

Chart1.Series[0].Points[2].Url="/url3";

to redirect from specific legends of pie chart:

Chart1.Series[0].Points[0].LegendUrl="/url1";

Chart1.Series[0].Points[1].LegendUrl="/url2";

Chart1.Series[0].Points[2].LegendUrl="/url3";

you can write:

Chart1.Series[0].Points[0].Url = Chart1.Series[0].Points[0].LegendUrl = "rptPendingBreakdown.aspx";

To redirect from the specific section of the pie chart.

Use:

Chart1.Series(0).Points(0).Url="/url1"

Chart1.Series(0).Points(1).Url="/url2"

Chart1.Series(0).Points(2).Url="/url3"

饼形图

Try this one, it works fine for me

protected void QuestionResponseChart_DataBound(object sender, EventArgs e)
        {
            int points = QuestionResponseChart.Series[0].Points.Count;
            int i;
            for (i = 0; i <= points - 1; i++)
            {
                string txt = QuestionResponseChart.Series[0].Points[i].AxisLabel;
                QuestionResponseChart.Series[0].Points[i].Url = "SurveyList.ASPX?txt=" + txt;
            }
        }

我想出了如何使用 switch 语句将 url 和查询字符串分配给特定段名称来执行此操作:

Point.Url = "/url?querystring"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM