YAxis click event not working

Thread is closed for posting
5 posts, 1 answers
  1. Chris
    Chris avatar
    5 posts
    Member since:
    Dec 2011

    Posted 23 Jan 2012 Link to this post

    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);
        }
    }
  2. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 24 Jan 2012 Link to this post

    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!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chris
    Chris avatar
    5 posts
    Member since:
    Dec 2011

    Posted 24 Jan 2012 Link to this post

    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.
  5. Answer
    Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 27 Jan 2012 Link to this post

    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
  6. Chris
    Chris avatar
    5 posts
    Member since:
    Dec 2011

    Posted 27 Jan 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017