예제 #1
0
 function customizeChartProperties()
 {
     parent::customizeChartProperties();
     $dataSetsToDisplay = $this->getDataSetsToDisplay();
     if ($dataSetsToDisplay === false) {
         return;
     }
     $dataSetToDisplay = current($dataSetsToDisplay);
     $this->x->set_grid_colour('#ffffff');
     $this->x_labels->set_steps(2);
     $this->x->set_stroke(1);
     // create the Bar object
     $bar = new bar_filled('#3B5AA9', '#063E7E');
     $bar->set_alpha("0.5");
     $bar->set_key($this->yLabels[$dataSetToDisplay], 12);
     $bar->set_tooltip('#val# #key#');
     // create the bar values
     $yValues = $this->yValues[$dataSetToDisplay];
     $labelName = $this->yLabels[$dataSetToDisplay];
     $unit = $this->yUnit;
     $barValues = array();
     $i = 0;
     $sum = array_sum($yValues);
     foreach ($this->xLabels as $label) {
         $value = (double) $yValues[$i];
         $displayPercentage = '';
         if ($this->displayPercentageInTooltip) {
             $percentage = round(100 * $value / $sum);
             $displayPercentage = "({$percentage}%)";
         }
         $barValue = new bar_value($value);
         $barValue->set_tooltip("{$label}<br>{$value}{$unit} {$labelName} {$displayPercentage}");
         $barValues[] = $barValue;
         $i++;
     }
     $bar->set_values($barValues);
     $this->chart->add_element($bar);
 }
예제 #2
0
<?php

