| 1 | <?php
|
|---|
| 2 | require_once("../phpchartdir.php");
|
|---|
| 3 |
|
|---|
| 4 | include("plotinclude.php");
|
|---|
| 5 |
|
|---|
| 6 | function GetData($db_id, $tables, $joins, $set, &$prim, &$val1, &$val2)
|
|---|
| 7 | {
|
|---|
| 8 | $query=GetQuery($tables, $joins, $set);
|
|---|
| 9 | // printf("query:%s<br>", $query);
|
|---|
| 10 | $result=mysql_query($query, $db_id);
|
|---|
| 11 |
|
|---|
| 12 | while ($row = mysql_fetch_row($result))
|
|---|
| 13 | {
|
|---|
| 14 | $prim[] = $row[0];
|
|---|
| 15 | $val1[] = $row[1];
|
|---|
| 16 | if ($_GET["plot"]=="val")
|
|---|
| 17 | $val2[] = $row[2];
|
|---|
| 18 | }
|
|---|
| 19 | mysql_free_result($result);
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | $primary=$_GET["prim"];
|
|---|
| 23 | $column=$_GET[$primary."Col"];
|
|---|
| 24 |
|
|---|
| 25 | //get data from db
|
|---|
| 26 | $db_id = mysql_pconnect($host, $user, $pw);
|
|---|
| 27 | if ($db_id==FALSE)
|
|---|
| 28 | {
|
|---|
| 29 | printf("mysql_connect returned the following error: %s\n", mysql_error());
|
|---|
| 30 | die("");
|
|---|
| 31 | }
|
|---|
| 32 | mysql_select_db($db);
|
|---|
| 33 |
|
|---|
| 34 | GetData($db_id, $tables, $joins, "", $prim, $val1, $val2);
|
|---|
| 35 | if (!empty($_GET["Set"]))
|
|---|
| 36 | GetData($db_id, $tables, $joins, "Set", $Setprim, $Setval1, $Setval2);
|
|---|
| 37 | if (!empty($_GET["Set2"]))
|
|---|
| 38 | GetData($db_id, $tables, $joins, "Set2", $Set2prim, $Set2val1, $Set2val2);
|
|---|
| 39 |
|
|---|
| 40 | mysql_close($db_id);
|
|---|
| 41 |
|
|---|
| 42 | //set up plot
|
|---|
| 43 | $c= new XYChart(640,400);//, 0xeeeeee, 0x000000, 1);
|
|---|
| 44 | //$c->setRoundedFrame();
|
|---|
| 45 | $c->setPlotArea(70, 45, 540, 300, 0xffffff, -1, 0xcccccc, 0xccccccc);
|
|---|
| 46 |
|
|---|
| 47 | //size of the symbols
|
|---|
| 48 | $small=2;//normal data
|
|---|
| 49 | $large=8;//set1, set2
|
|---|
| 50 | //fonts
|
|---|
| 51 | $titlesize=13;
|
|---|
| 52 | $font="arialbd.ttf";
|
|---|
| 53 | $axisfont="";
|
|---|
| 54 | $axissize=10;
|
|---|
| 55 | $labelfont="arialdb.ttf";
|
|---|
| 56 | $labelsize=10;
|
|---|
| 57 | //colours
|
|---|
| 58 | $colour=0x000000;
|
|---|
| 59 | $setcolour=0x0080ff;
|
|---|
| 60 | $set2colour=0xff0000;
|
|---|
| 61 |
|
|---|
| 62 | if ($_GET["plot"]=="val")
|
|---|
| 63 | {
|
|---|
| 64 | $column2=$_GET[$primary."Col2"];
|
|---|
| 65 | $c->addScatterLayer($val2, $val1, $column, CircleSymbol, $small, $colour, $colour);
|
|---|
| 66 | if (!empty($_GET["Set"]))
|
|---|
| 67 | $c->addScatterLayer($Setval2, $Setval1, $column, CircleSymbol, $large, $setcolour, $setcolour);
|
|---|
| 68 | if (!empty($_GET["Set2"]))
|
|---|
| 69 | $c->addScatterLayer($Set2val2, $Set2val1, $column, CircleSymbol, $large, $set2colour, $set2colour);
|
|---|
| 70 | $c->yAxis->setTitle($column, $axisfont, $axissize);
|
|---|
| 71 | $c->xAxis->setTitle($column2, $axisfont, $axissize);
|
|---|
| 72 | $textBoxObj = $c->addTitle(ltrim($column, "f")." vs ".ltrim($column2, "f"), $font, $titlesize);
|
|---|
| 73 | }
|
|---|
| 74 | else
|
|---|
| 75 | {
|
|---|
| 76 | $c->addScatterLayer($prim, $val1, $column, CircleSymbol, $small, $colour, $colour);
|
|---|
| 77 | if (!empty($_GET["Set"]))
|
|---|
| 78 | $c->addScatterLayer($Setprim, $Setval1, $column, CircleSymbol, $large, $setcolour, $setcolour);
|
|---|
| 79 | if (!empty($_GET["Set2"]))
|
|---|
| 80 | $c->addScatterLayer($Set2prim, $Set2val1, $column, CircleSymbol, $large, $set2colour, $set2colour);
|
|---|
| 81 | $c->yAxis->setTitle($column, $axisfont, $axissize);
|
|---|
| 82 | $c->xAxis->setTitle($primary, $axisfont, $axissize);
|
|---|
| 83 | $textBoxObj = $c->addTitle(ltrim($column,"f")." vs ".ltrim($primary,"f"), $font, $titlesize);
|
|---|
| 84 | }
|
|---|
| 85 | //get scaling of the yAxis
|
|---|
| 86 | if (!empty($_GET[$column."Start"]) && !empty($_GET[$column."Stop"]))
|
|---|
| 87 | {
|
|---|
| 88 | $start=$_GET[$column."Start"];
|
|---|
| 89 | $stop=$_GET[$column."Stop"];
|
|---|
| 90 | $numticks=($stop-$start)/4;
|
|---|
| 91 | $numticks2=($stop-$start)/8;
|
|---|
| 92 | $c->yAxis->setLinearScale($start, $stop, $numticks, $numticks2);
|
|---|
| 93 | }
|
|---|
| 94 | //background of title
|
|---|
| 95 | $textBoxObj->setBackground(0xccccff,-1, softLighting());
|
|---|
| 96 | $c->xAxis->setLabelStyle($labelfont, $labelsize);
|
|---|
| 97 | $c->yAxis->setLabelStyle($labelfont, $labelsize);
|
|---|
| 98 |
|
|---|
| 99 | header("Content-type: image/png");
|
|---|
| 100 | print($c->makeChart2(PNG));
|
|---|
| 101 |
|
|---|
| 102 | ?>
|
|---|