Jump to content

Click On Graph To Jump to New URL


Recommended Posts

Hello all,

I am looking to create a column chart URL HERE that allows a user to click on one of the columns to go to a new page. I based my code below off of this jsfiddle.

My goal is to have a user click on one of the columns to drill down to another page based on their selection, so if possible, I would love to also include the record as a parameter in the URL string.

I cannot get the code below to work even though it works in js fiddle. If it helps, the graph is set so that there will only be 10 records no matter what.

 

<script src="https://code.highcharts.com/highcharts.js"></script>
<script type="text/javascript">


Highcharts.chart('container', {

    chart: {
        type: 'column'
    },

    title: {
        text: 'Click points to go to URL'
    },

    xAxis: {
        type: 'category'
    },

    plotOptions: {
        series: {
            cursor: 'pointer',
            point: {
                events: {
                    click: function () {
                        location.href = 'https://en.wikipedia.org/wiki/';
                    }
                }
            }
        }
    },

    series: [{
        data: [{
            x: 1,

        }, {
            x: 2

        }, {
            x: 3,

        }]
    }]
});</script>

 

Link to comment
Share on other sites

Hello @rgiljohann

Here is the example of the code you may use with Column chart to implement redirection:

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {
 var chart = Highcharts.charts[0];
 console.log(chart);
 chart.update(
 {
  plotOptions: {
        series: {
            pointWidth: 20,
            cursor: 'pointer',
            point: {
                events: {
                    click: function () {
                        location.href = 'https://en.wikipedia.org/wiki/' + this.name;
                    }
                }
            }
        }
    },
  }
 );
});
</script>

Insert this code into the Header of your chart datapage. Do not forget to disable the HTML editor.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...