Home > other >  Highcharts, turn click point into link
Highcharts, turn click point into link

Time:01-24

I am working with Highcharts (https://www.highcharts.com/) to build a clickable map as it was the only option suiting what I needed. The map I am using is found on this codepen (https://codepen.io/mushigh/pen/xxRmpWy) . I have only one problem I can not possibly make it able to turn this markers as links

Image of keypoints in the map

I changed these paramerters a little bit so they would return a link but nothing worked.

tooltip: {
  formatter: function () {
    return this.point.id   (
      this.point.lat ?
        '<br>Lat: '   this.point.lat   ' Lon: '   this.point.lon : ''
    );
  }
},

plotOptions: {
  series: {
    marker: {
      fillColor: '#FFFFFF',
      lineWidth: 2,
      lineColor: Highcharts.getOptions().colors[1],
//'<button onclick="href=\'www.facebook.com\'">Kliko</button>'

    }
  }
},

CodePudding user response:

You need to use the point's click event to achieve that. Add the following code to the series:

cursor: 'pointer',
  point: {
    events: {
      click() {
        let point = this;
        location.href = `https://en.wikipedia.org/wiki/${point.name}`
      }
    }
  }

Demo: https://jsfiddle.net/BlackLabel/6bh34w5k/

API Reference: https://api.highcharts.com/highmaps/series.mappoint.point.events.click

  • Related