Asp.net Charts - Url on Series Data Points


 So if you have an Asp.net chart and need to have some kind of Url over the data point areas (esp the individual bars on a bar chart, or the slices of a pie chart , etc) on the chart itself you can access the individual Points on each of your Series and set the Url property.  Another option is to set a PostBackValue which can be accessed in a click event of the chart. 

This actually ended up being scrapped because I found that if you resize the image then the click areas do not match up with the image anymore.  With our responsive setup have the images be responsive was a necessity as well.  Normally the asp.net chart images have a fixed width and height...well now I know why.  

 DataTable dt= GetSource();

        if (dt.Count != 0)
        {          
                int i = 0;
                for (i = 0; i <= dt.Rows.Count - 1; i++)
                {
                    string x = (string)dt.Rows[i]["name"];
                    decimal y = (decimal)dt.Rows[i]["Value"];
                    Chart1.Series[0].Points.AddXY(x, y);                   
                    Chart1.Series[0].Points[i].Url = "/cr/pageurl.aspx" + "?id=" + ID.ToString();                
                  }
        
        }

Comments

Popular posts from this blog

Asp.net Publishing Broke Site - "App_WebReferences is not allowed because the application is precompiled"

Telerik - Custom Group Footers In RadGrid

Bootstrap Modal Popup is Grayed Out