Highcharts - Provide URL's for series data to open clickable link

后端 未结 2 573
滥情空心
滥情空心 2020-12-15 14:28

I would like to add a url to each of my data points inside my series that when clicked user is redirected to that page. For example jsfiddle .

series:[{data:         


        
相关标签:
2条回答
  • 2020-12-15 14:46

    Here's one way to do this (fiddle here):

                           series: [{
                                name: 'Batch',
                                URLs: ['www.google.com', null, null, 'www.yahoo.com', null, null, 'www.cnn.com', null, null, 'www.minecraft.net'], // pass in array of URLs
                                data: [4375.48, 113599.39, 1278, 83950.12, 6579.65, 94582, 1285.65, 48700.39, 500, 62917.27],
                                color:'#b8ecce',
                                point: {
                                    events: {
                                        click: function() {
                                            var someURL = this.series.userOptions.URLs[this.x]; // onclick get the x index and use it to find the URL
                                            if (someURL)
                                                window.open('http://'+someURL);
                                        }
                                    }
                                }
                           }],
    
    0 讨论(0)
  • 2020-12-15 15:00

    You can use structure:

     data:[{
       y:10,
       ownURL:'http://www.google.com'
     },{
       y:11,
       ownURL:'http://www.google2.com'
     },{
       y:5,
       ownURL:'http://www.google3.com'
     }]
    

    and then you have ability to "get" this value by

    this.point.options.ownURL
    
    0 讨论(0)
提交回复
热议问题