Home Forums Chart Support Pie Chart click event in if else problem

Pie Chart click event in if else problem

Viewing 4 posts - 1 through 4 (of 4 total)
  • #33730

    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/

    #33759

    @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.

    Show specific DIV based on slected dataPoint

    ___________
    Indranil Deo
    Team CanvasJS

    #33765

    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

    #33792

    @aapril98,

    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?

    ___________
    Indranil Deo
    Team CanvasJS

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

You must be logged in to reply to this topic.