コード例 #1
0
ファイル: index.php プロジェクト: cebe/php-orm-benchmark-1
 public function action_index()
 {
     require APPPATH . '/vendor/php-recipe-2nd/make_chart_parts.php';
     $output = APPPATH . '/cache/benchmark-results.json';
     $results = json_decode(file_get_contents($output), true);
     $barColors = array('pink', 'purple', 'green', 'red', 'blue', 'gray', 'orange');
     // Time Benchmark
     $data[] = array('', 'time', array('role' => 'style'));
     // header
     $colors = $barColors;
     foreach ($results as $fw => $result) {
         $data[] = array($fw, $result['time'], array_shift($colors));
     }
     //var_dump($data); exit;
     $options = array('title' => 'Time', 'titleTextStyle' => array('fontSize' => 16), 'hAxis' => array('title' => 'time (ms)', 'titleTextStyle' => array('bold' => true)), 'vAxis' => array('minValue' => 0, 'maxValue' => 0.01), 'width' => 500, 'height' => 400, 'bar' => array('groupWidth' => '90%'), 'legend' => array('position' => 'none'));
     $type = 'ColumnChart';
     list($chart_time, $div_time) = makeChartParts($data, $options, $type);
     // Memory Benchmark
     $data = array();
     $data[] = array('', 'memory', array('role' => 'style'));
     // header
     $colors = $barColors;
     foreach ($results as $fw => $result) {
         $data[] = array($fw, $result['memory'], array_shift($colors));
     }
     $options = array('title' => 'Memory', 'titleTextStyle' => array('fontSize' => 16), 'hAxis' => array('title' => 'memory (KB)', 'titleTextStyle' => array('bold' => true)), 'vAxis' => array('minValue' => 0, 'maxValue' => 1), 'width' => 500, 'height' => 400, 'bar' => array('groupWidth' => '90%'), 'legend' => array('position' => 'none'));
     $type = 'ColumnChart';
     list($chart_mem, $div_mem) = makeChartParts($data, $options, $type);
     $data = ['chart_time' => $chart_time, 'div_time' => $div_time, 'chart_mem' => $chart_mem, 'div_mem' => $div_mem];
     return View::forge('index/index', $data, false);
 }