$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Pragma: public");
$bar = new bar_filled('#4386a1', '#577261');
$bar_labels = array();
$bar_values = array();
foreach ($data as $label => $value) {
    $bar_labels[] = (string) $label;
    $bar_values[] = (double) $value;
}
$bar->set_values($bar_values);
$chart = new open_flash_chart();
$chart->set_title(new title($title));
$x = new x_axis();
$x->steps(1);
$x->set_labels_from_array($bar_labels);
$chart->set_x_axis($x);
$y = new y_axis();
$y->set_tick_length(7);
$y->set_range(0, (count($data) > 0 ? max($data) : 0) + 25, ((count($data) > 0 ? max($data) : 0) + 25) / 10);
$chart->set_y_axis($y);
$chart->set_bg_colour("#f3f3f3");
$chart->add_element($bar);
if (isset($yaxis_label)) {
    $y_legend = new y_legend($yaxis_label);
    $y_legend->set_style('{font-size: 20px; color: #000000}');
    $chart->set_y_legend($y_legend);
}
if (isset($xaxis_label)) {
    $x_legend = new x_legend($xaxis_label);
예제 #3
0
    if ($m == $lookback_in_months) {
        $time_lookback = strtotime(date('Y-m-01 00:00:00', $ts));
    }
    $x_labels[] = date('M y', $ts);
    $x_values[date('Ym', $ts)] = 0;
}
//Query total unique mims moved to IN PROGRESS and grouped them monthly
$q = "SELECT DATE_FORMAT(FROM_UNIXTIME(ish.status_time), '%Y%m') AS period" . ", COUNT(DISTINCT i.improvements_id) AS total_mims" . " FROM improvements i" . " INNER JOIN improvements_status_history ish" . " ON ish.improvements_id=i.improvements_id AND ish.status=3" . " WHERE i.department = {$team_id}" . " AND ish.status_time >= {$time_lookback}" . " GROUP BY period" . " ORDER BY period ASC";
$r = tep_db_query($q);
while ($row = tep_db_fetch_array($r)) {
    $x_values[$row['period']] = intval($row['total_mims']);
}
$tdf = 'd.m.y';
$title = new title('Processed MIMS ' . date($tdf, $time_lookback) . ' - ' . date($tdf));
$title->set_style('{color: #567300; font-size: 14px}');
$bar = new bar_filled('#2020AC', '#202073', 10);
$bar->set_values(array_values($x_values));
//BAR CHART
$xfs = 11;
//x fontsize
$yfs = 12;
//y fontsize
$hfs = 16;
//header fontsize
//create chart
$chart = new open_flash_chart();
$chart->set_title($title);
$chart->add_element($bar);
//x-label
$x = new x_axis();
$x->set_labels_from_array($x_labels);
예제 #4
0
 function clientstatAction()
 {
     if (!$this->clientdashboardfilter()) {
         return;
     }
     $this->view->activeTab = 'clientstat';
     // process data for chart
     include 'open-flash-chart.php';
     $request = $this->getRequest();
     $this->view->campaign_id = $request->getParam('id');
     $campaignModel = new Campaign();
     $campaign = $campaignModel->fetchRow('id = ' . $this->view->campaign_id);
     $this->_helper->layout->setLayout($this->getCampaignTemplate($campaign->id));
     //if session not exist, get data from webservice
     $reportMap = array();
     $array_data = $this->getReportCountbyCampaign($campaign, 0, $reportMap);
     $sum = 0;
     foreach ($array_data as $date) {
         $sum += $date;
     }
     $i = 0;
     $maxY = 0;
     foreach ($array_data as $date) {
         $array_data[$i] = round($date * 100 / $sum, 1);
         if ($array_data[$i] > $maxY) {
             $maxY = $array_data[$i];
         }
         $i++;
     }
     // create chart
     $array_create_date = array('0', '1', '2', '3', '4', '5', '6', '7');
     $title = new title("Kraft Spraks Comments");
     $title->set_style('{font-size: 14px; color: #FFFFFF; }');
     $max_y = floor($maxY / 10) * 10 + 10;
     $y = new y_axis();
     $y->set_range(0, $max_y, 10);
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($array_create_date);
     $x_labels->set_size(11);
     $x->set_labels($x_labels);
     $x->set_range(0, 7, 1);
     //There is a bug on the tooltip of bar: can not show #x_label#. So use bar_stack instead of bar here.
     $bar = new bar_filled();
     $array_bar_data[0] = new bar_value($array_data[0]);
     $array_bar_data[0]->set_colour('#606060');
     $array_bar_data[1] = new bar_value($array_data[1]);
     $array_bar_data[1]->set_colour('#BE3304');
     $array_bar_data[2] = new bar_value($array_data[2]);
     $array_bar_data[2]->set_colour('#F2B538');
     $array_bar_data[3] = new bar_value($array_data[3]);
     $array_bar_data[3]->set_colour('#EE7904');
     $array_bar_data[4] = new bar_value($array_data[4]);
     $array_bar_data[4]->set_colour('#D4FD32');
     $array_bar_data[5] = new bar_value($array_data[5]);
     $array_bar_data[5]->set_colour('#B4EB35');
     $array_bar_data[6] = new bar_value($array_data[6]);
     $array_bar_data[6]->set_colour('#B1D764');
     $array_bar_data[7] = new bar_value($array_data[7]);
     $array_bar_data[7]->set_colour('#A1C463');
     $bar->set_values($array_bar_data);
     //		$bar->set_tooltip('#x_label#: #val#');
     //		$bar = new bar_stack();
     //		$bar->set_colours(array( '#E2D66A', '#A0C361' ));
     //		foreach ($array_data as $date):
     //		$bar->append_stack(array((int)$date));
     //		endforeach;
     $bar->set_tooltip('#val#%');
     $x_legend = new x_legend('Positive');
     $x_legend->set_style('{font-size: 30px; color: #FFFFFF; }');
     $y_legend = new y_legend($this->view->translate('(%)'));
     $y_legend->set_style('{font-size: 30px; color: #FFFFFF;}');
     $tags = new ofc_tags();
     $tags->font("Verdana", 14)->align_x_right();
     $tag_y_value = -($max_y * 0.3);
     $t = new ofc_tag(6.6, $tag_y_value);
     $t->text($this->view->translate('Client_Report Positive'))->colour("#177A16");
     $tags->append_tag($t);
     $t2 = new ofc_tag(0.5, $tag_y_value);
     $t2->text($this->view->translate('Client_Report Negative'))->colour("#D88569");
     $tags->append_tag($t2);
     $t3 = new ofc_tag(-1, $max_y);
     $t3->text($this->view->translate('(%)'))->colour("#000000");
     $tags->append_tag($t3);
     $t4 = new ofc_tag(-0.7, $tag_y_value);
     $t4->text($this->view->translate('Client_Report No opinion'))->colour("#5D5D5D");
     $tags->append_tag($t4);
     $this->view->chart3 = new open_flash_chart();
     $this->view->chart3->set_title($title);
     $this->view->chart3->add_element($bar);
     $this->view->chart3->set_bg_colour('#FFFFFF');
     $this->view->chart3->set_x_axis($x);
     $this->view->chart3->set_y_axis($y);
     $this->view->chart3->set_x_legend($x_legend);
     $this->view->chart3->set_y_legend($y_legend);
     $this->view->chart3->add_element($tags);
 }