Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Chart > YAxis click event not working

Answered YAxis click event not working

Feed from this thread
  • Chris avatar

    Posted on Jan 23, 2012 (permalink)

    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);
        }
    }

    Reply

  • jumpstart Master avatar

    Posted on Jan 24, 2012 (permalink)

    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!
    Attached files

    Reply

  • Chris avatar

    Posted on Jan 24, 2012 (permalink)

    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.

    Reply

  • Answer Petar Marchev Petar Marchev admin's avatar

    Posted on Jan 27, 2012 (permalink)

    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

    Reply

  • Chris avatar

    Posted on Jan 27, 2012 (permalink)

    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.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Chart > YAxis click event not working
Related resources for "YAxis click event not working"

ASP.NET Chart Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]