Exemple #1
0
 /**
  * Generates data for OFC2 line chart in json format
  *
  * @return void
  */
 public function get_laba_rugi()
 {
     $this->load->plugin('ofc2');
     $this->load->model('jurnal_model');
     $model_data = $this->jurnal_model->get_laba_rugi_data();
     $bulan_data = array("Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des");
     for ($i = date('n') + 1; $i <= 12; $i++) {
         $pendapatan_kredit = isset($model_data[$i][date('Y') - 1][4][0]) ? $model_data[$i][date('Y') - 1][4][0] : 0;
         $pendapatan_debit = isset($model_data[$i][date('Y') - 1][4][1]) ? $model_data[$i][date('Y') - 1][4][1] : 0;
         $beban_kredit = isset($model_data[$i][date('Y') - 1][5][0]) ? $model_data[$i][date('Y') - 1][5][0] : 0;
         $beban_debit = isset($model_data[$i][date('Y') - 1][5][1]) ? $model_data[$i][date('Y') - 1][5][1] : 0;
         $data[] = $pendapatan_kredit - $pendapatan_debit - ($beban_debit - $beban_kredit);
         $thn = date('y') - 1;
         $thn = strlen($thn) == 1 ? '0' . $thn : $thn;
         $x_data[] = $bulan_data[$i - 1] . "'" . $thn;
     }
     for ($i = 1; $i <= date('n'); $i++) {
         $pendapatan_kredit = isset($model_data[$i][date('Y')][4][0]) ? $model_data[$i][date('Y')][4][0] : 0;
         $pendapatan_debit = isset($model_data[$i][date('Y')][4][1]) ? $model_data[$i][date('Y')][4][1] : 0;
         $beban_kredit = isset($model_data[$i][date('Y')][5][0]) ? $model_data[$i][date('Y')][5][0] : 0;
         $beban_debit = isset($model_data[$i][date('Y')][5][1]) ? $model_data[$i][date('Y')][5][1] : 0;
         $data[] = $pendapatan_kredit - $pendapatan_debit - ($beban_debit - $beban_kredit);
         $x_data[] = $bulan_data[$i - 1] . "'" . date('y');
     }
     $max = (int) max($data);
     $maxlen = strlen($max);
     $up = round($max, -($maxlen - 1));
     $min = (int) min($data);
     $minlen = strlen($min);
     $down = round($min, -($minlen - 1));
     $abs_max = (int) max(abs($max), abs($min));
     $len = strlen($abs_max);
     $round = round($abs_max, -($len - 1));
     $step = '1' . substr($round, 1);
     $up = $max > $up ? $up + $step : $up;
     $down = $min < $down ? $down - $step : $down;
     $d = new hollow_dot();
     $d->size(4)->halo_size(1)->colour('#668053');
     $line = new line();
     $line->set_values($data);
     $line->set_default_dot_style($d);
     $line->set_width(5);
     $line->set_colour('#7491a0');
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($x_data);
     $x = new x_axis();
     $x->set_labels($x_labels);
     $x->set_grid_colour('#bfb8b3');
     $y = new y_axis();
     $y->set_grid_colour('#bfb8b3');
     $y->set_range($down, $up, $step);
     $chart = new open_flash_chart();
     $chart->add_element($line);
     $chart->set_x_axis($x);
     $chart->set_y_axis($y);
     $chart->set_bg_colour('#FFFFFF');
     echo $chart->toPrettyString();
 }
