Wrong data on chart after adjust_resolution
Murz - October 28, 2009 - 18:11
| Project: | Chart API |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I have the PIE chart with some values:
<?php
$chart = array(
'#chart_id' => uniqid(),
'#type' => CHART_TYPE_PIE_3D,
'#size' => chart_size(500, 160),
'#adjust_resolution' => TRUE,
);
$chart['#data'] = array([0] => 529 [1] => 102 [2] => 41 [3] => 25 [4] => 10 [5] => 5 [6] => 1 [7] => 1 );
$chart['#data_colors'] = array('78c0e9', 'ffe500', '50b432', 'ed561b');
echo chart_render($chart);
?>If I turn on "#adjust_resolution = true" I see a PIE with only 2 normal zones, and all other becomes zero-sized! Example:
http://chart.apis.google.com/chart?chd=t1%3A99%2C19%2C7%2C4%2C1%2C-1%2C-...
If I don't use "#adjust_resolution = true" option, I see the chart with bad size of zones (first zone must be much than 5 times bigger that other). Example:
http://chart.apis.google.com/chart?chd=t1%3A529%2C102%2C41%2C25%2C10%2C5...
Why after adjusing resolution i didn't see other zones and some values becomes -1?

#1
Correct php code is
<?php$chart = array(
'#chart_id' => uniqid(),
'#type' => CHART_TYPE_PIE_3D,
'#size' => chart_size(500, 160),
'#adjust_resolution' => TRUE,
);
$chart['#data'] = array(529, 102, 41, 25, 10, 5, 1, 1);
$chart['#data_colors'] = array('78c0e9', 'ffe500', '50b432', 'ed561b');
echo chart_render($chart);
?>
#2
If I change the line 447 in chart.module file from
<?php$data[$k] = floor($v / $divider);
?>
to
<?php$data[$k] = ceil($v / $divider);
?>
The pie looks normally:
http://chart.apis.google.com/chart?chd=t1%3A100%2C20%2C8%2C5%2C2%2C1%2C1...