Inheritance: extends GridGraph
 /**
  * construct multigraph
  */
 public function Values($values)
 {
     parent::Values($values);
     if (!$this->values->error) {
         $this->multi_graph = new MultiGraph($this->values, $this->force_assoc, $this->datetime_keys, $this->require_integer_keys);
     }
 }
 /**
  * Generate the output html from the template file.
  */
 function generate()
 {
     global $smarty;
     $rows = array();
     $max = 0;
     for ($i = 1; $i <= $this->length_; $i++) {
         $row = $this->toplist_->getRow();
         if ($row) {
             $rows[] = $row;
         }
         if ($row['cnt'] > $max) {
             $max = $row['cnt'];
         }
     }
     if (empty($rows)) {
         return;
     }
     $pilot = new Pilot($rows[0]['plt_id']);
     $smarty->assign('title', $this->title_);
     $smarty->assign('pilot_portrait', $pilot->getPortraitURL(64));
     $smarty->assign('award_img', config::get('cfg_img') . "/awards/" . $this->award_ . ".png");
     $smarty->assign('url', edkURI::build(array('a', 'pilot_detail', true), array('plt_id', $rows[0]['plt_id'], true)));
     $smarty->assign('name', $pilot->getName());
     $bar = new BarGraph($rows[0]['cnt'], $max);
     $smarty->assign('bar', $bar->generate());
     $smarty->assign('cnt', $rows[0]['cnt']);
     for ($i = 2; $i < $this->length_ + 1; $i++) {
         if (!$rows[$i - 1]['plt_id']) {
             break;
         } else {
             if (!$rows[$i - 1]['plt_name']) {
                 $pilot = new Pilot($rows[$i - 1]['plt_id']);
                 $pilotname = $pilot->getName();
             } else {
                 $pilotname = $rows[$i - 1]['plt_name'];
             }
         }
         $bar = new BarGraph($rows[$i - 1]['cnt'], $max);
         $top[$i] = array('url' => edkURI::build(array('a', 'pilot_detail', true), array('plt_id', $rows[$i - 1]['plt_id'], true)), 'name' => $pilotname, 'bar' => $bar->generate(), 'cnt' => $rows[$i - 1]['cnt']);
     }
     $smarty->assign('top', $top);
     $smarty->assign('comment', $this->comment_);
     return $smarty->fetch(get_tpl('award_box'));
 }
 /**
  * Sets up the colour class with corrected number of colours
  */
 protected function ColourSetup($count, $datasets = NULL)
 {
     // $count is off by 1 because the divisions are numbered
     return parent::ColourSetup($count - 1, $datasets);
 }
 /**
  * Overridden to prevent drawing behind higher bars
  * $offset_y should be true for inner bars
  */
 protected function BarLabel(&$item, &$bar, $offset_y = null)
 {
     $font_size = $this->bar_label_font_size;
     $space = $this->bar_label_space;
     if ($offset_y) {
         // bar too small, would be above
         if ($bar['height'] < $font_size + 2 * $space) {
             return parent::BarLabel($item, $bar, ($bar['height'] + $font_size) / 2);
         }
         // option set to above
         if ($this->bar_label_position == 'above') {
             $this->bar_label_position = 'top';
             $label = parent::BarLabel($item, $bar);
             $this->bar_label_position = 'above';
             return $label;
         }
     }
     return parent::BarLabel($item, $bar);
 }
Beispiel #5
0
<?php