Exemple #2
0
 function customizeChartProperties()
 {
     parent::customizeChartProperties();
     $dataSetsToDisplay = $this->getDataSetsToDisplay();
     if ($dataSetsToDisplay === false) {
         return;
     }
     $colors = array("0x3357A0", "0xCC3399", "0x9933CC", "0x80a033", "0xFD9816", "0x246AD2", "0xFD16EA", "0x49C100");
     $i = 0;
     foreach ($dataSetsToDisplay as $dataSetToDisplay) {
         $color = $colors[$i % count($colors)];
         $labelName = $this->yLabels[$dataSetToDisplay];
         $d = new hollow_dot();
         $d->size(3)->halo_size(0)->colour($color);
         $line = new line();
         $line->set_default_dot_style($d);
         $line->set_key($labelName, 11);
         $line->set_width(1);
         $line->set_colour($color);
         // Line Values
         // Note: we have to manually create the dot values as the steps feature doens't work on X axis
         // when it's working again, we can remove code below and set generic tooltip above: // ->tooltip('#x_label#<br>#val# '.$labelName)
         $yValues = $this->yValues[$dataSetToDisplay];
         $labelName = $this->yLabels[$dataSetToDisplay];
         $lineValues = array();
         $j = 0;
         $unit = $this->yUnit;
         foreach ($this->xLabels as $label) {
             $value = (double) $yValues[$j];
             $lineValue = new hollow_dot($value);
             $whole = (int) $value;
             if ($value - $whole >= 0.005) {
                 $value = sprintf('%.2f', $value);
             }
             $lineValue->tooltip("{$label}<br><b>{$value}{$unit}</b> {$labelName}");
             if (!empty($this->xOnClick)) {
                 $lineValue->on_click("piwikHelper.redirectToUrl('" . $this->xOnClick[$j] . "')");
             }
             $lineValues[] = $lineValue;
             $j++;
         }
         $line->set_values($lineValues);
         $lines[] = $line;
         $i++;
     }
     foreach ($lines as $line) {
         $this->chart->add_element($line);
     }
     // if one column is a percentage we set the grid accordingly
     // note: it is invalid to plot a percentage dataset along with a numeric dataset
     if ($this->yUnit == '%' && $this->maxValue > 90) {
         $this->y->set_range(0, 100, 50);
     }
 }
