source: trunk/MagicSoft/Mars/datacenter/db/plot.php@ 8381

Last change on this file since 8381 was 8161, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 3.1 KB
Line 
1<?php
2 require_once("../phpchartdir.php");
3
4include("plotinclude.php");
5
6function 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);
27if ($db_id==FALSE)
28{
29 printf("mysql_connect returned the following error: %s\n", mysql_error());
30 die("");
31}
32mysql_select_db($db);
33
34GetData($db_id, $tables, $joins, "", $prim, $val1, $val2);
35if (!empty($_GET["Set"]))
36 GetData($db_id, $tables, $joins, "Set", $Setprim, $Setval1, $Setval2);
37if (!empty($_GET["Set2"]))
38 GetData($db_id, $tables, $joins, "Set2", $Set2prim, $Set2val1, $Set2val2);
39
40mysql_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;
57if ($_GET["plot"]=="val")
58{
59 $column2=$_GET[$primary."Col2"];
60 $c->addScatterLayer($val2, $val1, $column, CircleSymbol, $small, 0x000000, 0x000000);
61 if (!empty($_GET["Set"]))
62 $c->addScatterLayer($Setval2, $Setval1, $column, CircleSymbol, $large, 0x0080ff, 0x0080ff);
63 if (!empty($_GET["Set2"]))
64 $c->addScatterLayer($Set2val2, $Set2val1, $column, CircleSymbol, $large, 0xff0000, 0xff0000);
65 $c->yAxis->setTitle($column, $axisfont, $axissize);
66 $c->xAxis->setTitle($column2, $axisfont, $axissize);
67 $textBoxObj = $c->addTitle(ltrim($column, "f")." vs ".ltrim($column2, "f"), $font, $titlesize);
68}
69else
70{
71 $c->addScatterLayer($prim, $val1, $column, CircleSymbol, $small, 0x000000, 0x000000);
72 if (!empty($_GET["Set"]))
73 $c->addScatterLayer($Setprim, $Setval1, $column, CircleSymbol, $large, 0x0080ff, 0x0080ff);
74 if (!empty($_GET["Set2"]))
75 $c->addScatterLayer($Set2prim, $Set2val1, $column, CircleSymbol, $large, 0xff0000, 0xff0000);
76 $c->yAxis->setTitle($column, $axisfont, $axissize);
77 $c->xAxis->setTitle($primary, $axisfont, $axissize);
78 $textBoxObj = $c->addTitle(ltrim($column,"f")." vs ".ltrim($primary,"f"), $font, $titlesize);
79}
80//get scaling of the yAxis
81if (!empty($_GET[$column."Start"]) && !empty($_GET[$column."Stop"]))
82{
83 $start=$_GET[$column."Start"];
84 $stop=$_GET[$column."Stop"];
85 $numticks=($stop-$start)/4;
86 $numticks2=($stop-$start)/8;
87 $c->yAxis->setLinearScale($start, $stop, $numticks, $numticks2);
88}
89//background of title
90$textBoxObj->setBackground(0xccccff,-1, softLighting());
91$c->xAxis->setLabelStyle($labelfont, $labelsize);
92$c->yAxis->setLabelStyle($labelfont, $labelsize);
93
94header("Content-type: image/png");
95print($c->makeChart2(PNG));
96
97?>
Note: See TracBrowser for help on using the repository browser.