Пример #1
0
');
$deposits = array();
$withdrawals = array();
$weeks = array();
while ($row = mysql_fetch_assoc($result)) {
    $weeks[] = date('d.m.Y', $row['stamp']);
    $deposits[] = round($row['deposits'], 2);
    $withdrawals[] = -round($row['withdrawals'], 2);
}
//lines
$line1 = new line();
$line1->set_values($deposits);
$line1->set_colour('#00FF00');
$line2 = new line();
$line2->set_values($withdrawals);
$line2->set_colour('#FF0000');
//axises
$axis_x = new x_axis();
$axis_x_labels = new x_axis_labels();
$axis_x_labels->set_labels($weeks);
$axis_x->set_labels($axis_x_labels);
$axis_y = new y_axis();
$axis_y->range(0, max(max($deposits), max($withdrawals)), 1000);
//chart
$chart = new open_flash_chart();
$chart->set_y_axis($axis_y);
$chart->set_x_axis($axis_x);
$chart->add_element($line1);
$chart->add_element($line2);
$chart->set_bg_colour('#FFFFFF');
echo $chart->toPrettyString();
Пример #2
0
 function subscription()
 {
     acymailing::setTitle(JText::_('CHARTS'), 'stats', 'diagram&task=subscription');
     $listsClass = acymailing::get('class.list');
     $lists = $listsClass->getLists('listid');
     $db =& JFactory::getDBO();
     $db->setQuery('SELECT min(subdate) as minsubdate, min(unsubdate) as minunsubdate FROM ' . acymailing::table('listsub'));
     $dates = $db->loadObject();
     $spaces = array();
     $intervals = 10;
     $dates->maxsubdate = time();
     $delay = ($dates->maxsubdate - $dates->minsubdate) / $intervals;
     for ($i = 0; $i < $intervals; $i++) {
         $spaces[$i] = (int) ($dates->minsubdate + $delay * $i);
     }
     $spaces[$intervals] = $dates->maxsubdate;
     $results = array();
     $legendX = array();
     for ($i = 0; $i <= $intervals; $i++) {
         $legendX[] = acymailing::getDate($spaces[$i]);
         $db->setQuery('SELECT count(subid) as total, listid FROM ' . acymailing::table('listsub') . ' WHERE `status` != 2 AND `subdate` < ' . $spaces[$i] . ' AND (`status` = 1 OR `unsubdate`>' . $spaces[$i] . ') GROUP BY listid');
         $results[$i] = $db->loadObjectList('listid');
     }
     $title = new title(JText::_('SUB_HISTORY'));
     $title->set_style('font-size:20px; color: #FF8040');
     $lines = array();
     $maxSub = 0;
     foreach ($lists as $listid => $oneList) {
         $lines[$listid] = new line_base();
         $values = array();
         for ($i = 0; $i <= $intervals; $i++) {
             $values[] = empty($results[$i][$listid]->total) ? 0 : (int) $results[$i][$listid]->total;
         }
         $lines[$listid]->set_values($values);
         $lines[$listid]->set_text($oneList->name);
         $lines[$listid]->set_colour($oneList->color);
         $maxSub = max($maxSub, max($values));
     }
     $x_axis = new x_axis();
     $xlabelobject = new x_axis_labels();
     $xlabelobject->rotate(-20);
     $xlabelobject->set_labels($legendX);
     $x_axis->set_labels($xlabelobject);
     $y_axis = new y_axis();
     $y_axis->range(0, $maxSub, intval($maxSub / 10));
     $chart = new open_flash_chart();
     $chart->set_x_axis($x_axis);
     $chart->set_y_axis($y_axis);
     $chart->set_title($title);
     foreach ($lines as $oneLine) {
         $chart->add_element($oneLine);
     }
     $this->assignRef('chart', $chart);
 }