Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Re: Web graph ?????

    I've a couple of tricks to generate bar charts on the fly, using GD in one
    instance, and spacer images/TD cells in the other

    Using GD / javascript:

    graph.htm

    <script language="javascript">
    function VUgauge(gaugeID)
    {
    var n=20;
    var time=new Date();
    var n=time.getSeconds();
    n=Math.floor((n*100)/60);

    document.getElementById(gaugeID).src='makepng.php? percent='+n;
    var temp=setTimeout("VUgauge('gauge1')",1000);
    }
    </script>

    <body onLoad="VUgauge('gauge1');">
    <img name="guage1" alt="bar size controlled by javascript function VUgauge">
    <img src="graph.php?percent=45" alt="bar size set by percent parameter">
    </body>

    graph.php

    <?php
    // read url parameter 'percent'
    $percent=$_GET["percent"];
    // calculate size of bar
    $x1=floor(460*($percent/100));

    // build image
    $im = ImageCreate(500, 50);

    // set colours, first colour created is background
    $black = ImageColorAllocate($im, 0, 0, 0);
    $white = ImageColorAllocate($im, 255, 255, 255);
    $red = ImageColorAllocate($im, 255, 0, 0);

    // set up array defining vertices of hexagonal bar, width depends on
    'percent' parameter
    $points=array(10,25,20,45,($x1+20),45,($x1+30),25, ($x1+20),5,20,5);

    // draw polygon using array 'points' and colour red
    imagefilledpolygon($im,$points,6,$red);

    // write text on top of bar
    imagestring($im,5,20,20,$percent.'%',$white);

    // send the image to the browser
    header("Content-type: image/png");
    ImagePNG($im);

    // tidy up
    ImageDestroy($im);
    ?>


    and for TD cells

    <?php
    $tablewidth=500;
    $value=45;
    $total=200;

    $cell1=$tablewidth*($value/$total);
    $cell2=$tablewidth-$cell1;

    echo "<tr>";
    echo "<td><td width=\"".$cell1."\" bgcolor=\"#ff0000\"><img
    src=\"images/spacer.gif\" width=\"".$cell1."\"></td>";
    echo "<td><td width=\"".$cell2."\" bgcolor=\"#eeeeee\"><img
    src=\"images/spacer.gif\" width=\"".$cell2."\"></td>";
    echo "</tr>";
    ?>

    "E-Star" <unix_core@linuxmail.org> wrote in message
    news:150720030242250833%unix_core@linuxmail.org...
    > I'm trying to build a webiste that produced a graph. Any good php
    > packages out there?
    >
    > I came across Web Chart Creator ([url]www.ankord.com[/url]). Is this any good?
    > Any one use it?

    Richard Hockey Guest

  2. Similar Questions and Discussions

    1. Graph.0.69 Module---how to get a DAG from graph with cycles
      Here I use an example to illustrate the problem I met when using Graph Theory Module: I have a directed graph looks like the following (see the...
    2. GD graph, Several Colors per Bar?
      Hi. I'm struggling with a GD::Graph -problem. I want to create a graph with bars by adding(+) the execution time from each little job within my...
    3. GD::Graph - how to get rid of leading gap in line graph?
      Is there a way to get rid of the leading gap to the left of a line graph? Therefore, I want the graph line to start on the Y-axis, not the...
    4. ANNOUNCE: Graph::Timeline and Graph::Timeline::GD 1.0
      Graph::Timeline - Render timeline data This document refers to verion 0.1 of Graph::Timeline, released November 11, 2003 This class takes a...
    5. save graph to gif or jpg
      Is there / what is the PHP function that saves a dynamcially drawn chart to a image file (either gif or jpeg)? Also, an advanced PHP book...
  3. #2

    Default Re: Web graph ?????

    E-Star wrote:
    > I'm trying to build a webiste that produced a graph. Any good php
    > packages out there?
    >
    > I came across Web Chart Creator ([url]www.ankord.com[/url]). Is this any good?
    > Any one use it?
    I use jpGraph ([url]www.aditus.nu/jpgraph[/url])


    Kevin Thorpe Guest

  4. #3

    Default Re: Web graph ?????

    Daniel Bußmeyer <daniel@bussmeyer.com> wrote in message news:<bf0mis$9rotv$1@ID-199942.news.uni-berlin.de>...
    > Kevin Thorpe wrote:
    > > E-Star wrote:
    > >
    > >> I'm trying to build a webiste that produced a graph. Any good php
    > >> packages out there?
    > >>
    > >> I came across Web Chart Creator ([url]www.ankord.com[/url]). Is this any good?
    > >> Any one use it?
    > >
    > >
    > > I use jpGraph ([url]www.aditus.nu/jpgraph[/url])
    > >
    > >
    > Hi!
    >
    > You can try baaChart. It's a lib you can use to draw many kinds of
    > 2d-charts.
    > try: [url]http://members.aol.com/barryaandrew/baaChart/baachartguide.html[/url]
    I used phplot and found it to be very useful: [url]http://www.phplot.com[/url]
    Klym Guest

  5. #4

    Default Re: Web graph ?????

    On 15 Jul 2003, E-Star <unix_core@linuxmail.org> impressively belched the
    following:
    > I'm trying to build a webiste that produced a graph. Any good php
    > packages out there?
    >
    > I came across Web Chart Creator ([url]www.ankord.com[/url]). Is this any good?
    > Any one use it?
    ladies and gentlemen, in 3rd place this week on phpclasses.org:

    3rd Place:
    Herman Veluwenkamp
    Class - Graph Drawing Class 2
    [url]http://www.phpclasses.org/browse.html/package/176.html[/url]
    Wins - developers version of Template Tamer.
    Bad Man Guest

  6. #5

    Default Re: Web graph ?????

    E-Star wrote:
    > I'm trying to build a webiste that produced a graph. Any good php
    > packages out there?
    >
    > I came across Web Chart Creator ([url]www.ankord.com[/url]). Is this any good?
    > Any one use it?
    Like Kevin Thorpe, I use JPGraph.

    It is extremely thourough and flexible.



    Disco Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139