ihatephp Posted November 20, 2008 Share Posted November 20, 2008 Let’s say I want to show the combined results of how many kids there is per family. Any idea how I can combine my results to form a chart or piechart? Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/ Share on other sites More sharing options...
Styles2304 Posted November 20, 2008 Share Posted November 20, 2008 results from what? Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694307 Share on other sites More sharing options...
rhodesa Posted November 20, 2008 Share Posted November 20, 2008 Can I assume you already now how to generate the data, just need to turn that into something graphical? There are several options out there: http://www.fusioncharts.com/ - Stylish, but not free, Flash based frontend http://www.maani.us/xml_charts/ - Also Stylish, has a free version, Flash based frontend http://www.aditus.nu/jpgraph/ - Crude looking, but all free, uses GD to make image http://code.google.com/apis/chart/ - Pretty slick, you just create a URL and Google makes the image for you Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694308 Share on other sites More sharing options...
ihatephp Posted November 20, 2008 Author Share Posted November 20, 2008 Hmm, roughly how should i generate the data? I 've never used flash before so i'm unsure of how it's gona work. Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694310 Share on other sites More sharing options...
rhodesa Posted November 20, 2008 Share Posted November 20, 2008 All of ones with the Flash front end, don't require you to know any Flash. They generate the chart based on an XML file (which can be static or dynamically generated with PHP). Read the Documentation for each and check out their examples for what the final data looks like. Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694315 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 16 bytes) for($c=0; $c<count($children); $c++){ number 26 related error <<<<<<<<<,,, why dosent it work please got it to work once then bang gone........... this is a graph out off css to show number off children........ <?php /* Show number of blocks per child. 1 = 1 2 = 18 3 = 38 4 = 58 5 = 78 6 = 98 7 = 118 8 = 138 9 = 158 10 = 178 */ $children=array("1","2"); $num=count($children); for($c=0; $c<count($children); $c++){ switch($children[$c]){ case "1": $children[]="1"; break; case "2": $children[]="18"; break; case "3"; $children[]="38"; break; case "4"; $children[]="58"; break; case "5"; $children[]="78"; break; case "6"; $children[]="98"; break; case "7"; $children[]="118"; break; case "8"; $children[]="138"; break; case "9"; $children[]="158"; break; case "10"; $children[]="178"; break; } } for($f=$num; $f<$c; $f++,$children++){ echo"<br><br><div style='height: 10px; width:{$children[$f]}px; padding: 10px; background: URL(2tone.gif) repeat'></div><br><br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694416 Share on other sites More sharing options...
rhodesa Posted November 20, 2008 Share Posted November 20, 2008 you are adding elements to $children as you are reading them, therefore it will run forever Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694418 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 can u show me the solution please cheers........ Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694421 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 the only way a function lol... <?php /* Show number of blocks per child. 1 = 1 2 = 18 3 = 38 4 = 58 5 = 78 6 = 98 7 = 118 8 = 138 9 = 158 10 = 178 */ function pie($children){ switch($children){ case "1": $children="1"; break; case "2": $children="18"; break; case "3"; $children="38"; break; case "4"; $children="58"; break; case "5"; $children="78"; break; case "6"; $children="98"; break; case "7"; $children="118"; break; case "8"; $children="138"; break; case "9"; $children="158"; break; case "10"; $children="178"; break; } echo"<br><br><div style='height: 10px; width:{$children}px; padding: 10px; background: URL(2tone.gif) repeat'></div><br><br>"; } echo pie('5',$children); Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694433 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 why is the 1st result not showing the name off the person on top off array 0 see the result your self http://simpleforum.ath.cx/pie.php WHY THE ECHOED FORMAT WRONG OF THE RESULT, IT NOT ON TOP WHY? The function........ <?php $family=array("john"=>"3","paul"=>"10","bob"=>"9","henry"=>"1","clair"=>"2","linda"=>"6"); foreach($family as $key => $val){ echo "$key has $val children ".pie($val,$children)." "; } ?> full code <?php /* Show number of blocks per child. 1 = 1 2 = 18 3 = 38 4 = 58 5 = 78 6 = 98 7 = 118 8 = 138 9 = 158 10 = 178 */ function pie($children){ switch($children){ case "1": $children="1"; break; case "2": $children="18"; break; case "3"; $children="38"; break; case "4"; $children="58"; break; case "5"; $children="78"; break; case "6"; $children="98"; break; case "7"; $children="118"; break; case "8"; $children="138"; break; case "9"; $children="158"; break; case "10"; $children="178"; break; } echo"<div style='height: 10px; width:{$children}px; padding: 10px; background: URL(2tone.gif) repeat'></div><br>"; } $family=array("john"=>"3","paul"=>"10","kevin"=>"7"); foreach($family as $key => $val){ echo "$key ".pie($val,$children)." "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694453 Share on other sites More sharing options...
Mark Baker Posted November 20, 2008 Share Posted November 20, 2008 Please get rid of that long switch() statement. You can do the same using: if ($children > 1) { } else { $children = ($children-1)*20-2; } Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694481 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 your maths didnt work m8.... look agin....... the quistion is why issint the correct names on the correct line...... Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694491 Share on other sites More sharing options...
rhodesa Posted November 20, 2008 Share Posted November 20, 2008 change the 'echo' in your function to 'return'. since you are executing the pie() function inside the echo statement, it will run it first (echoing the DIV), then finishing the echo. Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694492 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 can u show me please thank u............ like to learn properly........ Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694498 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 SOLVED JUST NEEDED RETURN INSTEAD OFF ECHO LOVLY YE HA THANK U.... There u go a pie chart............. Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694519 Share on other sites More sharing options...
rhodesa Posted November 20, 2008 Share Posted November 20, 2008 if i had my way, it would be like this: <?php $family = array( 'john' => 3, 'paul' => 10, 'kevin' => 7, ); foreach($family as $name => $num){ $width = ($num > 1) ? (($num-1)*20)-2 : 1; echo "{$name}<div style='height: 10px; width:{$width}px; padding: 10px; background: URL(2tone.gif) repeat'></div><br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694522 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 your way good so what all this mean $width = ($num > 1) ? (($num-1)*20)-2 : 1; exsplain it confused me Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694533 Share on other sites More sharing options...
premiso Posted November 20, 2008 Share Posted November 20, 2008 your way good so what all this mean $width = ($num > 1) ? (($num-1)*20)-2 : 1; exsplain it confused me If $num is greater than one, then subtract 1 from $num then times that by 20 then subtract 2 from that. If $num is less than one set $num to one. So lets say $num is 10 10 - 1 is 9 times that by 20 is 180 then subtract 2 is 178 So the width would be set to 178 pixels. This I am assuming would make sure that the name can fit inside the div without being cut off. And if there was no name it would be set to 1 so the div wouldn't really be visible....at least that is how I interpret it. Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694534 Share on other sites More sharing options...
Mark Baker Posted November 20, 2008 Share Posted November 20, 2008 the quistion is why issint the correct names on the correct line...... I know that my maths wasn't answering your question.... I was just getting fed up with seeing the size of your switch statement when the logic it executed could be simplified to a simple mathematical formula. your maths didnt work mate....So what was wrong with the mathematics.... other than the fact that I left an else in the if statement? Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694537 Share on other sites More sharing options...
Mark Baker Posted November 20, 2008 Share Posted November 20, 2008 the quistion is why issint the correct names on the correct line...... I know that my maths wasn't answering your question.... I was just getting fed up with seeing the size of your switch statement when the logic it executed could be simplified to a simple mathematical formula. My apologies for trying to simplify your code. your maths didnt work mate....So what was wrong with the mathematics.... other than the fact that I left an else in the if statement? Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694540 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 you needed to take 2 away or 1 away to get correct result..... other wise get wrong image result...... but your ways off thinking are grate thank u... Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694544 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 no sorry ur write im always wrong sorry............. i just dont no how to think like a programmer my common sence sucks sorry mate didnt even think off maths logic to solve this....... not even my post i suppose it all wrong but i like to try to understand it.......... Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694546 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 look at google chart amazing and free <img src="http://chart.apis.google.com/chart? chs=250x100 &chd=t:60,40 &cht=p3 &chl=Hello|World" alt="Sample chart" /> google tacken over everthink even programming stratargys man it sick............ wonder why copy past exsperts get good money....... Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694562 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 here u go better then everthink else free and unreel enjoy........ php charts......... http://naku.dohcrew.com/libchart/pages/introduction/ Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694591 Share on other sites More sharing options...
redarrow Posted November 20, 2008 Share Posted November 20, 2008 look at this butifull chart............ libchart......... http://simpleforum.ath.cx/pie/demo/VerticalBarChartTest.php use the link below to get the correct class.......... Quote Link to comment https://forums.phpfreaks.com/topic/133495-report-generating/#findComment-694621 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.