Home Forums Chart Support creating links by onclick of splice of pie chart

creating links by onclick of splice of pie chart

Viewing 6 posts - 1 through 6 (of 6 total)
  • #5552

    Hi….I want to add a link to splices of pie chart……I want to add html links to it.

    Can someone please help me with this…

    #5553

    Ankita,

    You can open html links for respective dataPoint on click using click event handler. Please check out below code snippet for the same.

    chart.options.data[0].click = function(e){ 
      var dataSeries = e.dataSeries;
      var dataPoint = e.dataPoint;
      var dataPointIndex = e.dataPointIndex;
    
      if(!dataPoint.exploded)
        window.open(dataPoint.link,'_blank');  
    
      for(var i = 0; i < dataSeries.dataPoints.length; i++){
        if(i === dataPointIndex){                
          continue;
        }
    
        dataSeries.dataPoints[i].exploded = false;            
      }
    };

    Also, refer this JSFiddle for complete code.

    Adding Hyperlinks to Pie Chart Slices


    Sunil Urs
    Team CanvasJS

    #5554

    I have one more doubt…in this can I call a div of same html as a link instead of some site like google or yahoo….if yes then how?

    #5555

    Can you please explain what you meant by “can I call a div of same html as a link”.

    In any case once the click event handler is called you should be able to execute any code as per your requirement.

    #5556

    I mean that There are 4 charts which i have defined in 4 div. So onclick of a splice of pie chart i want to show one chart which is in one div…

    #5558

    You can achieve this using jQuery’s show/hide methods. Just place the code inside the event handler.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.