source: trunk/Mars/datacenter/db/plot.php@ 17386

Last change on this file since 17386 was 17386, checked in by tbretz, 11 years ago
Removed svn:executable property, these are no executables.
File size: 3.4 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
43if (empty($_GET["x"]))
44 $x=640;
45else
46 $x=$_GET["x"];
47if (empty($_GET["y"]))
48 $y=400;
49else
50 $y=$_GET["y"];
51
52$c= new XYChart($x,$y);//, 0xeeeeee, 0x000000, 1);
53$c->setPlotArea(70, 45, $x-100, $y-100, 0xffffff, -1, 0xcccccc, 0xccccccc);
54//$c= new XYChart(440,250);//, 0xeeeeee, 0x000000, 1);
55//$c->setPlotArea(70, 45, 340, 150, 0xffffff, -1, 0xcccccc, 0xccccccc);
56//$c->setRoundedFrame();
57
58//size of the symbols
59$small=2;//normal data
60$large=8;//set1, set2
61//fonts
62$titlesize=13;
63$font="arialbd.ttf";
64$axisfont="";
65$axissize=10;
66$labelfont="arialdb.ttf";
67$labelsize=10;
68//colours
69$colour=0x000000;
70$setcolour=0x0080ff;
71$set2colour=0xff0000;
72
73if ($_GET["plot"]=="val")
74{
75 $column2=$_GET[$primary."Col2"];
76 $c->addScatterLayer($val2, $val1, $column, CircleSymbol, $small, $colour, $colour);
77 if (!empty($_GET["Set"]))
78 $c->addScatterLayer($Setval2, $Setval1, $column, CircleSymbol, $large, $setcolour, $setcolour);
79 if (!empty($_GET["Set2"]))
80 $c->addScatterLayer($Set2val2, $Set2val1, $column, CircleSymbol, $large, $set2colour, $set2colour);
81 $c->yAxis->setTitle($column, $axisfont, $axissize);
82 $c->xAxis->setTitle($column2, $axisfont, $axissize);
83 $textBoxObj = $c->addTitle(ltrim($column, "f")." vs ".ltrim($column2, "f"), $font, $titlesize);
84}
85else
86{
87 $c->addScatterLayer($prim, $val1, $column, CircleSymbol, $small, $colour, $colour);
88 if (!empty($_GET["Set"]))
89 $c->addScatterLayer($Setprim, $Setval1, $column, CircleSymbol, $large, $setcolour, $setcolour);
90 if (!empty($_GET["Set2"]))
91 $c->addScatterLayer($Set2prim, $Set2val1, $column, CircleSymbol, $large, $set2colour, $set2colour);
92 $c->yAxis->setTitle($column, $axisfont, $axissize);
93 $c->xAxis->setTitle($primary, $axisfont, $axissize);
94 $textBoxObj = $c->addTitle(ltrim($column,"f")." vs ".ltrim($primary,"f"), $font, $titlesize);
95}
96//get scaling of the yAxis
97if (!empty($_GET[$column."Start"]) && !empty($_GET[$column."Stop"]))
98{
99 $start=$_GET[$column."Start"];
100 $stop=$_GET[$column."Stop"];
101 $numticks=($stop-$start)/4;
102 $numticks2=($stop-$start)/8;
103 $c->yAxis->setLinearScale($start, $stop, $numticks, $numticks2);
104}
105//background of title
106$textBoxObj->setBackground(0xccccff,-1, softLighting());
107$c->xAxis->setLabelStyle($labelfont, $labelsize);
108$c->yAxis->setLabelStyle($labelfont, $labelsize);
109
110header("Content-type: image/png");
111print($c->makeChart2(PNG));
112
113?>
Note: See TracBrowser for help on using the repository browser.