completenutter2
Posts: 5
Joined: Fri Jan 22, 2010 1:31 pm

Clicking a Bar

Hi,

I have just found your charting library, and so far, it seems very impressive. I am just testing it out to see if it is suitable to replace the charting library we use at the moment.

I am trying to get a simple function to be called when I click on a bar in a chart.

Using the following code:

Code: Select all

plotOptions: {
    bar: {
        events: {
            click: testClick
        }
    }
},
This is the method I'm trying to call:

Code: Select all

function testClick(event) {
                alert("test");
            }
When I click on a bar, the alert pops up, but Visual Studio (I'm using ASP.NET) breaks out at the following piece of code:

Code: Select all

if(r==Aa||r.tagName=="AREA"&&r!=G)
r is null. I'm not entirely sure what r is, or whether it is needed, since it still seems to work ok.

Is this is a bug in the charting tool, or (and this is far more likely) a bug in the way I am using it?
completenutter2
Posts: 5
Joined: Fri Jan 22, 2010 1:31 pm

Re: Clicking a Bar

This is the email I got back from support
I think this is an error that occurs in certain cases when you mouse out of the chart. Try using the latest trunk version of Highcharts: http://highcharts.com/js/prerelease/hig ... 1.2.src.js.
This seems to have fixed the problem :D
torstein.honsi
Site Admin
Posts: 9215
Joined: Thu Nov 09, 2006 11:22 am
Location: Vik i Sogn, Norway

Re: Clicking a Bar

Yes, it was fixed in version 1.1.2 released Friday.
Torstein Hønsi
CTO, Founder
Highsoft
Bmeahan
Posts: 1
Joined: Tue Feb 09, 2010 10:56 pm

Re: Clicking a Bar

This part is working fine for me, but I want to take it a step further and use it for drill down capability. I understand how to get the next page through the javascript function, but where I'm lost is on getting the paramaters from the item in the chart to pass to the next page. Basically if the chart is a set of monthly values then I would need to pass the series name, and the month (x axis) and year to the next page. I can get the series name with this.name, but I'm not grasping how I can get the x-axis for the data point I'm clicking on.

thanks
torstein.honsi
Site Admin
Posts: 9215
Joined: Thu Nov 09, 2006 11:22 am
Location: Vik i Sogn, Norway

Re: Clicking a Bar

You can get the x (category) value by event.point.category:

Code: Select all

function testClick(event) {
                alert(event.point.category);
            }
Torstein Hønsi
CTO, Founder
Highsoft

Return to “Highcharts Usage”