the most efficent & all around best way to create graphs

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

the most efficent & all around best way to create graphs

Post by m3mn0n »

I would like ones similar to the ones here:

http://playteq.com/stats.asp

The options I've explored are Ming and SVG. Out of the two, so far Ming is looking to be the one i go with. SVG = XML Derivative and the book I read about it cautioned me to be wary about compatability issues from browser to browser and etc. Also Ming seems to be the best choice since the coding would be all php and no XML, plus there isn't a pc around without the flash plugin. ;)

Is there anything else possible? Any recommendations? And if you know of any good prebuilt classes for graphs in php/mysql please let me know.

Thanks in advanced.
Judas
Forum Commoner
Posts: 67
Joined: Tue Jun 10, 2003 3:34 pm
Location: Netherlands

Post by Judas »

I wich i knowe more about PHP rendering .swf
Unipus
Forum Contributor
Posts: 409
Joined: Tue Aug 26, 2003 2:06 pm
Location: Los Angeles, CA

Post by Unipus »

You mean, "I wish I knew more about Flash." PHP's rendering has very little to do with it, as far as I know. Flash simply accepts variables that you can pass to it from PHP. You can use those variables in your ActionScript to make neat things happen. I don't know of any pre-built solutions, though, and there are a few good reasons not to make infographics in Flash anyway.
Judas
Forum Commoner
Posts: 67
Joined: Tue Jun 10, 2003 3:34 pm
Location: Netherlands

Post by Judas »

O boy .
pfff :)

Take a look at this you can also create flash with PHP .
The 1 thing = ya must install it first.

Code: Select all

<?php
swf_openfile ("test.swf", 256, 256, 30, 1, 1, 1);
swf_ortho2 (-100, 100, -100, 100);
swf_defineline (1, -70, 0, 70, 0, .2);
swf_definerect (4, 60, -10, 70, 0, 0);
swf_definerect (5, -60, 0, -70, 10, 0);
swf_addcolor (0, 0, 0, 0);

swf_definefont (10, "Mod");
swf_fontsize (5);
swf_fontslant (10);
swf_definetext (11, "This be Flash wit PHP!", 1);

swf_pushmatrix ();
swf_translate (-50, 80, 0);
swf_placeobject (11, 60);
swf_popmatrix ();

for ($i = 0; $i < 30; $i++) &#123;
    $p = $i/(30-1);
    swf_pushmatrix ();
    swf_scale (1-($p*.9), 1, 1);
    swf_rotate (60*$p,  'z');
    swf_translate (20+20*$p, $p/1.5, 0);
    swf_rotate (270*$p,  'z');
    swf_addcolor ($p, 0, $p/1.2, -$p);
    swf_placeobject (1, 50);
    swf_placeobject (4, 50);
    swf_placeobject (5, 50);
    swf_popmatrix ();
    swf_showframe ();
&#125;

for ($i = 0; $i < 30; $i++) &#123;
    swf_removeobject (50);
    if (($i%4) == 0) &#123;
        swf_showframe ();
    &#125;
&#125;

swf_startdoaction ();
swf_actionstop ();
swf_enddoaction ();

swf_closefile ();
?>
code from http://nl3.php.net/swf

also note this site http://www.blue-pac.com/
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

as all those graphs ar cron'd either hourly or every 12 hours you hardly need flash at all - could as easily do it with server cached images.
writing the algorythm to create them from a data array wouldn't be at all tricky - just a matter of running a gradient background and slinging a few lines and points on them.

With a bit of work (and some free time) and GD above 2.0.4 I could more than likely get better results than they have there just by creating cached ping files. An example of a graphing function using just GD (note. when I get time I will improve the render algorythm about 5 fold and will change to a gaussian anti-alias technique for smoother results.

As mentioned on that page, I will be distro'ing a DataGraphs class when I have time to finish the seperate functions.
You might also check out jpGraph as another free distro.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Wow that donut chart is cool. I will definatley test it out.

Any solutions for bar & scatter plot charts?
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

Just about all graph style imaginable are 'on the agenda' - just a matter of finding the time between other ventures. Realistically I am not going to have anything distro'able for at least a month.

Am deliberating on the line graph approach as a shaded tube style gives the impression of the lines growing toward the foreground ( eg http://www.teckis.com/scriptix/datagraphs/s.php.png ) - might need a rhombus perspective background to balance it. Obviously a lot more work to do there before anything becomes usable.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Looks great. I'm looking forward to your apps release.


I never relized the imaging power of the gd library until now, heh. I will be tinkering around a lot more than usual with it now. Thanks for the eye-opener. ;)
Post Reply