require '../SVGraph.php';
$graph = new BarGraph();
$graph->setGraphTitle('My bar graph');
$graph->setGraphDescription('Just a demo');
$graph->setXAxisLabel('My X-Axis');
$graph->setYAxisLabel('My Y-Axis');
$graph->setXAxis(array('put', 'some', 'text', 'or', 'values', 'like', 0, 'or', 0.75, 'here'));
$graph->addDataRow(array(1, 1, 1, 1, 1, 1, 1, 10, 15, 20), 'My first data row');
$graph->addDataRow(array(0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5), 'My second data row');
$graph->addDataRow(array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1), 'My third data row');
$graph->addAverage(0, 'Average for my first data row');
$graph->addMovingAverage(2, 0, 'Moving average for my first data row');
$graph->addAverage();
// Total average line
//print_r($graph);
//$graph->output();
Beispiel #6
0
 /**
  *  Build the killlists that are needed for the options selected.
  */
 function killList()
 {
     if (isset($this->viewList[$this->view])) {
         return call_user_func_array($this->viewList[$this->view], array(&$this));
     }
     $scl_id = (int) edkURI::getArg('scl_id');
     global $smarty;
     $html = '';
     $smarty->assign('view', $this->view);
     switch ($this->view) {
         case "":
             $targets = array();
             $curtarget = array();
             while ($target =& $this->contract->getContractTarget()) {
                 $kl =& $target->getKillList();
                 $ll =& $target->getLossList();
                 $summary = new KillSummaryTable($kl, $ll);
                 $summary->setVerbose(true);
                 $summary->setView('combined');
                 $curtargets['type'] = $target->getType();
                 $curtargets['id'] = $target->getID();
                 $curtargets['name'] = $target->getName();
                 $curtargets['summary'] = $summary->generate();
                 if ($summary->getTotalKillISK()) {
                     $curtargets['efficiency'] = round($summary->getTotalKillISK() / ($summary->getTotalKillISK() + $summary->getTotalLossISK()) * 100, 2);
                 } else {
                     $curtargets['efficiency'] = 0;
                 }
                 $curtargets['total_kills'] = $summary->getTotalKills();
                 $curtargets['total_losses'] = $summary->getTotalLosses();
                 $curtargets['total_kill_isk'] = round($summary->getTotalKillISK() / 1000000000, 2);
                 $curtargets['total_loss_isk'] = round($summary->getTotalLossISK() / 1000000000, 2);
                 $bar = new BarGraph($curtargets['efficiency'], 100, 120);
                 $curtargets['bar'] = $bar->generate();
                 $targets[] = $curtargets;
             }
             $smarty->assignByRef('targets', $targets);
             $smarty->assign('akey', session::isAdmin() ? session::makeKey() : false);
             $html .= $smarty->fetch(get_tpl('cc_detail_lists'));
             break;
         case "recent_activity":
             $this->contract = new Contract($this->ctr_id);
             $klist = $this->contract->getKillList();
             $klist->setOrdered(true);
             if ($scl_id) {
                 $klist->addVictimShipClass($scl_id);
             } else {
                 $klist->setPodsNoobShips(config::get('podnoobs'));
             }
             $table = new KillListTable($klist);
             $table->setLimit(10);
             $smarty->assign('killtable', $table->generate());
             $llist = $this->contract->getLossList();
             $llist->setOrdered(true);
             if ($scl_id) {
                 $llist->addVictimShipClass($scl_id);
             } else {
                 $llist->setPodsNoobShips(config::get('podnoobs'));
             }
             $table = new KillListTable($llist);
             $table->setLimit(10);
             $smarty->assign('losstable', $table->generate());
             $smarty->assign('akey', session::isAdmin() ? session::makeKey() : false);
             $html .= $smarty->fetch(get_tpl('cc_detail_lists'));
             break;
         case "kills":
             $this->contract = new Contract($this->ctr_id);
             $list = $this->contract->getKillList();
             $list->setOrdered(true);
             if ($scl_id) {
                 $list->addVictimShipClass($scl_id);
             } else {
                 $list->setPodsNoobShips(config::get('podnoobs'));
             }
             $list->setPageSplit(config::get('killcount'));
             $pagesplitter = new PageSplitter($list->getCount(), config::get('killcount'));
             $table = new KillListTable($list);
             $smarty->assign('killtable', $table->generate());
             $smarty->assign('splitter', $pagesplitter->generate());
             $smarty->assign('akey', session::isAdmin() ? session::makeKey() : false);
             $html .= $smarty->fetch(get_tpl('cc_detail_lists'));
             break;
         case "losses":
             $this->contract = new Contract($this->ctr_id);
             $llist = $this->contract->getLossList();
             $llist->setOrdered(true);
             if ($scl_id) {
                 $llist->addVictimShipClass($scl_id);
             } else {
                 $llist->setPodsNoobShips(config::get('podnoobs'));
             }
             $llist->setPageSplit(config::get('killcount'));
             $pagesplitter = new PageSplitter($llist->getCount(), config::get('killcount'));
             $table = new KillListTable($llist);
             $smarty->assign('losstable', $table->generate());
             $smarty->assign('splitter', $pagesplitter->generate());
             $smarty->assign('akey', session::isAdmin() ? session::makeKey() : false);
             $html .= $smarty->fetch(get_tpl('cc_detail_lists'));
             break;
     }
     return $html;
 }
 /**
  * Returns the style options for bar labels (and totals)
  */
 public function DataLabelStyle($dataset, $index, &$item)
 {
     $style = parent::DataLabelStyle($dataset, $index, $item);
     if (strpos($dataset, 'total') === 0) {
         // total settings can override label settings
         $opts = array('font' => 'bar_total_font', 'font_size' => 'bar_total_font_size', 'font_weight' => 'bar_total_font_weight', 'colour' => 'bar_total_colour', 'space' => 'bar_total_space', 'type' => 'bar_total_type', 'font_adjust' => 'bar_total_font_adjust', 'back_colour' => 'bar_total_back_colour', 'angle' => 'bar_total_angle', 'round' => 'bar_total_round', 'stroke' => 'bar_total_outline_colour', 'stroke_width' => 'bar_total_outline_thickness', 'fill' => 'bar_total_fill', 'tail_width' => 'bar_total_tail_width', 'tail_length' => 'bar_total_tail_length', 'shadow_opacity' => 'bar_total_shadow_opacity', 'pad_x' => 'bar_total_padding_x', 'pad_y' => 'bar_total_padding_y');
         // special case
         $opt = 'bar_total_padding';
         if (isset($this->settings[$opt]) && !empty($this->settings[$opt])) {
             $style['pad_x'] = $this->settings[$opt];
             $style['pad_y'] = $this->settings[$opt];
         }
         foreach ($opts as $key => $opt) {
             if (isset($this->settings[$opt]) && !empty($this->settings[$opt])) {
                 $style[$key] = $this->settings[$opt];
             }
         }
     }
     return $style;
 }
 function getTableStats()
 {
     // Don't use caching to save memory. These queries are once only.
     $qry = new DBQuery(true);
     $this->metric_total = $this->contractlist_->getCount();
     for ($i = 0; $i < $this->contractlist_->getCount(); $i++) {
         $contract = $this->contractlist_->getBattle($i);
         if (!($contract->getKillISK() + $contract->getLossISK() > config::get('fleet_battles_mod_minisk') * 1000000)) {
             $this->metric_total = $this->metric_total - 1;
             continue 1;
         }
         // generate all necessary objects within the contract
         $contract->execQuery();
         for ($j = 0; $j < 2; $j++) {
             if ($j == 0) {
                 $list =& $contract->llist_;
             } else {
                 $list =& $contract->klist_;
             }
             $isk = $list->getISK();
             if ($j == 0) {
                 $ldata = array('losses' => $list->getCount(), 'lossisk' => $isk / 1000);
                 $this->lss_isk_all_time += $isk;
             } else {
                 $kdata = array('kills' => $list->getCount(), 'killisk' => $isk / 1000);
                 $this->kll_isk_all_time += $isk;
             }
         }
         if ($kdata['killisk']) {
             $efficiency = round($kdata['killisk'] / ($kdata['killisk'] + $ldata['lossisk']) * 100, 2);
         } else {
             $efficiency = 0;
         }
         $bar = new BarGraph($efficiency, 100);
         if (!config::get('fleet_battles_mod_cache')) {
             $this->inv_all_time += $contract->getInvolved();
             $this->kll_all_time += $contract->getKills();
             $this->lss_all_time += $contract->getLosses();
         }
         $battle = array_merge(array('name' => $contract->getName(), 'startdate' => $contract->getStartDate(), 'enddate' => $contract->getEndDate(), 'bar' => $bar->generate(), 'endtime' => date('H:i:s', strtotime($contract->getEndDate())), 'efficiency' => $efficiency, 'involved' => $contract->getInvolved(), 'kll_id' => $contract->getKillID(), 'id' => $contract->getID(), 'numberOfOwnersInvolved' => $contract->getNumberOfOwnersInvolved(), 'ownerPilotIds' => $contract->getOwnersInvolved()), $kdata, $ldata);
         if (config::get('fleet_battles_mod_cache')) {
             $this->cacheBattle($battle);
         } else {
             $tbldata[] = $battle;
         }
     }
     if (config::get('fleet_battles_mod_cache')) {
         $cacheq = DBFactory::getDBQuery();
         $whereSql = "";
         if ($this->isFiltered) {
             $filterTerms = $this->getFilterArgumentsWhereSql();
             // build filter-string
             if (!empty($filterTerms)) {
                 $whereSql = "WHERE " . implode(" AND ", $filterTerms);
             }
         }
         $sql = "SELECT * \n                                    FROM kb3_battles_cache bc\n                                        INNER JOIN kb3_systems sys ON sys.sys_name = bc.system\n                                        INNER JOIN kb3_constellations con ON con.con_id = sys.sys_con_id\n                                        INNER JOIN kb3_regions reg ON reg.reg_id = con.con_reg_id\n                                    {$whereSql} \n                                    ORDER BY end DESC";
         $cacheq->execute($sql);
         while ($cb = $cacheq->getRow()) {
             $args = array();
             $args[] = array('a', 'kill_related', true);
             $tbldata[] = array('name' => $cb['system'], 'kll_id' => $cb['kll_id'], 'id' => $cb['battle_id'], 'enddate' => $cb['end'], 'startdate' => $cb['start'], 'endtime' => date('H:i:s', strtotime($cb['end'])), 'kills' => $cb['kills'], 'losses' => $cb['losses'], 'efficiency' => $cb['efficiency'], 'involved' => $cb['involved'], 'killisk' => $cb['killisk'], 'lossisk' => $cb['lossisk'], 'bar' => $cb['bar'], 'numberOfOwnersInvolved' => $cb['ownersInvolved'], 'battle_url' => edkURI::build($args, array('kll_id', $cb['kll_id'], true), array('battle', true, true)));
         }
     }
     return $tbldata;
 }
 /**
  * Override to prevent drawing an entry past the last bar
  */
 protected function SetLegendEntry($dataset, $index, $item, $style_info)
 {
     // the last entry is a blank to wangle the numbering
     if ($item->key >= $this->GetMaxKey()) {
         return;
     }
     parent::SetLegendEntry($dataset, $index, $item, $style_info);
 }
 /**
  * construct multigraph
  */
 public function Values($values)
 {
     parent::Values($values);
     $this->multi_graph = new MultiGraph($this->values, $this->force_assoc);
 }
