Skip to content Skip to sidebar Skip to footer

Amcharts Graph - Hyperlink For Chart Columns To Custom Urls To Open In A New Tab/window

I am trying to make a amcharts graph with columns linked to custom urls and want the urls to open in a new tab/window. I tried adding this code to the graph object but it does not

Solution 1:

You can use urlTarget such as:

var chart = AmCharts.makeChart("chartdiv", {
  "graphs": [{
    "balloonText": "[[category]]: <b>[[value]]</b>",
    "fillAlphas": 0.8,
    "lineAlpha": 0.2,
    "type": "column",
    "valueField": "visits",
    "urlField": "url",
    "urlTarget": "_blank"
  }],
  ...
};

Solution 2:

Change

"listeners": [{
      "event": "clickItem",
      "method": function(event) {
window.open(event.serialDataItem.dataContext.url, '_blank');
      }
    }],

to

listeners:[{
  event:'clickItem',
  method:function(event){
    open(event.item.url, '_blank');
  }
}]

Post a Comment for "Amcharts Graph - Hyperlink For Chart Columns To Custom Urls To Open In A New Tab/window"