Exemple #3
0
     $time_axis[] = date("H:i", strtotime($row->Time));
     $data_watt[] = round((double) $row->Watt, 3);
     //$data_max[]    = round((float)$row->maxWatt,3) ;
     $data_tot[] = round((double) $row->ETotal, 3);
 }
 $chart = new open_flash_chart();
 if (count($time_axis) == 0) {
     echo 0;
     exit;
 }
 $title = new title("\n" . date('l dS F Y', $time) . " (" . round(max($data_tot) - min($data_tot), 2) . " kWh)");
 $title->set_style('{font-size: 20px; color: #778877;}');
 $tooltip = new tooltip();
 $tooltip->set_hover();
 $sline = new scatter_line('#3D3D3D', 3);
 $def = new hollow_dot();
 $def->size(0)->halo_size(0);
 $sline->set_default_dot_style($def);
 $sline->set_key('Leistung (W)', 11);
 $v = array();
 foreach ($data_watt as $key => $val) {
     $v[] = new scatter_value($key, $val);
     $v[] = new scatter_value($key + 1, $val);
 }
 $sline->set_values($v);
 $bars_curr = new bar_glass();
 $bars_curr->set_key('Leistung (W)', 10);
 $bars_curr->set_colour('#EFC01D');
 $bars_curr->set_alpha(0.8);
 $bars_curr->set_tooltip('#val# W');
 for ($i = 0; $i < count($data_watt); $i++) {
                    return 40;
                } else {
                    if ($a > 50) {
                        return 20;
                    } else {
                        return 5;
                    }
                }
            }
        }
    }
    // end function getIdeal...
}
// end if function_exist
// Prepare look and feel of data points
$def = new hollow_dot();
$def->size(4)->halo_size(3)->tooltip('#val#<br>#date:Y-m-d H:i#');
// Build and show the chart
$chart = new open_flash_chart();
$chart->set_title(new Title($titleGraph));
// do this for each checked data-column
//-----------------------------------
//#############################################################
foreach ($the_checked_cols as $col) {
    // reset loop-arrays
    $the_values = array();
    $the_dates = array();
    $the_data = array();
    // skip NULL or not-numeric entries
    // check if values are numeric
    // and change date into UNIX-format
 public function get_jx_json($info, $type = '')
 {
     $year = array_keys($info);
     $price = array_values($info);
     $chart = new open_flash_chart();
     $chart->set_bg_colour('#FFFFFF');
     //flash背景颜色
     //$title = new title( 'UK Petrol price (pence) per Litre' );
     //$title->set_style( "{font-size: 20px; color: #A2ACBA; text-align: center;}" );
     //$chart->set_title( $title );
     $d = new hollow_dot();
     $d->size(3)->halo_size(0)->colour('#8f8fbd');
     $area = new area();
     $area->set_width(2);
     $area->set_default_dot_style($d);
     $area->set_fill_colour('#eaf6ff');
     $area->set_fill_alpha(0.4);
     $area->set_colour('#8f8fbd');
     //$area->set_values($price);
     $area->set_values($price);
     $chart->add_element($area);
     $num = intval(count($year >= 7 ? $year : 7) / 7);
     if ($num == 0) {
         $num = intval(count($year));
     }
     $num = $num > 0 ? $num : 1;
     $x_labels = new x_axis_labels();
     $x_labels->set_steps($num);
     $x_labels->set_size(12);
     $x_labels->set_colour('#000000');
     $x_labels->set_labels($year);
     if (count($year) > 0) {
         $x_labels->set_vertical();
     }
     //		// 插入数据
     $x = new x_axis();
     $x->set_colour('#000000');
     $x->set_grid_colour('#dadada');
     $x->set_offset(false);
     $x->set_steps($num);
     // Add the X Axis Labels to the X Axis
     //$x->set_labels($x_labels);
     $x->set_labels_from_array($year);
     $chart->set_x_axis($x);
     $y = new y_axis();
     $y->labels = null;
     $max = $this->get_the_right_y(max($price));
     $max = $max > 0 ? $max : 1;
     $y->set_range(0, ($max / 5 + 1) * 5, $max / 5 + 1);
     //		if ($max > 20 && $max <= 100) {
     //
     //			$y->set_range(0, $max, 10);
     //		}elseif($max >= 10&&$max<=20){
     //			$y->set_range(0, $max, 5);
     //		}
     //		else {
     //			$y->set_range(0, $max);
     //		}
     $y->set_colour('#000000');
     $y->set_grid_colour('#dadada');
     if ($type == 'percent') {
         $y->set_label_text("       #val#%");
     } else {
         $y->set_label_text("       #val#");
     }
     $chart->add_y_axis($y);
     $info = $chart->toPrettyString();
     return $info;
 }
Exemple #6
0
                            } else {
                                ////ChromePhp::log("Adding data");
                                $x_labels[] = $year;
                            }
                        }
                    }
                }
            }
        } else {
            $x_labels[] = '';
        }
    }
    $date_count++;
}
// line properties
$d = new hollow_dot();
$d->size(5)->halo_size(0)->colour('#3D5C56');
$line->set_default_dot_style($d);
$line->set_values($returns);
$line->set_width(2);
$line->set_colour('#668053');
$chart->add_element($line);
// title properties
$portfolio_type = array("", "Unknown", "401(k)", "Traditional IRA", "Roth IRA", "SIMPLE IRA", "SEP-IRA", "Solo 401(k)", "Roth 401(k)", "403(b)", "Other");
$type_idx = $_GET['i'];
$type_idx = $type_idx == 0 ? $type_idx : $type_idx - 1;
$title = new title("Individual Portfolio Performance (" . $portfolio_type[$type_idx] . ")");
$title->set_style("{font-size: 25px; font-family: Calibri; font-weight: bold; color: #121212; text-align: center;}");
$chart->set_title($title);
// y axis properties
$y = new y_axis();
Exemple #7
0
<?php

