简体   繁体   English

ASP.NET - 如何将超链接添加到饼图部分?

[英]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.我知道如何在饼图的aspx中执行此操作,但是数据源和数据系列是基于方法返回的数据。 Would you use something like: foreach series with a switch statement for the hyperlink ?你会使用类似的东西: 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[0].Url="/url1";

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

Chart1.Series[0].Points[2].Url="/url3"; 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[0].LegendUrl="/url1";

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

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

you can write:你可以写:

Chart1.Series[0].Points[0].Url = Chart1.Series[0].Points[0].LegendUrl = "rptPendingBreakdown.aspx"; 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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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