コード例 #2
0
function make_graph($id, $title, $hAxis_title)
{
    global $results;
    $barColors = array('DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen', 'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', 'DarkOrchid', 'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', 'DarkSlateGray', 'DarkBlue', 'DarkCyan', 'DarkGoldenRod', 'DarkGray', 'DarkGreen', 'DarkKhaki', 'DarkMagenta', 'DarkOliveGreen', 'DarkOrange', 'DarkOrchid', 'DarkRed', 'DarkSalmon', 'DarkSeaGreen', 'DarkSlateBlue', 'DarkSlateGray');
    $graphWidth = 1000;
    $graphHeight = 400;
    $data = array();
    $data[] = array('', $id, array('role' => 'style'));
    // header
    $colors = $barColors;
    foreach ($results as $fw => $result) {
        $data[] = array($fw, $result[$id], array_shift($colors));
    }
    //var_dump($data); exit;
    $options = array('title' => $title, 'titleTextStyle' => array('fontSize' => 16), 'hAxis' => array('title' => $hAxis_title, 'titleTextStyle' => array('bold' => true)), 'vAxis' => array('minValue' => 0, 'maxValue' => 0.01), 'width' => $graphWidth, 'height' => $graphHeight, 'bar' => array('groupWidth' => '90%'), 'legend' => array('position' => 'none'));
    $type = 'ColumnChart';
    return makeChartParts($data, $options, $type);
}
コード例 #3
0
ファイル: 151_pie_chart.php プロジェクト: sxyr318/study_php
// 別ファイルのユーザー定義関数「makeChartParts()」を読み込む
require_once './make_chart_parts.php';
// グラフ1の値
$data[] = array();
$data[] = array('', '2005年');
$data[] = array('15才未満', 14.8);
$data[] = array('15~64歳', 67.90000000000001);
$data[] = array('64歳以上', 17.3);
// グラフ1のオプション
$options = array('title' => '2005年', 'titleTextStyle' => array('fontSize' => 16), 'width' => 360, 'height' => 300, 'legend' => array('position' => 'bottom', 'alignment' => 'center'));
// 凡例
// グラフ種類(円グラフ)
$type = 'PieChart';
// 「グラフ1」グラフ描画のJavaScriptの関数、表示させる<div>タグの生成
list($chart1, $div) = makeChartParts($data, $optins, $type);
// グラフ2の値
$data[] = array();
$data[] = array('', '2010年');
$data[] = array('15才未満', 14.5);
$data[] = array('15~64歳', 65.2);
$data[] = array('65歳以上', 20.3);
// グラフ2のオプション(グラフ1のオプションのタイトルのみ変更)
$options['titile'] = '2010年';
// 「グラフ2」グラフ描画のJavaScriptの関数、表示させる<div>タグの生成
list($chart2, $div2) = makechartParts($data, $options, $type);
?>
<!DOCTYPE html>
<html kang="ja">
<head>
<meta charset="UFT-8">
コード例 #4
0
    $data[] = array($fw, $result['memory'], array_shift($colors));
}
$options = array('title' => 'Memory', 'titleTextStyle' => array('fontSize' => 16), 'hAxis' => array('title' => 'peak memory (MB)', 'titleTextStyle' => array('bold' => true)), 'vAxis' => array('minValue' => 0, 'maxValue' => 1), 'width' => $graphWidth, 'height' => $graphHeight, 'bar' => array('groupWidth' => '90%'), 'legend' => array('position' => 'none'));
$type = 'ColumnChart';
list($chart_mem, $div_mem) = makeChartParts($data, $options, $type);
// Exec Time Benchmark
$data = array();
$data[] = array('', 'time', array('role' => 'style'));
// header
$colors = $barColors;
foreach ($results as $fw => $result) {
    $data[] = array($fw, $result['time'], array_shift($colors));
}
$options = array('title' => 'Exec Time', 'titleTextStyle' => array('fontSize' => 16), 'hAxis' => array('title' => 'ms', 'titleTextStyle' => array('bold' => true)), 'vAxis' => array('minValue' => 0, 'maxValue' => 1), 'width' => $graphWidth, 'height' => $graphHeight, 'bar' => array('groupWidth' => '90%'), 'legend' => array('position' => 'none'));
$type = 'ColumnChart';
list($chart_time, $div_time) = makeChartParts($data, $options, $type);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PHP Framework Benchmark</title>
<script src="https://www.google.com/jsapi"></script>
<script>
<?php 
echo $chart_rpm, $chart_mem, $chart_time;
?>
</script>
</head>
<body>
<h1>PHP Framework Benchmark</h1>
コード例 #5
0
ファイル: 150_bar_chart.php プロジェクト: sxyr318/study_php
// 別ファイルのユーザー定義関数「makeChartParts()」を読み込む
require_once './make_chart_parts.php';
// グラフの値
$data = array();
$data[] = array('', '2005年', '2010年');
$data[] = array('愛知県', 7254432, 7410719);
$data[] = array('岐阜県', 2107293, 2080773);
$data[] = array('三重県', 1867166, 1854724);
// グラフのオプション
$options = array('title' => '東海三県の人口(国税調査)', 'titleTextStyle' => array('fontSize' => 16), 'hAxis' => array('title' => '単価:人'), 'width' => 560, 'height' => 400, 'colors' => array('#396', 'darkorange'), 'legend' => array('position' => 'top', 'alognment' => 'end'));
// 凡例
// グラフ種類(棒グラフ)
$type = 'BarChart';
// グラフ描画のJavaScriptの関数、表示させる<div>タグの生成
list($chart, $div) = makeChartParts($data, $type);
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>棒グラフを生成したい</title>
<script src="https://www.google.com/jsapi"></script>
<script>
<?php 
// グラフ描画関数を表示
echo $chart;
?>
</script>
</head>
<body>