Location: PHPKode > projects > PACSPulse > pacspulse/chart.php
<?php

/* 
PAC Pulse (PACS Perfomance optimization tool)
Copyright (C) 2001 Medical College of Wisconsin

This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

//Include the code
include ("globalvars.php");
include("phplot.php");

//querystring variables Typ,V,Dir,T,P
if (IsSet($Dir)){
 if ($Dir=='tx')
 {$direction='Outgoing';
 $dirsql=" and txrx='$Dir' ";}
 else
 {$direction='Incoming';
 $dirsql=" and txrx='$Dir' ";}
}
//page request type (network/device/modality)
switch ($P)
{
    case "N":
    $filtsql=" reverse(right(reverse(ip),length(ip)-locate('.',reverse(ip))))='$V' ";
    break;
    case "D":
    $filtsql=" nameMod='$V' ";
    break;
    case "M":
    $filtsql=" typeMod='$V' ";
    break;
}
//where $filtsql $dirsql
switch ($Typ)
{
    case 1:
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),count(distinct StudyUID) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      $max=0;  
      while ($row = mysql_fetch_array($sql_result)) {
        $example_data[]=array($row[0],$row[1]);
        if ($row[1]>$max){$max=$row[1];}
      }
      $graph = new PHPlot(500,300);
      $grinc=number_format($max/4,0);
      $graph->SetDataValues($example_data);
      $graph->SetXLabel('Week');
      $graph->SetYLabel('Number of Studies');
      $graph->SetTitle('Number of ' . $direction . ' Studies for ' . $V . ' by Week');
      $graph->SetPlotType('bars');
      $graph->SetXDataLabelMaxlength(4);
      $graph->SetVertTickIncrement("$grinc");
      $graph->SetPrecisionY("0");
      $graph->SetBackgroundColor("white");
      $graph->SetIsInline=("1");
      //Draw it
      $graph->DrawGraph();
    break;

    case 2:
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format(avg(size)/1000,0) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      $max=0;  
      while ($row = mysql_fetch_array($sql_result)) {
        $example_data[]=array($row[0],$row[1]);
        if ($row[1]>$max){$max=$row[1];}
      }
      $graph = new PHPlot(500,300);
      $grinc=number_format($max/4,0);
      $graph->SetDataValues($example_data);
      $graph->SetXLabel('Week');
      $graph->SetYLabel('Volume (GB)');
      $graph->SetTitle('Volume ' . $direction . ' size for ' . $V . ' by Week');
      $graph->SetPlotType('bars');
      $graph->SetXDataLabelMaxlength(4);
      $graph->SetVertTickIncrement("$grinc");
      $graph->SetPrecisionY("0");
      $graph->SetBackgroundColor("white");
      $graph->SetIsInline=("1");
      //Draw it
      $graph->DrawGraph();
    break;

    case 3:
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format(sum(numObj)/count(distinct StudyUID),0) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      $max=0;  
      while ($row = mysql_fetch_array($sql_result)) {
        $example_data[]=array($row[0],$row[1]);
        if ($row[1]>$max){$max=$row[1];}
      }
      $graph = new PHPlot(500,300);
      $grinc=number_format($max/4,0);
      $graph->SetDataValues($example_data);
      $graph->SetXLabel('Week');
      $graph->SetYLabel('Images per Study');
      $graph->SetTitle($direction . ' Images per Study for ' . $V . ' by Week');
      $graph->SetPlotType('bars');
      $graph->SetXDataLabelMaxlength(4);
      $graph->SetVertTickIncrement("$grinc");
      $graph->SetPrecisionY("0");
      $graph->SetBackgroundColor("white");
      $graph->SetIsInline=("1");
      //Draw it
      $graph->DrawGraph();
    break;

    case 4:
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format((sum(size)/sum(numObj)),0) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      $max=0;  
      while ($row = mysql_fetch_array($sql_result)) {
        $example_data[]=array($row[0],$row[1]);
        if ($row[1]>$max){$max=$row[1];}
      }
      $graph = new PHPlot(500,300);
      $grinc=number_format($max/4,0);
      $graph->SetDataValues($example_data);
      $graph->SetXLabel('Week');
      $graph->SetYLabel('Image Size');
      $graph->SetTitle($direction . ' Images Size (KB) for ' . $V . ' by Week');
      $graph->SetPlotType('bars');
      $graph->SetXDataLabelMaxlength(4);
      $graph->SetVertTickIncrement("$grinc");
      $graph->SetPrecisionY("0");
      $graph->SetBackgroundColor("white");
      $graph->SetIsInline=("1");
      //Draw it
      $graph->DrawGraph();
    break;

    case 5:
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format(avg(rate)/1000,3) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      $max=0;  
      while ($row = mysql_fetch_array($sql_result)) {
        $example_data[]=array($row[0],$row[1]);
        if ($row[1]>$max){$max=$row[1];}
      }
      $graph = new PHPlot(500,300);
      $grinc=number_format($max/4,0);
      $graph->SetDataValues($example_data);
      $graph->SetXLabel('Week');
      $graph->SetYLabel('Transfer Rate (MB/S)');
      $graph->SetTitle('Average ' . $direction . ' Transfer Rate (KB/S) for ' . $V );
      $graph->SetPlotType('bars');
      $graph->SetXDataLabelMaxlength(4);
      $graph->SetVertTickIncrement("$grinc");
      $graph->SetPrecisionY("0");
      $graph->SetBackgroundColor("white");
      $graph->SetIsInline=("1");
      //Draw it
      $graph->DrawGraph();
    break;

    case 6:
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format(avg(size/(numObj*rate)),1) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      $max=0;  
      while ($row = mysql_fetch_array($sql_result)) {
        $example_data[]=array($row[0],$row[1]);
        if ($row[1]>$max){$max=$row[1];}
      }
      $graph = new PHPlot(500,300);
      $grinc=number_format($max/4,0);
      $graph->SetDataValues($example_data);
      $graph->SetXLabel('Week');
      $graph->SetYLabel('Transfer Time Per Image (S)');
      $graph->SetTitle($direction . ' Transfer Time per Image (S) for ' . $V );
      $graph->SetPlotType('bars');
      $graph->SetXDataLabelMaxlength(4);
      $graph->SetVertTickIncrement("$grinc");
      $graph->SetPrecisionY("0");
      $graph->SetBackgroundColor("white");
      $graph->SetIsInline=("1");
      //Draw it
      $graph->DrawGraph();
    break;

    case 7:
      $db = mysql_select_db("pulsetest", $connection) or die ("Couldn't connect to DB Radtracker");
      $sql_command = "select Week(timestamp),format(avg(size/rate),1) from test where $filtsql $dirsql group by Week(timestamp)";
      $sql_result = mysql_query($sql_command,$connection) or die (mysql_error());
      $max=0;  
      while ($row = mysql_fetch_array($sql_result)) {
        $example_data[]=array($row[0],$row[1]);
        if ($row[1]>$max){$max=$row[1];}
      }
      $graph = new PHPlot(500,300);
      $grinc=number_format($max/4,0);
      $graph->SetDataValues($example_data);
      $graph->SetXLabel('Week');
      $graph->SetYLabel('Transfer Time (S)');
      $graph->SetTitle( $direction . ' Total Transfer Time (S) for ' . $V );
      $graph->SetPlotType('bars');
      $graph->SetXDataLabelMaxlength(4);
      $graph->SetVertTickIncrement("$grinc");
      $graph->SetPrecisionY("0");
      $graph->SetBackgroundColor("white");
      $graph->SetIsInline=("1");
      //Draw it
      $graph->DrawGraph();
    break;

}

?>
Return current item: PACSPulse