 |
 |
|
|
| |
| |
| |
|
|
| Articles about Graphs |
| | More Graphs of Top Colleges | | 2008-04-01 22:02:12 | | Part of applying to colleges is knowing how colleges value early decision or early action applications. Here’s some more data on other top schools. Note the most selective colleges have a goal or “quota” for the number of students taken from each in coming class vis-a-vis early decision pools. Miro Advantage [...] | | By: Miro Advantage, Test Prep, Admissions and College | | |
| | Build Dynamic HTML Graphs | | 2007-01-16 08:23:00 | | Using DHTML, you can build graphs that change without requiring even a page refresh. The result? Your users can play with data in real time. Something is fundamentally unsatisfying about the way the Web works. You click on a link, the page disappears, and that lovely spinning ball or ticking clock grinds by as a new page appears section by section, (hopefully) with the information you want. This certainly is not the interactivity we're all used to from our client-side applications. But, thank goodness, you can make an application that works without a page refresh. This hack shows you how to make an interactive scatter plot using a few graphics, some PHP, and a whole slew of JavaScript. The Code The index file, index.php, is shown in Example 1. Example 1. JavaScript, the real workhorse in this hack <?php $states = array(array("Alabama",4447100,1963711,52419.02,1675.01,50744,87.6,38.7),array("Alaska",626932,260978,663267.26,91316,571951.26,1.1,0.5),array("Arizona",5130632,2189189,113998.3,363.73,113634.57,45.2,19.3),array("Arkansas",2673400,1173043,53178.62,1110.45,52068.17,51.3,22.5),array("California",33871648,12214549,163695.57,7736.23,155959.34,217.2,78.3),array( "Colorado",4301261,1808037,104093.57,376.04,103717.53,41.5,17.4 ),…array( "Washington",5894121,2451075,71299.64,4755.58,66544.06,88.6,36.8 ),array( "West Virginia",1808344,844623,24229.76,152.03,24077.73,75.1,35.1 ),array( "Wisconsin",5363675,2321144,65497.82,11187.72,54310.1,98.8,42.7 ),array( "Wyoming",493782,223854,97813.56,713.16,97100.4,5.1,2.3 ),array( "Puerto Rico",3808610,1418476,5324.5,1899.94,3424.56,1112.1,414.2 ));?><html><head><script language="Javascript">var width = 300;var height = 300; var axes = ["population", "housing_units", "total_area", "total_water", "total_land", "people_density", "housing_density" ]; var data = [<?php $first = true; foreach( $states as $state ){ if ( !$first ) echo( "," );?>{ state: "<?php echo($state[0]); ?>",population: <?php echo($ | | By: php webtutorial | | |
|
|
|
| Build Lightweight HTML Graphs With PHP | | 2007-01-15 17:43:00 | | Use HTML to create simple graphs for your data. It seems as though every site you go to these days requires QuickTime or Flash so that you can see fancy images and graphs. For simple bar graphs, though, you don't need fancy image rendering or Flash movies. You can use this hack to create bar graphs with just a few HTML tables and some PHP. The result looks just as cool as those other Flash-heavy sites but doesn't require any extra plug-ins or downloads. The Code Save the code in Example 1 as htmlgraph.php. Example 1. Drawing some simple bar graphs <html> <? $data = array( array( "movies", 20 ), array( "food", 30 ), array( "workout", 10 ), array( "work", 40 ) ); $max = 0; foreach ( $data as $d ) { $max += $d[1]; } ?> <body> <table width="400" cellspacing="0" cellpadding="2"> <? foreach( $data as $d ) { $percent = ( $d[1] / $max ) * 100; ?> <tr> <td width="20%"><? echo( $d[0] ) ?></td> <td width="10%"><? echo( $d[1] ) ?>%</td> <td> <table width="<? echo($percent) ?>%" bgcolor="#aaa"> <tr><td> </td></tr> </table> </td> </tr> <? } ?> </table> </body> </html> You can use several techniques to create HTML graphs. I chose to use two tables; the first contains the textual data, and the second contains a set of nested tables, each with a width value based on the graph value in that row. I calculate the width by first finding the maximum value of the combined data, and storing that in $max. I then derive the percentage by dividing $max by the current value, and multiplying the result by 100 (to set the scale between 0 and 100). That number is stored in $percent, which is then used in the width attribute of the table. Running Use your browser to surf to the htmlgraph.php page. You should see something similar to Figure 1 Figure 1. The simple HTML graph as seen in Safari Start Running I admit that gray is not the prettiest color for a graph, so Example 2 is a | | By: php webtutorial | | |
|
|
| |
 |
|
| |
| |
|
 |