コード例 #1
0
ファイル: VerticalBar.php プロジェクト: Doluci/tomatocart
 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
 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);
 }