/**
  *
  * Set the xLabels
  * Note we can no longer set angle for labels as openFlashPlayer
  * doesn't seem to render it anymore - presumably after being upgraded
  *  I think the fonts would need to be embedded
  * @return object x_axis_labels
  */
 function setXLabels()
 {
     $xLabels = new x_axis_labels();
     $xLabels->set_labels($this->xlabels);
     $xLabels->set_size($this->xlabelSize);
     if ($this->xlabelAngle) {
         $xLabels->rotate($this->xlabelAngle);
     }
     return $xLabels;
 }
Example #2
0
 function getNewUsersByTime($timePhase, $fromDate = '', $toDate = '')
 {
     $this->load->library('ofc');
     $userId = $this->common->getUserId();
     $this->ofc->open_flash_chart();
     $this->ofc->set_bg_colour(CHART_BG_COLOR);
     $toTime = date("Y-m-d", strtotime("-1 day"));
     if ($timePhase == "7day") {
         $fromTime = date("Y-m-d", strtotime("-8 day"));
         $color = CHART_LINE_1;
         $key = "近7日新增用户";
         $title = new title("近7日新增用户统计");
     }
     if ($timePhase == "1month") {
         $title = new title("近30天新增用户统计");
         $fromTime = date("Y-m-d", strtotime("-31 day"));
         $color = CHART_LINE_2;
         $key = "近30天新增用户统计";
     }
     if ($timePhase == "3month") {
         $title = new title("近三个月新增用户统计");
         $fromTime = date("Y-m-d", strtotime("-92 day"));
         $color = CHART_LINE_3;
         $key = "近三个月新增用户统计";
     }
     if ($timePhase == "all") {
         $title = new title("所有新增用户统计");
         $fromTime = '1970-01-01';
         $color = CHART_LINE_4;
         $key = "所有新增用户统计";
     }
     if ($timePhase == "any") {
         $title = new title("所有新增用户统计");
         $fromTime = $fromDate;
         $toTime = $toDate;
         $color = CHART_LINE_4;
         $key = "所有新增用户统计";
     }
     $fromTime = $this->product->getUserStartDate($userId, $fromTime);
     $query = $this->newusermodel->getNewUsersByUserId($fromTime, $toTime, $userId);
     $data = array();
     $maxY = 0;
     $recordCount = $query->num_rows();
     $steps = $recordCount - 1 <= 10 ? 2 : (int) (((int) $recordCount - 1) / 10);
     $xlabelArray = array();
     if ($query != null && $query->num_rows() > 0) {
         foreach ($query->result() as $row) {
             $dot = new dot();
             $dot->size(3)->halo_size(1)->colour($color);
             $dot->tooltip($row->startdate . " 新增" . $row->totalusers . "用户");
             $dot->value((int) $row->totalusers);
             if ((int) $row->totalusers > $maxY) {
                 $maxY = (int) $row->totalusers;
             }
             array_push($xlabelArray, date('y-m-d', strtotime($row->startdate)));
             array_push($data, $dot);
         }
     }
     $y = new y_axis();
     $y->set_range(0, $this->common->getMaxY($maxY), $this->common->getStepY($maxY));
     $x = new x_axis();
     $x->set_range(0, $recordCount > 1 ? $recordCount - 1 : 1);
     $x_labels = new x_axis_labels();
     $x_labels->set_steps($steps);
     $x_labels->set_vertical();
     $x_labels->set_colour(CHART_LABEL_COLOR);
     $x_labels->set_size(13);
     $x_labels->set_labels($xlabelArray);
     $x_labels->rotate(-25);
     $x->set_labels($x_labels);
     $x->set_steps(1);
     $this->ofc->set_y_axis($y);
     $this->ofc->set_x_axis($x);
     $dot = new dot();
     $dot->size(3)->halo_size(1)->colour($color);
     $line = new line();
     $line->set_default_dot_style($dot);
     $line->set_values($data);
     $line->set_width(2);
     $line->set_colour($color);
     $line->colour($color);
     $line->set_key($key, 12);
     $this->ofc->add_element($line);
     $title->set_style("{font-size: 14px; color:#000000; font-family: Verdana; text-align: center;}");
     // 		$x_legend = new x_legend("<a href=\"javascript:changeChartName('chartNewUser')\">新增用户</a> <a href=\"javascript:changeChartName('chartActiveUser')\">活跃用户</a> <a href=\"javascript:changeChartName('chartStartUser')\">启动用户</a>");
     // 		$this->ofc->set_x_legend( $x_legend );
     // 		$x_legend->set_style( '{font-size: 14px; color: #778877}' );
     $this->ofc->set_title($title);
     echo $this->ofc->toPrettyString();
 }