$this->output->set_header("Cache-Control: no-store, no-cache, must-revalidate");
$this->output->set_header("Pragma: public");
$line_data = array();
$labels = array();
foreach ($data as $label => $value) {
    $line_data[] = (double) $value;
    $labels[] = (string) $label;
}
$hol = new hollow_dot();
$hol->size(3)->halo_size(1)->tooltip('#x_label#<br>#val#');
$line = new line();
$line->set_default_dot_style($hol);
$line->set_values($line_data);
$chart = new open_flash_chart();
$chart->set_title(new title($title));
$chart->add_element($line);
$x = new x_axis();
$x->steps(count($data) > 10 ? (int) (count($data) / 4) : 1);
$x->set_labels_from_array($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");
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);
$items[] = new ofc_menu_item('Refresh ','load');
$items[] = new ofc_menu_item('1 Hour  ','show_hour1');
$items[] = new ofc_menu_item('2 Hours ','show_hour2');
$items[] = new ofc_menu_item('6 Hours ','show_hour3');
$items[] = new ofc_menu_item('12 Hours','show_hour4');
$items[] = new ofc_menu_item('1 Day    ','show_hour5');
$items[] = new ofc_menu_item('3 Days   ','show_hour6');
$items[] = new ofc_menu_item('1 Week  ','show_hour7');
$items[] = new ofc_menu_item('2 Weeks ','show_hour8');
$items[] = new ofc_menu_item('1 Month  ','show_hour9');
//$items[] = new ofc_menu_item('Save...   ','save_image');
$m->values($items);
$chart->set_menu($m);
*/
//var_dump($y_data);
$hol = new hollow_dot();
$hol->size(3)->halo_size(1)->tooltip('#key# <br>Listeners: #val#<br>Time: #x_label#');
//foreach
//var_dump($y_data);
foreach ($y_data as $key => $data) {
    $line_dot = new area();
    //$line_dot = new line();
    if (isset($channels[$key])) {
        $legend = $channels[$key]['name'] . ':(' . end($data) . ')';
        $color = $channels[$key]['color'];
        $line_dot->set_width(1);
    } else {
        $legend = 'Total:(' . end($data) . "/{$total_avg}/{$total_max})";
        $color = '#e81dd7';
        $line_dot->set_width(3);
    }
Exemple #9
0
	/**
	 * I use this wrapper for default dot types,
	 * it just makes the code easier to read.
	 */
	public function __construct($colour, $size)
	{
		parent::hollow_dot();
		$this->colour($colour)->size($size);
	}
        }
    }
    $line_3 = new line();
    $line_3->set_default_dot_style($line_3_default_dot);
    $line_3->set_values($data_3);
    $line_3->set_colour($data_3_color);
    $line_3->set_width(2);
}
if (isset($data[4])) {
    $data_4_color = '#009900';
    $data_4 = explode('|', $data[4]);
    foreach ($data_4 as $k => $v) {
        $kw = $k + 1;
        $v = floatval($v);
        $d = $kw_daterange[$kw];
        $lv = new hollow_dot($v);
        $lv->colour($data_4_color)->size(3)->halo_size(0);
        $lv->tooltip('#x_label#<br>' . $d . '<br>Value: #val#');
        $data_4[$k] = $lv;
        if ($v > $data_max) {
            $data_max = ceil($v);
        }
    }
    $line_4 = new line();
    $line_4->set_default_dot_style($line_4_default_dot);
    $line_4->set_values($data_4);
    $line_4->set_colour($data_4_color);
    $line_4->set_width(1);
}
//CHECK MAX VALUE TO DEFINE BEST VERTICAL STEPS
if ($data_max <= 10) {
 /**
  * I use this wrapper for default dot types,
  * it just makes the code easier to read.
  */
 function __construct($colour, $size)
 {
     parent::__construct();
     $this->colour($colour)->size($size);
 }
Exemple #12
0
 /**
  * I use this wrapper for default dot types,
  * it just makes the code easier to read.
  */
 function s_hollow_dot($colour, $size)
 {
     parent::hollow_dot();
     $this->colour($colour)->size($size);
 }
 public function clientimpressionAction()
 {
     ini_set('display_errors', 1);
     $frontController = Zend_Controller_Front::getInstance();
     $frontController->throwExceptions(true);
     // filter!
     if (!$this->clientdashboardfilter()) {
         return;
     }
     $this->view->activeTab = 'clientimpression';
     include 'open-flash-chart.php';
     $request = $this->getRequest();
     if ($request->isPost()) {
         $formData = $request->getPost();
         $campaign_id = $formData['campaign_id'];
     } else {
         $campaign_id = $request->getParam('id');
     }
     $this->_helper->layout->setLayout($this->getCampaignTemplate($campaign_id));
     $this->view->campaign_id = $campaign_id;
     // get date from db
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('report', array('left(create_date,10) as date', 'accesscode'))->where('report.campaign_id = ?', $campaign_id)->where('report.state = "APPROVED"')->order('date');
     $results = $db->fetchAll($select);
     $accesscodeDbMatchArray = array();
     foreach ($results as $result) {
         $accesscodeDbMatchArray[$result['accesscode']] = $result['date'];
     }
     $accesscodeArray = array_keys($accesscodeDbMatchArray);
     $campaignModel = new Campaign();
     $campaign = $campaignModel->fetchRow('id = ' . $campaign_id);
     // get impression value from ws
     $db = Zend_Registry::get('db');
     $select = $db->select();
     $select->from('dashboard_mapping');
     $select->where('survey_id = ?', $campaign->i2_survey_id);
     $select->where('mark="FRIENDS"');
     $mappings = $db->fetchRow($select);
     $indicate2Connect = new Indicate2_Connect();
     $response = $indicate2Connect->getAnswerSetForSurvey(array($campaign->i2_survey_id, $campaign->i2_survey_id_en), null, array(array('ContextIndex' => $mappings['context_index'], 'QuestionIndex' => $mappings['question_index'])), 0);
     //        Zend_Debug::dump($mappings);die;
     $optionArray = array();
     if (isset($response->QuestionType) && is_array($response->QuestionType)) {
         foreach ($response->QuestionType as $questionType) {
             foreach ($questionType->SelectionQuestionOptionType as $optionObject) {
                 //get min value, like '11-15' = 11
                 $optionArray[$optionObject->OptionId] = (int) $optionObject->OptionText;
             }
         }
     } else {
         if (isset($response->QuestionType->SelectionQuestionOptionType)) {
             foreach ($response->QuestionType->SelectionQuestionOptionType as $optionObject) {
                 //get min value, like '11-15' = 11
                 if ($optionObject->OptionText == '>=10') {
                     $optionArray[$optionObject->OptionId] = 10;
                 }
                 $optionArray[$optionObject->OptionId] = (int) $optionObject->OptionText;
             }
         }
     }
     $answerArray = array();
     $i = 0;
     if (isset($response->AnswerSetType)) {
         foreach ($response->AnswerSetType as $answerObject) {
             $answerArray[$i++] = array($answerObject->AccessCode, iconv("UTF-8", "gb18030", preg_replace('/[\\n\\r\\t]/', ' ', base64_decode($answerObject->AnswerType->AnswerText))));
         }
     }
     // create x axis date value (endDate = expireDate/now + 10 days)
     $this->view->startDate = $startDate = date("Y-m-d", strtotime($campaign->create_date));
     if (strtotime($campaign->expire_date) > strtotime(date("Y-m-d"))) {
         $this->view->xmax = $endDate = date("Y-m-d", strtotime("+10 days", strtotime(date("Y-m-d"))));
     } else {
         $this->view->xmax = $endDate = date("Y-m-d", strtotime("+10 days", strtotime($campaign->expire_date)));
     }
     if ($request->isPost()) {
         $formData = $request->getPost();
         $this->view->xmax = $endDate = $formData['x_max'];
     }
     $resultArray = array();
     $xDateArrayLength = 0;
     while (1) {
         $resultArray[$startDate] = 0;
         $startDate = date("Y-m-d", strtotime("+1 days", strtotime($startDate)));
         $xDateArrayLength++;
         if ($startDate == $endDate) {
             $resultArray[$startDate] = 0;
             $xDateArrayLength++;
             break;
         }
     }
     //var_dump($resultArray);die;
     // set sparks initial impressions for each campaign, it should be added if a new campaign is lanuched!
     switch ($campaign_id) {
         case '1':
             $staticsparks = array(50, 110);
             break;
         case '2':
             $staticsparks = array(50, 150, 250, 400, 450);
             break;
         case '3':
             $staticsparks = array(100, 350, 750, 1200, 1500);
             break;
         case '4':
             $staticsparks = array(50, 200, 250);
             break;
         case '5':
             $staticsparks = array(50, 150);
             break;
         case '6':
             $staticsparks = array(50, 150, 350, 500, 900, 1700, 2300, 2500);
             break;
         case '7':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 150, 350, 500, 900, 1038);
             break;
         case '8':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '9':
             $staticsparks = array(0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '10':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 0, 0, 150, 300, 450, 600, 750, 900, 1000);
             break;
         case '13':
             $staticsparks = array(0, 0, 0, 0, 0, 0, 50, 100, 150, 300, 450, 600, 750, 900, 1200);
             break;
         default:
             break;
     }
     for ($temp = count($staticsparks); $temp < $xDateArrayLength; $temp++) {
         $staticsparks[$temp] = $staticsparks[$temp - 1];
     }
     // set everyday impression by using ws data
     foreach ($answerArray as $answer) {
         if (!isset($accesscodeDbMatchArray[$answer[0]])) {
             continue;
         }
         if (date("Y-m-d", strtotime($accesscodeDbMatchArray[$answer[0]])) > date("Y-m-d", strtotime($this->view->xmax))) {
             continue;
         }
         if (!array_key_exists($accesscodeDbMatchArray[$answer[0]], $resultArray)) {
             $resultArray[$accesscodeDbMatchArray[$answer[0]]] = $optionArray[$answer[1]];
         } else {
             $resultArray[$accesscodeDbMatchArray[$answer[0]]] += $optionArray[$answer[1]];
         }
     }
     //Zend_Debug::dump($optionArray);
     //Zend_Debug::dump($resultArray);
     //Zend_Debug::dump($answerArray);
     //Zend_Debug::dump($accesscodeDbMatchArray);
     // set line value
     $sparks = 0;
     $data_1 = array();
     $data_2min = array();
     $data_2max = array();
     $data_3min = array();
     $data_3max = array();
     $i = 0;
     $data_1[0] = $data_2max[0] = $data_2min[0] = $data_3min[0] = $data_3max[0] = $accumulate = 0;
     $temp = 0;
     foreach ($resultArray as $result) {
         if ($result != 0) {
             $xTodayLength = $temp;
         }
         $temp++;
     }
     foreach ($resultArray as $result) {
         if ($i == 0) {
             $i++;
             continue;
         }
         $accumulate = $result + $accumulate;
         $data_1[$i] = $accumulate + $staticsparks[$i];
         $data_2min[$i] = floor($accumulate * 2.5 + $staticsparks[$i]);
         $data_2max[$i] = $accumulate * 5 + $staticsparks[$i];
         $data_2avg[$i] = $accumulate * 3.75;
         $data_3min[$i] = floor($data_2avg[$i] * 3) + $data_2min[$i];
         $data_3max[$i] = floor($data_2avg[$i] * 4) + $data_2max[$i];
         $max = $data_3max[$i];
         if ($i == $xTodayLength) {
             break;
         }
         $i++;
     }
     // set max y axis value
     $dateArray = array_keys($resultArray);
     $y = new y_axis();
     if ($request->isPost()) {
         $formData = $request->getPost();
         $max = $formData['y_max'];
     } else {
         if ($max < 10000) {
             $max = ceil($max / 100) * 100;
         } else {
             $max = ceil($max / 1000) * 1000;
         }
     }
     $y->set_range(0, $max, $max / 10);
     $this->view->ymax = $max;
     // draw lines
     $x = new x_axis();
     $x_labels = new x_axis_labels();
     $x_labels->set_labels($dateArray);
     $x_labels->set_steps(floor($xDateArrayLength / 42) + 1);
     $x_labels->rotate(40);
     $x->set_labels($x_labels);
     $line_1_default_dot = new dot();
     $line_1_default_dot->colour('#007DCD')->tooltip('#x_label#: #val#');
     $line_1 = new line();
     $line_1->set_default_dot_style($line_1_default_dot);
     $line_1->set_values($data_1);
     $line_1->set_colour("#007DCD");
     $line_1->set_width(1);
     $line_2min_default_dot = new dot();
     $line_2min_default_dot->colour('#81C909')->tooltip('#x_label#: #val#');
     $line_2min = new line();
     $line_2min->set_default_dot_style($line_2min_default_dot);
     $line_2min->set_values($data_2min);
     $line_2min->set_colour("#81C909");
     $line_2min->set_width(1);
     $line_2_default_dot = new dot();
     $line_2_default_dot->colour('#81C909')->tooltip('#x_label#: #val#');
     $line_2 = new line();
     $line_2->set_default_dot_style($line_2_default_dot);
     $line_2->set_values($data_2max);
     $line_2->set_colour("#81C909");
     $line_2->set_width(1);
     $line_3_default_dot = new dot();
     $line_3_default_dot->colour('#FF0000')->tooltip('#x_label#: #val#');
     $line_3 = new line();
     $line_3->set_default_dot_style($line_3_default_dot);
     $line_3->set_values($data_3min);
     $line_3->set_colour("#FF0000");
     $line_3->set_width(1);
     $line_3max_default_dot = new dot();
     $line_3max_default_dot->colour('#FF0000')->tooltip('#x_label#: #val#');
     $line_3max = new line();
     $line_3max->set_default_dot_style($line_3max_default_dot);
     $line_3max->set_values($data_3max);
     $line_3max->set_colour("#FF0000");
     $line_3max->set_width(1);
     //tags
     $tags = new ofc_tags();
     $tags->font("Verdana", 10)->colour("#2F2F2F")->align_x_right();
     $this->view->chart = new open_flash_chart();
     // create event
     $campaignEventModel = new CampaignEvent();
     $campaignEvents = $campaignEventModel->fetchAll('campaign_id = ' . $campaign_id, 'event_date');
     $eventTotal = count($campaignEvents);
     $eventTemp = 0;
     foreach ($campaignEvents as $campaignEvent) {
         $eventDate = floor((strtotime($campaignEvent->event_date) - strtotime($campaign->create_date)) / 86400);
         $eventDescription = $campaignEvent->event_name;
         // event line
         $eventline = new scatter_line('#C5BE97', 1);
         $def = new hollow_dot();
         $def->size(0)->halo_size(0);
         $eventline->set_default_dot_style($def);
         $v = array(new scatter_value($eventDate, 0), new scatter_value($eventDate, $this->view->ymax));
         $eventline->set_values($v);
         $this->view->chart->add_element($eventline);
         // event description
         $tagAndArrow_Yvalue = 1 - ($eventTotal - $eventTemp++) / 10;
         if ($tagAndArrow_Yvalue == 0) {
             $tagAndArrow_Yvalue = 0.1;
         }
         $tag_xvalue = $eventDate + 2;
         $t = new ofc_tag($tag_xvalue, $this->view->ymax * $tagAndArrow_Yvalue);
         $t->text($eventDescription)->style(false, false, false, 1.0)->padding(0, 0);
         $tags->append_tag($t);
         // event arrow
         $arrowStart_x = $tag_xvalue;
         $arrowStart_y = $this->view->ymax * $tagAndArrow_Yvalue;
         $arrowEnd_x = $tag_xvalue - 1.5;
         $arrowEnd_y = $this->view->ymax * $tagAndArrow_Yvalue;
         $arrowColor = '#000000';
         $arrowBarbLength = 7;
         $a = new ofc_arrow($arrowStart_x, $arrowStart_y, $arrowEnd_x, $arrowEnd_y, $arrowColor, $arrowBarbLength);
         $this->view->chart->add_element($a);
     }
     $this->view->chart->add_element($line_1);
     $this->view->chart->add_element($line_2min);
     $this->view->chart->add_element($line_2);
     $this->view->chart->add_element($line_3);
     $this->view->chart->add_element($line_3max);
     $this->view->chart->add_element($tags);
     $this->view->chart->set_y_axis($y);
     $this->view->chart->set_x_axis($x);
     $this->view->chart->set_bg_colour('#FFFFFF');
 }