0

I am simply trying to allow each data section or series of a pie chart via highcharts to be clickable, eg. Shop section should link to #shop_section I've found demos where a global link was set to every data section in a chart. But I simply would like a unique #link to be accessible via clicking one of my three data sections / series.

   series: [{
        innerSize: '30%',
        data: [
            ['Shop', 10], 
            ['Buy', 10], 
            ['Own', 10], 
        ]
    }]
});

This didn't work: (attempt)

    data: [
        {name: 'Shop', 10, url: 'http://my_site1.com'},
        {name: 'Buy', 10,  url: 'http://my_site2.com'},
        {name: 'Own', 10,  url: 'http://my_site3.com'}
    ]

2 Answers 2

2

Your series is incorrect, it should be:

data: [
    {name: 'Shop', y: 10, url: 'http://my_site1.com'},
    {name: 'Buy', y: 10,  url: 'http://my_site2.com'},
    {name: 'Own', y: 10,  url: 'http://my_site3.com'}
]
Sign up to request clarification or add additional context in comments.

1 Comment

Please replicate your example as live demo, which doesnt work.
1

Using plotOptions would do the work:

    plotOptions: {
        series:{
            point:{
                events:{
                    click: function(){
                        window.location.href = this.url;
                    }
                }
            }
        },
    },

By simply using a series->point->events we can speficy which events to delegate to our series points (in the case of a pie chart a point is a "slice"). On the event handler function itself, this refers to the clicked point, therefore I can directly use the custom property url you've set.

2 Comments

This looks great but how to specify which section links eg. name 'Shop' slice?
Hey @JamesBond, please clarify what your'e trying to achieve :) I didn't fully understand. the above code would work also for sections links

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.