sanaini Posted January 25, 2009 Share Posted January 25, 2009 Hello everyone, This one has been killing me for a while. I am creating a pie chart with JPGraphs. I'm inserting minutes to be displayed right now, but I would like to convert them into hours to show. When I do so, it shows 0. I suppose since the number of minutes is less than an hour, and it does not display decimal points. This is my code snippet $xdata=array(); $ydata=array(); $xlables=array(); if($num_rows>=1){ $row=mysql_fetch_assoc($result); do{ $mins= $row['minutes']; $divider = doubleval(60); $hrs = $mins/$divider; array_push($xdata,$mins); array_push($ydata,trim($row['parent_task_name'])); $name=$rowName['ln']; } while($row = mysql_fetch_assoc($result)); } Can someone please let me know how to fix this. I'm assuming it messes up once it enters the array. Becasue I did an echo of every step and it shows the values right, but once in the array, the chart shows 0. Thanks a lot, -Seyed Link to comment https://forums.phpfreaks.com/topic/142361-inserting-decimals-in-an-array-with-array_push/ Share on other sites More sharing options...
landavia Posted January 25, 2009 Share Posted January 25, 2009 can u type the whole script.. i think this script is no problemo.. Link to comment https://forums.phpfreaks.com/topic/142361-inserting-decimals-in-an-array-with-array_push/#findComment-745921 Share on other sites More sharing options...
sanaini Posted January 25, 2009 Author Share Posted January 25, 2009 Thanks man. I got it! The format is this $p1->value->SetFormat("%d"); and should be changed to a float $p1->value->SetFormat("%01.2f"); Thanks, -Seyed Link to comment https://forums.phpfreaks.com/topic/142361-inserting-decimals-in-an-array-with-array_push/#findComment-745971 Share on other sites More sharing options...
landavia Posted January 25, 2009 Share Posted January 25, 2009 hmm perhaps the proble on Double u use above? Link to comment https://forums.phpfreaks.com/topic/142361-inserting-decimals-in-an-array-with-array_push/#findComment-745974 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.