This is a migrated thread and some comments may be shown as answers.

YAxis click event not working

4 Answers 61 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 23 Jan 2012, 04:27 PM
I'm having trouble making the X-axis labels clickable in an asp.net stacked bar chart (sorry, said y-axis in the subject). Using the code below, they don't even get added to the area map and become clickable, let alone the event fire. If I uncomment the url, they become clickable and send me to the default page so I think I'm dealing with the correct chart elements, but I want postback event and to be able to access the label specific values and react to them. What am I doing wrong?

protected void RadChart2_Load(object sender, EventArgs e)
{
    foreach (ChartAxisItem axisItem in this.RadChart2.PlotArea.XAxis.Items)
    {
        axisItem.ActiveRegion.Tooltip = "Click Me";
        //axisItem.ActiveRegion.Url = "Default.aspx";
        axisItem.ActiveRegion.Click += new RegionClickEventHandler(ActiveRegion_Click);
    }
}

4 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 24 Jan 2012, 06:34 PM
Chris:

You did not specify here what it is that you want to do with the value accessed from the AxisItem. But, you might want to take a look at the
RadChart - Create a Drill-Down Chart TelerikTV video. It provides an interesting way to capture an AxisItem value using the tooltip, and on the RadChart click event, store it into a session variable. Then, in this case to use the session parameter in a SQL Stored Procedure to populate the second drilldown chart.

See the "radchartclick.png" screen capture for the pertinent code.

Hope this helps!
0
Chris
Top achievements
Rank 1
answered on 24 Jan 2012, 09:33 PM
I tried the method you suggested Jumpstart, but I just cannot seem to make the x-axis labels become clickable except to configure them all to go to a single URL.

I'm using the radchart.click event currently to react to the user clicking the stacked bar segments and allow them to filter down to a single series. I want to make the labels (which are date/hour ranges) clickable to drill down to a single range and display that hour in minutes.

Everything's working, except as I said above, those x-axis labels will simply not register as clickable using radchart.click or chartaxisitem.activeregion.click.
0
Accepted
Petar Marchev
Telerik team
answered on 27 Jan 2012, 12:35 PM
Hi,

The RadChart in asp.net ajax is being rendered as an image on the server and sent to the client. That being the case - it is not possible to attach a handler to an event and later react to it.

However, there are ways to find out if an axis item was clicked. I have attached a sample project to demonstrate one approach. Some javascript is involved and passing string arguments, which you may use to pass information. 

References:
Ensure __doPostBack is implemented

All the best,
Petar Marchev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Chris
Top achievements
Rank 1
answered on 27 Jan 2012, 08:33 PM
Thank you. I was able to achieve the functionality I wanted by manually attaching a client side click event with a __dopostback call.

I do however think it seems like a workaround for a bug or missing functionality in the chart control. I think if you provide a click even to attach to, the control should recognize that and generate a proper imagemap area tag and necessary javascript code to perform the postback, even if it all gets fed into a single RadChart_Click method as opposed to individual event handlers.
Tags
Chart (Obsolete)
Asked by
Chris
Top achievements
Rank 1
Answers by
Richard
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Petar Marchev
Telerik team
Share this question
or