It is currently Fri Aug 29, 2014 6:11 pm Advanced search

URLs for category labels on bar chart

Technical support, bug reports and more.

URLs for category labels on bar chart

Postby dwhalenenr » Wed Feb 15, 2012 5:50 pm

Hi everyone.

I have bar chart with pre-set categories. I want to hyperlink the category names so that clicking on the label (not the bar) loads the URL in a new window.

I've seen some examples that involve clicking on a bar inside the plot area, but nothing involving a category label. Is there a way to do this?

Cheers!

DW
dwhalenenr
 
Posts: 11
Joined: Wed Feb 08, 2012 10:32 pm

Re: URLs for category labels on bar chart

Postby Fusher » Wed Feb 15, 2012 6:16 pm

Paweł Fus
Highcharts support team
Fusher
 
Posts: 6928
Joined: Mon Jan 30, 2012 12:16 pm

Re: URLs for category labels on bar chart

Postby dwhalenenr » Wed Feb 15, 2012 6:18 pm

Awesome! Thanks very much!
dwhalenenr
 
Posts: 11
Joined: Wed Feb 08, 2012 10:32 pm

Re: URLs for category labels on bar chart

Postby dwhalenenr » Fri Feb 17, 2012 7:42 pm

Has anyone got a way to make these open in a new window?
dwhalenenr
 
Posts: 11
Joined: Wed Feb 08, 2012 10:32 pm

Re: URLs for category labels on bar chart

Postby mrbob » Fri Feb 17, 2012 8:22 pm

mrbob
 
Posts: 8
Joined: Wed Jan 18, 2012 3:46 am

Re: URLs for category labels on bar chart

Postby dwhalenenr » Tue Feb 21, 2012 3:57 pm

Yeah, I tried that. Unfortunately when it gets changed to SVG tags it turns into a javascript:onclick call and the target attribute is removed.

If I could get the SVG to call a custom JS function of my own on click, then I could make it happen....
dwhalenenr
 
Posts: 11
Joined: Wed Feb 08, 2012 10:32 pm

Re: URLs for category labels on bar chart

Postby hfrntt » Fri Feb 24, 2012 2:25 am

It'll work if you switch to html labels (set useHTML to true), I mean:
Code: Select all
labels: {
    useHTML: true,
    formatter: function() {
        return '<a href="'+categoryLinks[this.value] +'"  target="_blank">'+
            this.value +'</a>';
    }
}


Here you can see this live: http://jsfiddle.net/grVFk/11311/
Slawek Kolodziej
Highcharts support team
hfrntt
 
Posts: 6394
Joined: Mon Aug 30, 2010 10:41 am


Return to Highcharts Usage

Who is online

Users browsing this forum: funkmunk and 7 guests