Example #3
0
/** flowview_viewchart()
 *
 *  This function is taken from Slowlog.  Given
 *  a title, chart type and chart data, it will
 *  echo the required syntax for the Callback
 *  from the chart page to operate corectly.
 */
function flowview_viewchart()
{
    global $colors, $config;
    include $config['base_path'] . "/plugins/flowview/lib/open-flash-chart-object.php";
    include $config['base_path'] . "/plugins/flowview/lib/open-flash-chart.php";
    $title = $_REQUEST["title"];
    $chart_type = "bar";
    $column = $_REQUEST["type"];
    $sessionid = $_REQUEST["session"];
    /* get the chart data from the session */
    if (isset($_SESSION['flowview_flows'][$sessionid]['data'])) {
        $data = $_SESSION['flowview_flows'][$sessionid]['data'];
    } else {
        $filter = createfilter($sessionid);
        $data = $_SESSION['flowview_flows'][$sessionid]['data'];
    }
    switch ($column) {
        case 'flows':
            $unit = ucfirst($column);
            $suffix = "Total Flows";
            $_SESSION['sess_flows_flows'] = 'on';
            break;
        case 'bytes':
            $unit = ucfirst($column);
            $suffix = "Bytes Exchanged";
            $_SESSION['sess_flows_bytes'] = 'on';
            break;
        case 'packets':
            $unit = ucfirst($column);
            $suffix = "Packets Examined";
            $_SESSION['sess_flows_packets'] = 'on';
            break;
    }
    $columns = $_SESSION['flowview_flows'][$sessionid]['columns'];
    foreach ($columns as $key => $cdata) {
        if (strtolower($cdata) == $column) {
            $column = $key;
        }
    }
    if (sizeof($data)) {
        $elements = array();
        $legend = array();
        $maxvalue = 0;
        if (isset($_REQUEST['exclude']) && $_REQUEST['exclude'] > 0) {
            for ($i = 0; $i < $_REQUEST['exclude']; $i++) {
                array_shift($data);
            }
        }
        foreach ($data as $row) {
            if ($maxvalue < $row[$column]) {
                $maxvalue = $row[$column];
                $scaling = flowview_autoscale($row[$column]);
            }
        }
        $maxvalue = flowview_getmax($maxvalue);
        $autorange = flowview_autoscale($maxvalue);
        $maxvalue = $maxvalue / $autorange[0];
        $i = 0;
        foreach ($data as $row) {
            $elements[$i] = new bar_value(round($row[$column] / $autorange[0], 3));
            $elements[$i]->set_colour(flowview_get_color());
            $elements[$i]->set_tooltip($unit . ": #val# " . $autorange[1]);
            if (sizeof($row) == 4) {
                $legend[] = $row[0];
            } else {
                $legend[] = $row[0] . " -\n" . $row[1];
            }
            $i++;
        }
        $bar = new bar_glass();
        $bar->set_values($elements);
        $title = new title($title . " (" . $suffix . ")");
        $title->set_style("{font-size: 18px; color: #444444; text-align: center;}");
        $x_axis_labels = new x_axis_labels();
        $x_axis_labels->set_size(10);
        $x_axis_labels->rotate(45);
        $x_axis_labels->set_labels($legend);
        $x_axis = new x_axis();
        //$x_axis->set_3d( 3 );
        $x_axis->set_colours('#909090', '#909090');
        $x_axis->set_labels($x_axis_labels);
        $y_axis = new y_axis();
        $y_axis->set_offset(true);
        $y_axis->set_colours('#909090', '#909090');
        $y_axis->set_range(0, $maxvalue, $maxvalue / 10);
        $y_axis->set_label_text("#val# " . $autorange[1]);
        $chart = new open_flash_chart();
        $chart->set_title($title);
        $chart->add_element($bar);
        $chart->set_x_axis($x_axis);
        $chart->add_y_axis($y_axis);
        $chart->set_bg_colour('#FEFEFE');
        echo $chart->toString();
    }
}
foreach ($data as $key => $v) {
    $tags->append_tag(new ofc_tag($x, $v->top, $statuscolor[$key]));
    $x++;
}
$bar = new bar_3d();
$bar->set_values(array_values($data));
$chart->add_element($bar);
$chart->add_element($tags);
//x-label
$xal = new x_axis_labels();
$tmp = array();
foreach ($statustext as $status => $text) {
    $tmp[] = new x_axis_label($text, $statuscolor[$status], $xfs, 15);
}
$xal->set_labels($tmp);
$xal->set_size($xfs);
$x = new x_axis();
$x->set_offset(true);
$x->set_labels($xal);
$x->set_3d(5);
$x->colour = '#909090';
$chart->set_x_axis($x);
//y-label
$yal = new y_axis_labels();
$yal->set_size($yfs);
$y = new y_axis();
$y->set_labels($yal);
$y->set_range(0, ceil($y_max / $step) * $step, $step);
$chart->set_y_axis($y);
//draw data for chart
echo $chart->toString();
 public function get_jx_json_bar($info, $type = '')
 {
     $year = array_keys($info);
     $price = array_values($info);
     $chart = new open_flash_chart();
     $chart->set_bg_colour('#FFFFFF');
     //flash背景颜色
     $x_labels = new x_axis_labels();
     $x_labels->set_steps(1);
     $x_labels->set_size(12);
     $x_labels->set_colour('#000000');
     if (count($year) > 0) {
         $x_labels->set_vertical();
     }
     $x_labels->set_labels($year);
     //		// 插入数据
     $x = new x_axis();
     $x->set_colour('#000000');
     $x->set_grid_colour('#dadada');
     $x->set_offset(true);
     $x->set_steps(1);
     // Add the X Axis Labels to the X Axis
     $x->set_labels($x_labels);
     $x->set_offset(true);
     $chart->set_x_axis($x);
     //		$bar = new bar_filled( '#74b1e0', '#9dc7e8' );
     //		$bar->set_values( $price );
     $price_array = array();
     foreach ($price as $k => $v) {
         $price_array[$k] = new bar_value($v);
         $price_array[$k]->set_colour('#74b1e0');
         if ($type == 'percent') {
             //$y->set_label_text("#val#%");
             $price_array[$k]->set_tooltip($year[$k] . '<br>' . '' . number_format($v) . '%');
         } else {
             $price_array[$k]->set_tooltip($year[$k] . '<br>' . '' . number_format($v));
         }
     }
     $bar = new bar_glass();
     $bar->set_values($price_array);
     $chart->add_element($bar);
     //
     // LOOK:
     //
     //$x_legend = new x_legend( '1983 to 2008' );
     //$x_legend->set_style( '{font-size: 20px; color: #778877}' );
     //$chart->set_x_legend( $x_legend );
     //
     // remove this when the Y Axis is smarter
     //
     $y = new y_axis();
     $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;
 }
