kieranbarnes Independent PHP, WordPress & CubeCart Programmer

JPGraph Part 1

Posted on July 18, 2007

I 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-&gt;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;

untitled.PNG

Nice, huh?


Related posts

  1. Idiot Proof Lightbox
    I've just made some modifications to my Gallery code which is part of i9000's small...
  2. CAPTCHA Image Generation Part 2
    A quick morning hack - I added some random lines to try and confuse the...
  3. [Snippet] Simplified UK/US Date Conversion
    One of my major annoyances in PHP & MySQL world is the different formats when...
  4. [Snippet] Formatting an IMEI Number in PHP
    Formatting an IMEI number in PHP is reasonably simple. The IMEI (14 decimal digits plus...
  5. Retro Fitting Record Pagination with ADOdb
    For my first project of the New Year I had to retro-fit pagination controls to...

Posted by Kieran


Tagged as: , Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.