$inc_types = array();
while ($row = stripslashes_deep(mysql_fetch_array($result), MYSQL_ASSOC)) {
    // build assoc arrays of types and counts
    if (array_key_exists($row['in_types_id'], $inc_types)) {
        $inc_types[$row['in_types_id']]++;
    } else {
        $inc_types[$row['in_types_id']] = 1;
    }
}
// end while($row =...)
include 'baaChart.php';
$width = isset($img_width) ? $img_width : $type_diam;
// 3/21/10
$mygraph = new baaChart($width);
//$mygraph->setTitle($from,$to);
$mygraph->setTitle('Incidents by Type', '');
//dump ($inc_types);
foreach ($inc_types as $key => $val) {
    if (strlen($key) > 0) {
        $mygraph->addDataSeries('P', PIE_CHART_PCENT + PIE_LEGEND_VALUE, $val, $inc_types_text[$key]);
    }
}
// end foreach()
$mygraph->setBgColor(0, 0, 0, 1);
//transparent background
$mygraph->setChartBgColor(0, 0, 0, 1);
//as background
$mygraph->drawGraph();
/*
include('baaChart.php');
	$mygraph = new baaChart(1000);
    // build assoc arrays of types and counts
    if (array_key_exists($row['severity'], $severities)) {
        $severities[$row['severity']]++;
    } else {
        $severities[$row['severity']] = 1;
    }
}
//dump ($severities);
//$severities = ksort ($severities);
$legends = array("NORMAL", "MEDIUM", "HIGH");
include 'baaChart.php';
$width = isset($img_width) ? $img_width : $severity_diam;
// 3/21/10
$mygraph = new baaChart($width);
//$mygraph->setTitle($from, $to);
$mygraph->setTitle("Incidents by Severity", "");
foreach ($severities as $key => $val) {
    if (strlen($key) > 0) {
        $mygraph->addDataSeries('P', PIE_CHART_PCENT + PIE_LEGEND_VALUE, $val, $legends[$key]);
    }
}
// end foreach()
$mygraph->setBgColor(0, 0, 0, 1);
// transparent background
$mygraph->setChartBgColor(0, 0, 0, 1);
// as background
$mygraph->setSeriesColor(1, 222, 227, 231);
// normal severity
$mygraph->setSeriesColor(2, 102, 102, 204);
// medium
$mygraph->setSeriesColor(3, 255, 0, 0);
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), __FILE__, __LINE__);
$cities = array();
while ($row = stripslashes_deep(mysql_fetch_array($result), MYSQL_ASSOC)) {
    // build assoc arrays of types and counts
    if (array_key_exists($row['tick_city'], $cities)) {
        $cities[$row['tick_city']]++;
    } else {
        $cities[$row['tick_city']] = 1;
    }
}
//dump ($cities);
include 'baaChart.php';
$width = isset($img_width) ? $img_width : $location_diam;
// 3/21/10
$mygraph = new baaChart($width);
$mygraph->setTitle("Incidents by Location", "");
foreach ($cities as $key => $val) {
    $mygraph->addDataSeries('P', PIE_CHART_PCENT + PIE_LEGEND_VALUE, $val, $key);
}
// end foreach()
$mygraph->setBgColor(0, 0, 0, 1);
// transparent background
$mygraph->setChartBgColor(0, 0, 0, 1);
// as background
$mygraph->setSeriesColor(1, 222, 227, 231);
//
$mygraph->setSeriesColor(2, 102, 102, 204);
//
$mygraph->setSeriesColor(3, 255, 0, 0);
//
$mygraph->drawGraph();