JPGraph Part 1
July 18th, 2007I really like JPGraph now. For too long I hated it as a clunky, bloated rather useless graphing library (Sorry!), but now I like it. Really like it.
Over the next few months I’ll be doing a series of articles on using JPGraph.
For now, heres my favourite feature at the moment.
Save the following code as make_image_led.php
require_once '_common_includes/jpgraph/jpgraph.php';
require_once '_common_includes/jpgraph/jpgraph_led.php';
$_GET['value'] = str_pad($_GET['value'],’6′,’0′,STR_PAD_LEFT);
$led = new DigitalLED74();
$led->SetSupersampling(4);
$led->StrokeNumber($_GET['value'],LEDC_BLUE);
To generate an image, just call from another page;
echo '<img src="make_image_led?value='.$NUMBER.'" alt="image" />';
I pull the number from the database;
$count_1_rs = $conn->CacheExecute(180,'SELECT COUNT(id) AS id FROM SOME_TABLE;');
echo '<img src="http://bloke.org/wordpress/wp-admin/make_image_led?value=%27.$count_1_rs-%3Efields%5B%27id%27%5D.%27" alt="image" />';
Which generates one of the following;
Nice, huh?
| Bookmark it del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Propeller | Yahoo |
Was this post useful to you? Let me know, buy me a beer!
Alternatively, if you're feeling impecunious, you may like to subscribe to my RSS feed, or see other articles in the PHP category.