You must be logged in to post your query.
Home › Forums › Chart Support › creating links by onclick of splice of pie chart
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…
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.
— Sunil Urs Team CanvasJS
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?
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.
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…
You can achieve this using jQuery’s show/hide methods. Just place the code inside the event handler.
You must be logged in to reply to this topic. Login/Register