You must be logged in to post your query.
Home › Forums › Chart Support › Pie Chart click event in if else problem
Tagged: html, mysql, php
I am trying to make my pie chart toggle open a certain div when a specific segment has been clicked on but I am not sure how because I am using php to intergrate the data for the pie chart
Here is my javascript for the pie chart:
https://jsfiddle.net/sg8yom6q/
@aapril98,
You can create DIV containers corresponding to each dataPoint as shown below –
<div id="DevJan" style="height: 17px; width: 100%;"> Delivered </div> <div id="NotDevJan" style="height: 17px; width: 100%;"> Not Delivered</div>
Then, hide/unhide the specific DIV container using jQuery as shown in the below code snippet –
click: function (e){ if( e.dataPoint.dataPoints === "Delivered"){ $("#DevJan").show(); $("#NotDevJan").hide(); }else{ $("#DevJan").hide(); $("#NotDevJan").show(); } },
Please take a look at this JSFiddle for a working example.
___________ Indranil Deo Team CanvasJS
I actually have div containers assigned to those id’s and within those divs are tables..
The problem lies in the if condition where it says e.dataPoint.dataPoints
In my JSFiddle my dataPoints are datas from my MySQL table. How to I get the if condition to read my data and if the pie slice clicked is the Delivered slice then it toggles open the div
Can you kindly create a sample project reproducing the issue you are facing and share it with us over Google-Drive or Onedrive along with sample database so that we can look into your code, run it locally at our end to understand the scenario better, and help you out?
You must be logged in to reply to this topic. Login/Register