Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
Also return rows where the value is zero in Google's Making a 3D Pie Chart

I have the following code to create the google chart.

google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {

  $.getJSON('categorias.php', function (data) {

    var tdata = new google.visualization.DataTable();

    tdata.addColumn('string', 'Categorias');
    tdata.addColumn('number', 'Total');

    for (var i = 0; i < data.length; i++) {

      tdata.addRow([data[i][0], parseInt(data[i][1]) ]);
    } 
      var options = {
        is3D: true,
      };
     
      var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));
      chart.draw(tdata, options);
    
  });
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="piechart_3d" style="width: 900px; height: 500px;"></div>

The data returned in the categories.php page are as follows:

0: ["Sugestões para Melhorias", 0]  
1: ["Problemas de Ambiente no Trabalho", 0]  
2: ["Insatisfação geral", 0]  
3: ["Problemas relacionados com Saúde Mental (Depressão, Ansiedade, Stress, Burnout)", 0]  
4: ["Bullying (Mobbing, Bossing, Pessoal, Gossip)", 1]  
5: ["Assédio Sexual", 0]  
6: ["Discriminação (Raça, Idade, Género, Orientação Sexual, Religião)", 0]  
7: ["Preocupação relativas à saúde e segurança", 0]  
8: ["Incumprimento do Manual de Conduta", 0]  
9: ["Suspeita de Roubo, Corrupção ou Desfalque", 2]  
10: ["Danos à Instituição (Propriedade ou Reputação", 0]  
11: ["Agressão Física", 0] 
12: ["Violação da Lei ou Código do Trabalho", 0]  
13: ["Feedback positivo ou elogio", 0]  
14: ["Outras", 0]

All categories whose value is 0 does not return. But I want them to return all categories even if it's zero.

I show the graph how it looks:

enter image description here

But I wanted all the categories to appear as in this image I show:

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!