Beispiel #11
0
?>
">
	<?php 
include_partial('searchForm', array('form' => $form));
?>
</div>

<?php 
if (count($occupancy_list) > 0) {
    require_once dirname(__FILE__) . '/Graph.class.php';
    require_once dirname(__FILE__) . '/BarGraph.class.php';
    $titles = array();
    $values = array();
    foreach ($occupancy_list as $occupancy) {
        $titles[] = $occupancy['room']->getName();
        $values[] = round($occupancy['ratio'] * 100);
    }
    $graph = new BarGraph(800, 600);
    $graph->setTitles($titles);
    $graph->setValues($values);
    $graph->setMinValue(0);
    $graph->setMaxValue(100);
    $graph->render();
    $name = '/images/occupancycache.png';
    ?>
<img src="<?php 
    echo $name;
    ?>
" alt="graph" />
<?php 
}
    /**
     * Get the statistics for this table.
     * @return array Array of table statistics.
     */
    function getTableStats()
    {
        $qry = DBFactory::getDBQuery();
        while ($contract = $this->contractlist->getContract()) {
            // Losses
            // Outer query adds up the ships and cost.
            $sql = 'SELECT COUNT(kll_id) AS ships, SUM(kll_isk_loss) AS isk FROM (';
            $invcount = count($contract->getAlliances()) + count($contract->getCorps());
            // Inner query does the hard work of picking which kills to count.
            // Only use DISTINCT if we have to.
            if ($invcount > 1) {
                $sql .= 'SELECT DISTINCT kll_id, kll_isk_loss FROM kb3_kills kll ';
            } else {
                $sql .= 'SELECT kll_id, kll_isk_loss FROM kb3_kills kll ';
            }
            if ($contract->getRegions()) {
                $sql .= ' INNER JOIN kb3_systems sys ON ( sys.sys_id = kll.kll_system_id )
						INNER JOIN kb3_constellations con ON ( con.con_id = sys.sys_con_id)';
            }
            if ($contract->getCorps()) {
                $sql .= ' INNER JOIN kb3_inv_crp inc ON ( kll.kll_id = inc.inc_kll_id ) ';
            }
            if ($contract->getAlliances()) {
                $sql .= ' INNER JOIN kb3_inv_all ina ON ( kll.kll_id = ina.ina_kll_id ) ';
            }
            $andargs = array();
            if ($contract->getStartDate()) {
                $andargs[] = "kll.kll_timestamp >= '" . $contract->getStartDate() . "' ";
                if ($contract->getCorps()) {
                    $andargs[] = "inc.inc_timestamp >= '" . $contract->getStartDate() . "' ";
                }
                if ($contract->getAlliances()) {
                    $andargs[] = "ina.ina_timestamp >= '" . $contract->getStartDate() . "' ";
                }
            }
            if ($contract->getEndDate()) {
                $andargs[] = "kll.kll_timestamp < '" . $contract->getEndDate() . "' ";
                if ($contract->getCorps()) {
                    $andargs[] = "inc.inc_timestamp < '" . $contract->getEndDate() . "' ";
                }
                if ($contract->getAlliances()) {
                    $andargs[] = "ina.ina_timestamp < '" . $contract->getEndDate() . "' ";
                }
            }
            // Who are we shooting?
            $orargs = array();
            if ($contract->getCorps()) {
                $orargs[] = 'inc.inc_crp_id in ( ' . join(',', $contract->getCorps()) . ')';
            }
            if ($contract->getAlliances()) {
                $orargs[] = 'ina.ina_all_id in ( ' . join(',', $contract->getAlliances()) . ')';
            }
            if (count($orargs)) {
                $andargs[] = '(' . join(' OR ', $orargs) . ')';
            }
            // Who are we?
            $orargs = array();
            if (count(config::get('cfg_allianceid'))) {
                $orargs[] = 'kll.kll_all_id IN (' . implode(",", config::get('cfg_allianceid')) . ") ";
            }
            if (count(config::get('cfg_corpid'))) {
                $orargs[] = 'kll.kll_crp_id IN (' . implode(",", config::get('cfg_corpid')) . ") ";
            }
            if (count(config::get('cfg_pilotid'))) {
                $orargs[] = 'kll.kll_victim_id IN (' . implode(",", config::get('cfg_pilotid')) . ") ";
            }
            if (count($orargs)) {
                $andargs[] = '(' . join(' OR ', $orargs) . ')';
            }
            $orargs = array();
            if ($contract->getSystems()) {
                $orargs[] = 'kll.kll_system_id in ( ' . join(',', $contract->getSystems()) . ')';
            }
            if ($contract->getRegions()) {
                $orargs[] = 'con.con_reg_id in ( ' . join(',', $contract->getRegions()) . ' )';
            }
            if (count($orargs)) {
                $andargs[] = '(' . join(' OR ', $orargs) . ')';
            }
            if (count($andargs)) {
                $sql .= 'WHERE ' . join(' AND ', $andargs);
            }
            $sql .= ') as kb3_shadow';
            $sql .= " /* contract: getTableStats '{$invcount}:losses */";
            $result = $qry->execute($sql);
            $row = $qry->getRow($result);
            $ldata = array('losses' => $row['ships'], 'lossisk' => $row['isk'] / 1000);
            // Kills
            $sql = 'SELECT COUNT(kll_id) AS ships, sum(kll_isk_loss) AS isk FROM (';
            $invcount = count(config::get('cfg_pilotid')) + count(config::get('cfg_corpid')) + count(config::get('cfg_allianceid'));
            if ($invcount > 1) {
                $sql .= 'SELECT DISTINCT kll_id, kll_isk_loss FROM kb3_kills kll ';
            } else {
                $sql .= 'SELECT kll_id, kll_isk_loss FROM kb3_kills kll ';
            }
            if ($contract->getRegions()) {
                $sql .= ' INNER JOIN kb3_systems sys ON ( sys.sys_id = kll.kll_system_id )
						INNER JOIN kb3_constellations con ON ( con.con_id = sys.sys_con_id)';
            }
            if (count(config::get('cfg_pilotid'))) {
                $sql .= ' INNER JOIN kb3_inv_detail ind ON ( kll.kll_id = ind.ind_kll_id ) ';
            }
            if (count(config::get('cfg_corpid'))) {
                $sql .= ' INNER JOIN kb3_inv_crp inc ON ( kll.kll_id = inc.inc_kll_id ) ';
            }
            if (count(config::get('cfg_allianceid'))) {
                $sql .= ' INNER JOIN kb3_inv_all ina ON ( kll.kll_id = ina.ina_kll_id ) ';
            }
            $andargs = array();
            if ($contract->getStartDate()) {
                $andargs[] = "kll.kll_timestamp >= '" . $contract->getStartDate() . "' ";
                if (count(config::get('cfg_corpid'))) {
                    $andargs[] = "inc.inc_timestamp >= '" . $contract->getStartDate() . "' ";
                }
                if (count(config::get('cfg_allianceid'))) {
                    $andargs[] = "ina.ina_timestamp >= '" . $contract->getStartDate() . "' ";
                }
            }
            if ($contract->getEndDate()) {
                $andargs[] = "kll.kll_timestamp < '" . $contract->getEndDate() . "' ";
                if (count(config::get('cfg_corpid'))) {
                    $andargs[] = "inc.inc_timestamp < '" . $contract->getEndDate() . "' ";
                }
                if (count(config::get('cfg_allianceid'))) {
                    $andargs[] = "ina.ina_timestamp < '" . $contract->getEndDate() . "' ";
                }
            }
            $orargs = array();
            if ($contract->getCorps()) {
                $orargs[] = 'kll.kll_crp_id in ( ' . join(',', $contract->getCorps()) . ' )';
            }
            if ($contract->getAlliances()) {
                $orargs[] = 'kll.kll_all_id in ( ' . join(',', $contract->getAlliances()) . ' )';
            }
            if (count($orargs)) {
                $andargs[] = '(' . join(' OR ', $orargs) . ')';
            }
            $orargs = array();
            if (count(config::get('cfg_allianceid'))) {
                $orargs[] = '  ina.ina_all_id IN (' . implode(",", config::get('cfg_allianceid')) . ") ";
            }
            if (count(config::get('cfg_corpid'))) {
                $orargs[] = ' inc.inc_crp_id IN (' . implode(",", config::get('cfg_corpid')) . ") ";
            }
            if (count(config::get('cfg_pilotid'))) {
                $orargs[] = ' ind.ind_plt_id IN (' . implode(",", config::get('cfg_pilotid')) . ") ";
            }
            if (count($orargs)) {
                $andargs[] = '(' . join(' OR ', $orargs) . ')';
            }
            $orargs = array();
            if ($contract->getSystems()) {
                $orargs[] = 'kll.kll_system_id in ( ' . join(',', $contract->getSystems()) . ')';
            }
            if ($contract->getRegions()) {
                $orargs[] = 'con.con_reg_id in ( ' . join(',', $contract->getRegions()) . ' )';
            }
            if (count($orargs)) {
                $andargs[] = '(' . join(' OR ', $orargs) . ')';
            }
            if (count($andargs)) {
                $sql .= 'WHERE ' . join(' AND ', $andargs);
            }
            $sql .= ') as kb3_shadow';
            $sql .= " /* contract: getTableStats '{$invcount}':kills' */";
            $result = $qry->execute($sql);
            $row = $qry->getRow($result);
            $kdata = array('kills' => $row['ships'], 'killisk' => $row['isk'] / 1000);
            if ($kdata['killisk']) {
                $efficiency = round($kdata['killisk'] / ($kdata['killisk'] + $ldata['lossisk']) * 100, 2);
            } else {
                $efficiency = 0;
            }
            $bar = new BarGraph($efficiency, 100);
            $tbldata[] = array_merge(array('name' => $contract->getName(), 'startdate' => $contract->getStartDate(), 'bar' => $bar->generate(), 'enddate' => $contract->getEndDate(), 'efficiency' => $efficiency, 'id' => $contract->getID(), 'url' => edkURI::page('cc_detail', $contract->getID(), 'ctr_id')), $kdata, $ldata);
        }
        $this->contractlist->rewind();
        return $tbldata;
    }