Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pie Chart showing "other" when it should show data

I have implemented Google Pie Chart. All works perfectly but when i try to add data less than 10 it do not plot on chart instead of that it add a new entry under legend named - "Other"

My Script is

<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
 ['Task', 'Age Difference'],
['>10',        15],
['10-15',      <?php echo $agecnt2;?>],
['16-20',      <?php echo $agecnt3;?>],
['21-25',      <?php echo $agecnt4;?>],
['26-30',      <?php echo $agecnt5;?>],
['31-35',      <?php echo $agecnt6;?>],
['36-40',      <?php echo $agecnt7;?>],
['41-45',      <?php echo $agecnt8;?>],
['46-50',      <?php echo $agecnt9;?>],
['51-55',      <?php echo $agecnt10;?>],
['56-60',      <?php echo $agecnt11;?>],
['61-65',      <?php echo $agecnt12;?>],
['66-70',      <?php echo $agecnt13;?>],
['71-75',      <?php echo $agecnt14;?>],
['76-80',      <?php echo $agecnt15;?>],
['>80',        <?php echo $agecnt16;?>]
]);

var options = {
  title: 'Age Difference'
};

var chart = new google.visualization.PieChart(document.getElementById('chart_div4'));
chart.draw(data, options);
}
</script>  
like image 254
John Smith Avatar asked Jul 18 '13 06:07

John Smith


People also ask

What is the difference between a bar and pie chart?

A chart is used when you need to communicate complex information to show patterns and trends. Pie charts can quickly explain relative proportions of time or resource usage. Bar charts show distributions of results.

What data is being included in the pie chart?

Well, it looks like the other data is Code 85, Code 15, Inbound Scan, RLTO, IDST, and No Scan at Parent hub.... Those are all being included in your pie chart. You need to adjust the data reference of the chart. Going for Guru!

When should I use a chart?

If you have complicated data that needs to be simplified and presented in a way that shows a pattern or trend, a chart should always be used. They can be used to show the following:

Should I use a table or a chart for my presentation?

If in doubt, always use a chart rather than a table. Our minds tend to receive information more quickly with a chart. Charts can be overused. Pick out the key information and use the most appropriate chart. There is a tendency to fill our presentations with too many pie charts, which can distract from the vital information in your presentation.


2 Answers

The Google Pie chart groups all "small" slices into an "Other" group. As a default, any group that would have a default smaller than 1/2degree is grouped into the "Other" section. You can modify the sliceVisibilityThreshold (described here) to minimize/eliminate this effect.

like image 195
Jeremy Faller Avatar answered Oct 18 '22 13:10

Jeremy Faller


For me the problem was that my php code was still a string because of echo. So i did this:

parseInt("<?php echo $phpvalue; ?>")

and it worked.

like image 42
Ophiucus Avatar answered Oct 18 '22 14:10

Ophiucus