2

How would I modify the demo chart "Column with Drilldown" so that a column in the drilldown chart is a hyperlink to an arbitrary web page (not to another drilldown)?

  • Could you provide more detail? Examples? – MrBoJangles Feb 19 '14 at 16:43
  • Honestly, the demo has been my template, and it's the best example, so if you can show me what you would do with [link](http://www.highcharts.com/demo/column-drilldown), that would tell me everything I have to know. Thx. – user3328881 Feb 19 '14 at 16:55
  • So you don't want a drilldown, but URL to another page? Then see third demo from [docs](http://api.highcharts.com/highcharts#plotOptions.column.point.events.click). – Paweł Fus Feb 19 '14 at 16:59
  • Yes, that makes a link in the parent chart. I found that earlier and copied it over and it works. How to I enable it only for the child charts? – user3328881 Feb 19 '14 at 18:00
  • What is child charts? – Paweł Fus Feb 20 '14 at 10:36
  • Child charts are the second-level charts that you get from clicking on a point (or a column) in the parent chart. – user3328881 Feb 20 '14 at 12:20

1 Answers1

0

If you do not add a url property to your initial series it will not click to the url. So, add the url property to your drilldown items and add the click event handler to it. See this example. The url does not load because of jsFiddle but it should work in general.

Code that is important:

    $.each(versions, function (key, value) {
        drilldownSeries.push({
            name: key,
            id: key,
            data: value,
            url: 'http://bing.com/search?q=foo'
        });
    });

And:

        plotOptions: {
            series: {
                borderWidth: 0,
                dataLabels: {
                    enabled: true,
                    format: '{point.y:.1f}%'
                },
                point: {
                    events: {
                        click: function () {
                            location.href = this.options.url;
                        }
                    }
                }
            }
        }
wergeld
  • 14,332
  • 8
  • 51
  • 81
  • VERY close. Looks like the event handler works, but despite the url value like the above, it's looking for the resource locally. The browser says "Firefox can't find the file at /C:/Users/XXXXXX/Documents/undefined" – user3328881 Feb 19 '14 at 20:47
  • Another clue... if I hard code location.href: `location.href = 'http://www.yahoo.com';` then it works :^) – user3328881 Feb 19 '14 at 20:52
  • jsfiddle complains: {"error": "Please use POST request"} – user3328881 Feb 20 '14 at 12:22
  • Right. That is a jsFiddle issue. Have you tried on your dev site? – wergeld Feb 20 '14 at 12:47
  • If you mean a web server, no. If I specify a file instead of an http target, I get the same. If I replace `location.href = this.options.url;` with `alert(this.options.url);` the popup just says **undefined**. – user3328881 Feb 20 '14 at 12:58
  • Is this on the first series or on the drill series? The first series will throw the undefined error because you do not set the URL in the top-level series. Only set the url property in the series you want to have the url active on. – wergeld Feb 20 '14 at 13:06
  • I set the URL in drilldownSeries.push. That gives me the 'undefined' message. On the other hand, if I write `location.href = 'http://www.yahoo.com';` instead of `location.href = this.options.url;` right where you have it, then any column I click in the first series gives me that web page. If I click the 'back' button, I get the drill series chart. If I click any column there, I also get the web page. So all that's missing is how to tell click handler what chart is in context. – user3328881 Feb 20 '14 at 14:39
  • My code is just an exact copy of the Highcharts demo, which I launch into fiddle right from the web site. Exact copy. I tried copying what I have back up to fiddle (in case some non-printables are creeping in), but the results are identical. The 'issue' with fiddle you mentioned earlier interferes. If you download a copy of the Highcharts demo, and paste in your snippets, you will have exactly the code that I have. – user3328881 Feb 20 '14 at 15:03
  • @user3328881, okay. I can replicate that issue. This is interesting. Maybe only have the clicking of the "bar" lead to drill series but clicking on xAxis label do the URL? – wergeld Feb 20 '14 at 15:22
  • `click: function () { var ungawa = this.name; if (!ungawa) { // parent chart //alert('Parent chart'); } else { // child chart location.href = 'webpage.html'; } }` – user3328881 Feb 20 '14 at 15:46
  • 1
    In a parent chart, this.name is blank, whereas in a child chart it has a value. Don't understand why, but I can use it. – user3328881 Feb 20 '14 at 15:48