realjumper Posted July 13, 2006 Share Posted July 13, 2006 Hi,In my application to test the users knowledge of Kanji, I ask 20 random questions. At the completion of the test I show them, amoung other things, how many they got correct, how many they got wrong, and the percentage of correct answers....the code is below. What I would like to do is to show this data in the form of a pie chart or perhaps a bar graph as it is a bit more applealing than just the stats. I'm not asking for the code, I'm just asking to be sent in the right direction so that I can find out how to do this and have a go myself. If you can set me on my way, I'd be most gratefull, thanks[code]$yes = $row[test_correct];$no = $row[test_wrong];$total = $yes+$no;$sum = $yes/$total*'100';$perc = round($sum); if ($row[test_attempts] == '20') { echo "Test Complete"; echo "<p>"; echo "Correct Answers: $row[test_correct]"; echo "<p>"; echo "Wrong Answers: $row[test_wrong]"; echo "<p>"; echo "Percentage Correct: $perc%"; [/code] Quote Link to comment https://forums.phpfreaks.com/topic/14533-pie-chart-or-bar-graph/ Share on other sites More sharing options...
ShogunWarrior Posted July 13, 2006 Share Posted July 13, 2006 I think the best thing is to get a free PHP graph class and use it to display a nice graph.That way you won't be re-inventing code and coding what someone's put time into, I found one here:http://www.qualityunit.com/postgraph/It's open source and free.Here's an example graph from it:[img]http://www.qualityunit.com/web/content/english/default/img/graph2.png[/img] Quote Link to comment https://forums.phpfreaks.com/topic/14533-pie-chart-or-bar-graph/#findComment-57608 Share on other sites More sharing options...
GingerRobot Posted July 13, 2006 Share Posted July 13, 2006 if you do want to do it yourself, you'll need to look into using the GD library functions. Quote Link to comment https://forums.phpfreaks.com/topic/14533-pie-chart-or-bar-graph/#findComment-57609 Share on other sites More sharing options...
Barand Posted July 13, 2006 Share Posted July 13, 2006 If you just show %correct for a single student then a pie is ideal.If you want to show all questions and the % of students who got each correct then use a column chart with a column for each question Quote Link to comment https://forums.phpfreaks.com/topic/14533-pie-chart-or-bar-graph/#findComment-57610 Share on other sites More sharing options...
realjumper Posted July 13, 2006 Author Share Posted July 13, 2006 Great, thank you all for your help.....I think a bar graph would be the way to go for each result, and a pie chart for the total at the end of the test. What I mean is.... After each question, once the user has selected one four possible answers, the new question appears as well as whether they got the previous question right or wrong and a running total of the number of right and wrong answers so far. So, a bar graph that reflects this progress would be good.....do you think?Once they complete the test, perhaps a pie chart as well as the total results bar graph of right and wrong would be good. I could also supply a link so that the student could review his errors.That sounds like a plan ;-) Quote Link to comment https://forums.phpfreaks.com/topic/14533-pie-chart-or-bar-graph/#findComment-57616 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.