Example #6
0
function result_screen($mode = 'reg')
{
    global $month_names;
    $page_title = "Statistic Center Results";
    $page_detail = "&nbsp;";
    // -----------------------------------------
    if (!checkdate($_POST['to_month'], $_POST['to_day'], $_POST['to_year'])) {
        die("The 'Date To:' time is incorrect, please check the input and try again");
    }
    if (!checkdate($_POST['from_month'], $_POST['from_day'], $_POST['from_year'])) {
        die("The 'Date From:' time is incorrect, please check the input and try again");
    }
    // -----------------------------------------
    $to_time = mktime(12, 0, 0, $_POST['to_month'], $_POST['to_day'], $_POST['to_year']);
    $from_time = mktime(12, 0, 0, $_POST['from_month'], $_POST['from_day'], $_POST['from_year']);
    // $sql_date_to = date("Y-m-d",$to_time);
    // $sql_date_from = date("Y-m-d",$from_time);
    $human_to_date = getdate($to_time);
    $human_from_date = getdate($from_time);
    // -----------------------------------------
    if ($mode == 'reg') {
        $table = 'Registration Statistics';
        $sql_table = 'users';
        $sql_field = 'added';
        $page_detail = "Showing the number of users registered. (Note: All times based on GMT)";
    } else {
        if ($mode == 'rate') {
            $table = 'Rating Statistics';
            $sql_table = 'ratings';
            $sql_field = 'added';
            $page_detail = "Showing the number of ratings. (Note: All times based on GMT)";
        } else {
            if ($mode == 'post') {
                $table = 'Post Statistics';
                $sql_table = 'posts';
                $sql_field = 'added';
                $page_detail = "Showing the number of posts. (Note: All times based on GMT)";
            } else {
                if ($mode == 'msg') {
                    $table = 'PM Sent Statistics';
                    $sql_table = 'messages';
                    $sql_field = 'added';
                    $page_detail = "Showing the number of sent messages. (Note: All times based on GMT)";
                } else {
                    if ($mode == 'torr') {
                        $table = 'Torrent Statistics';
                        $sql_table = 'torrents';
                        $sql_field = 'added';
                        $page_detail = "Showing the number of Torrents. (Note: All times based on GMT)";
                    } else {
                        if ($mode == 'bans') {
                            $table = 'Ban Statistics';
                            $sql_table = 'bans';
                            $sql_field = 'added';
                            $page_detail = "Showing the number of Bans. (Note: All times based on GMT)";
                        } else {
                            if ($mode == 'comm') {
                                $table = 'Comment Statistics';
                                $sql_table = 'comments';
                                $sql_field = 'added';
                                $page_detail = "Showing the number of torrent Comments. (Note: All times based on GMT)";
                            } else {
                                if ($mode == 'new') {
                                    $table = 'News Statistics';
                                    $sql_table = 'news';
                                    $sql_field = 'added';
                                    $page_detail = "Showing the number of News Items added. (Note: All times based on GMT)";
                                } else {
                                    if ($mode == 'poll') {
                                        $table = 'Poll Statistics';
                                        $sql_table = 'polls';
                                        $sql_field = 'added';
                                        $page_detail = "Showing the number of Polls added. (Note: All times based on GMT)";
                                    } else {
                                        if ($mode == 'rqst') {
                                            $table = 'Request Statistics';
                                            $sql_table = 'requests';
                                            $sql_field = 'added';
                                            $page_detail = "Showing the number of Requests made. (Note: All times based on GMT)";
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    switch ($_POST['timescale']) {
        case 'daily':
            $sql_date = "%w %U %m %Y";
            $php_date = "F jS - Y";
            // $sql_scale = "DAY";
            break;
        case 'monthly':
            $sql_date = "%m %Y";
            $php_date = "F Y";
            // $sql_scale = "MONTH";
            break;
        default:
            // weekly
            $sql_date = "%U %Y";
            $php_date = " [F Y]";
            // $sql_scale = "WEEK";
            break;
    }
    $sortby = isset($_POST['sortby']) ? mysql_real_escape_string($_POST['sortby']) : "";
    // $sortby = sqlesc($sortby);
    $sqlq = "SELECT UNIX_TIMESTAMP(MAX({$sql_field})) as result_maxdate,\n\t\t\t\t COUNT(*) as result_count,\n\t\t\t\t DATE_FORMAT({$sql_field},'{$sql_date}') AS result_time\n\t\t\t\t FROM {$sql_table}\n\t\t\t\t WHERE UNIX_TIMESTAMP({$sql_field}) > '{$from_time}'\n\t\t\t\t AND UNIX_TIMESTAMP({$sql_field}) < '{$to_time}'\n\t\t\t\t GROUP BY result_time\n\t\t\t\t ORDER BY {$sql_field} {$sortby}";
    $res = @mysql_query($sqlq);
    $running_total = 0;
    $max_result = 0;
    $results = array();
    if (mysql_num_rows($res)) {
        while ($row = mysql_fetch_assoc($res)) {
            if ($row['result_count'] > $max_result) {
                $max_result = $row['result_count'];
            }
            $running_total += $row['result_count'];
            $results[] = array('result_maxdate' => $row['result_maxdate'], 'result_count' => $row['result_count'], 'result_time' => $row['result_time']);
        }
        include 'chart/php-ofc-library/open-flash-chart.php';
        foreach ($results as $pOOp => $data) {
            $counts[] = (int) $data['result_count'];
            if ($_POST['timescale'] == 'weekly') {
                $labes[] = "Week #" . strftime("%W", $data['result_maxdate']) . "\n" . date($php_date, $data['result_maxdate']);
            } else {
                $labes[] = date($php_date, $data['result_maxdate']);
            }
        }
        $title = new title($page_title . "\n" . ucfirst($_POST['timescale']) . " " . $table . " " . $human_from_date['mday'] . " " . $month_names[$human_from_date['mon']] . " " . $human_from_date['year'] . " to " . $human_to_date['mday'] . " " . $month_names[$human_to_date['mon']] . " " . $human_to_date['year']);
        $chart = new open_flash_chart();
        $chart->set_title($title);
        $line_1 = new line_hollow();
        $line_1->set_values($counts);
        $line_1->set_key($table . " | Total: " . $running_total, 12);
        $line_1->set_halo_size(1);
        $line_1->set_width(2);
        $line_1->set_colour('#0099FF');
        $line_1->set_dot_size(5);
        $chart->add_element($line_1);
        $x_labels = new x_axis_labels();
        $x_labels->set_steps(2);
        $x_labels->set_vertical();
        $x_labels->set_colour('#000000');
        $x_labels->set_size(12);
        $x_labels->set_labels($labes);
        $x = new x_axis();
        $x->set_colours('#A2ACBA', '#ECFFAF');
        $x->set_steps(2);
        $x->set_labels($x_labels);
        $chart->set_x_axis($x);
        $y = new y_axis();
        $y->set_steps(2);
        $y->set_colour('#A2ACBA');
        $y->set_range(0, max($counts) + 5, 50);
        $chart->add_y_axis($y);
        $cont = $chart->toPrettyString();
        // toFile($_SERVER["DOCUMENT_ROOT"]."/chart/","chart.json",$cont,false);
        // unset($cont);
        $html = "<script type=\"text/javascript\" src=\"chart/js/json/json2.js\"></script>";
        $html .= "<script type=\"text/javascript\" src=\"chart/js/swfobject.js\"></script>";
        $html .= "<script type=\"text/javascript\">\n\n\t\t\t\tfunction open_flash_chart_data()\n\t\t\t\t{\n\t\t\t\treturn JSON.stringify(data);\n\t\t\t\t}\n\n\t\t\t\tfunction findSWF(movieName) {\n\t\t\t\t  if (navigator.appName.indexOf(\"Microsoft\")!= -1) {\n\t\t\t\t\treturn window[movieName];\n\t\t\t\t  } else {\n\t\t\t\t\treturn document[movieName];\n\t\t\t\t  }\n\t\t\t\t}\n\n\t\t\t\tvar data = " . $cont . ";\n\n\t\t\t\t\t  swfobject.embedSWF(\"chart/open-flash-chart.swf\", \"my_chart\", \"800\", \"" . (max($counts) * 5 < 200 ? "250" : (max($counts) * 5 > 400 ? "400" : max($counts) * 5)) . "\", \"9.0.0\", \"expressInstall.swf\", {\"loading\":\"Please wait while the stats are loaded!\"} );\n\t\t\t\t\t </script>";
        $html .= "<div id=\"my_chart\"></div>";
    } else {
        $html .= "No results found\n";
    }
    print $html . "<br />";
}
	while ( $val = mssql_fetch_assoc( $query ) )	{
		$jumlah[] = $val[ 'jumlah' ];
		$bulan[] = getMonthName( $val[ 'bulan' ] );
		$total = $val[ 'total' ];
	}*/
$max = 0;
$title = new title('Jumlah Data Peserta KB Per Kelurahan, Total : ' . $total . ' ( ' . date("D M d Y") . ' ) ');
$title->set_style('{font-size:20px; color: #bcd6ff; margin:0px; background-color: #5E83BF;}');
$bar = new bar_3d();
$bar->set_values($jumlah);
$bar->colour = '#9999FF';
$bar->set_on_show(new bar_on_show('grow-up', 1, 0));
$labels = new x_axis_labels();
$labels->set_labels($kelurahan);
$labels->set_size(11);
$labels->rotate(315);
$y_base = new y_axis_base();
$y_base->set_range(0, $maxJumlah + round($maxJumlah / 2), round($maxJumlah / 10));
$x = new x_axis();
$x->set_labels($labels);
$x->set_3d(5);
$y = new y_axis();
$y->set_labels($y_labels);
$tags = new ofc_tags();
$tags->font('Verdana', 10)->colour('#000000')->align_x_center()->text('#y#');
$i = 0;
foreach ($jumlah as $j) {
    $tags->append_tag(new ofc_tag($i, $j));
    $i++;
}
 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);
 }
Example #9
0
function get_linear_graph($dates, $vals, $keys = array())
{
    include 'php-ofc-library/open-flash-chart.php';
    $max_y = 0;
    $arr_filled = array();
    for ($i = 0; $i < count($dates); $i++) {
        $year[] = $dates[$i];
        for ($m = 0; $m < count($vals); $m++) {
            $price[$m][] = (int) $vals[$m][$i];
            if ($max_y < (int) $vals[$m][$i]) {
                $max_y = (int) $vals[$m][$i];
            }
            if (@$arr_filled[$m] != $vals[$m][$i] and @$arr_filled[$m] == 0) {
                @($arr_filled[$m] = (int) $vals[$m][$i]);
            }
        }
    }
    while ($max_y % 10 != 0) {
        $max_y++;
    }
    $chart = new open_flash_chart();
    //$title = new title( 'UK Petrol price (pence) per Litre' );
    $d = new anchor();
    if (count($dates) > 60) {
        $d->size(2);
    } else {
        $d->size(3);
    }
    $d->halo_size(1);
    $d->colour('#3D5C56');
    $d->rotation(0);
    $d->sides(4);
    for ($i = 0; $i < count($price); $i++) {
        if ($arr_filled[$i] == 0) {
            continue;
        }
        if ($i == 0) {
            $color = '#5E0722';
        } elseif ($i == 1) {
            $color = '#00FF00';
        } else {
            $color = '#FF0000';
        }
        $area = new area();
        $area->set_colour($color);
        $area->set_default_dot_style($d);
        $area->set_values($price[$i]);
        if (isset($keys[$i])) {
            $area->set_key($keys[$i], 12);
        }
        // mb_convert_encoding($keys[$i], "UTF-8", "Windows-1251")
        $area->set_width(2);
        $chart->add_element($area);
    }
    $x_labels = new x_axis_labels();
    if (count($dates) > 40) {
        $x_labels->set_steps(7);
    } else {
        $x_labels->set_steps(1);
    }
    $x_labels->set_vertical();
    $x_labels->set_colour('#000000');
    $x_labels->set_labels($year);
    $x_labels->rotate(-55);
    $x_labels->set_size(12);
    $x = new x_axis();
    $x->set_colour('#000000');
    $x->set_grid_colour('#DDDDDD');
    //$x->set_offset( false );
    $x->set_steps(1);
    // Add the X Axis Labels to the X Axis
    $x->set_labels($x_labels);
    $chart->set_x_axis($x);
    $y = new y_axis();
    $y->set_range(0, $max_y);
    $y->set_colour('#000000');
    $y->set_grid_colour('#DDDDDD');
    $chart->add_y_axis($y);
    $chart->set_bg_colour("#FFFFFF");
    ?>


<script type="text/javascript" src="script/json/json2.js"></script>
<script type="text/javascript" src="script/swfobject.js"></script>
<script type="text/javascript">
swfobject.embedSWF("open-flash-chart.swf", "my_chart", "600", "350", "9.0.0");
</script>

<script type="text/javascript">

function ofc_ready()
{

}

function open_flash_chart_data()
{
	return JSON.stringify(data);
}

function findSWF(movieName) {
	if (navigator.appName.indexOf("Microsoft")!= -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

var data = <?php 
    echo $chart->toPrettyString();
    ?>
;

</script>
<?php 
}