I have the PIE chart with some values:
$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?
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | chart-numeric-617194-6.patch | 690 bytes | 13rac1 |
| #5 | chart_fix_adjust_resolution.patch | 639 bytes | mindbat |
Comments
Comment #1
murzCorrect php code is
Comment #2
murzIf I change the line 447 in chart.module file from
$data[$k] = floor($v / $divider);to
$data[$k] = ceil($v / $divider);The pie looks normally:
http://chart.apis.google.com/chart?chd=t1%3A100%2C20%2C8%2C5%2C2%2C1%2C1...
Comment #3
murzI have found the source of the problem!
In file
chart.modulefunction_chart_adjust_resolution()there are string:if ($v != 'NULL' && $v > 0){NULL must not be in quotes, the correct code is:
if ($v != NULL && $v > 0){and another error in function
_chart_encode_data($data)if ($v != 'NULL'){must be
if ($v != NULL){but for normal show the zero values I recommend this variant:
if (is_numeric($v)){because in first variant the pie charts with zero values shows bad!
values: 8,0,100,13
chart with
if ($v != NULL):http://chart.apis.google.com/chart?chd=t1%3A8%2C-1%2C100%2C13&cht=p3&chs...
value string: 8,-1,100,13
chart with
if (is_numeric($v)):http://chart.apis.google.com/chart?chd=t1%3A8%2C0%2C100%2C13&cht=p3&chs=...
value string: 8,0,100,13
Comment #4
haagendazs commentedMurz: I am using the 6.x-1.2 version of the Chart API module and had the same problem. Your fix described in #3 works great. Thanks a lot for figuring this out and sharing with us.
Comment #5
mindbat commentedThanks for posting a fix, Murz!
I've taken the liberty of rolling that fix into a patch.
Comment #6
13rac1 commentedSame patch for current 7.x-1.x-dev.
Comment #7
13rac1 commentedPatch applied to 7.x-1.x-dev. Needed in 6.x-1.x-dev.
Comment #8
13rac1 commentedJust realized, this is a dupe of #245532: formatting error for xy line charts, and issue with data that is equal to 0
Comment #9
Pierre.Vriens commented