Exemple #1
0
 function index()
 {
     if ($this->perm_user->reports->access) {
         /* Start Overall Worktype */
         $this->load->model('worktype_model');
         $worktypes = $this->worktype_model->select_multiple($this->session->userdata('company_id'));
         $values = array();
         $legends = array();
         $labels = array();
         foreach ($worktypes as $worktype) {
             if ($worktype['segment_count']) {
                 $labels[] = $worktype['name'];
                 $legends[] = $worktype['name'] . ' (' . $worktype['hour_float'] . ')';
                 $values[] = $worktype['hour_float'];
             }
         }
         $overall_worktype_chart = new gPieChart(500, 200);
         #$overall_worktype_chart->set3D(true);
         $overall_worktype_chart->addDataSet($values);
         $overall_worktype_chart->setLegend($legends);
         $overall_worktype_chart->setLabels($labels);
         $overall_worktype_chart->setColors($this->colors);
         $data['worktypes'] = $overall_worktype_chart->getUrl();
         /* Start User Group By Time */
         $usertimes = $this->statistics_model->select_users_groupby_time($this->session->userdata('company_id'));
         $values = array();
         $legends = array();
         $labels = array();
         foreach ($usertimes as $usertime) {
             if ($usertime['segment_count']) {
                 $labels[] = $usertime['user_name'];
                 $legends[] = $usertime['user_name'] . ' (' . $usertime['hour_float'] . ')';
                 $values[] = $usertime['hour_float'];
             }
         }
         $overall_usertime_chart = new gPieChart(500, 200);
         #$overall_worktype_chart->set3D(true);
         $overall_usertime_chart->addDataSet($values);
         $overall_usertime_chart->setLegend($legends);
         $overall_usertime_chart->setLabels($labels);
         $overall_usertime_chart->setColors($this->colors);
         $data['usertimes'] = $overall_usertime_chart->getUrl();
         $this->load->view('statistics/xhr_overview', $data);
     } else {
         $data['error'] = $this->lang->line('error_low_perm');
         $this->load->view('xhr_error', $data);
     }
 }
    function test_PieChart()
    {
        $piChart = new gPieChart();
        $piChart->setTitle("A Title");
        $piChart->addDataSet(array(112, 315, 66, 40));
        $piChart->setLegend(array("first", "second", "third", "fourth"));
        $piChart->setLabels(array("first", "second", "third", "fourth"));
        $piChart->setColors(array("ff3344", "11ff11", "22aacc", "3333aa"));
        $text = <<<END
newPieChart:
setTitle: A Title
addDataSet: 112,315,66,40
setLegend: first, second, third, fourth
setLabels: first, second, third, fourth
setColors: ff3344, 11ff11, 22aacc, 3333aa
END;
        $parser = new gChartPhpDSLParser();
        $parser->parse($text);
        $this->assertEqual($piChart->getUrl(), $parser->getUrl());
    }
img { display:block; }
</style>
</head>
<body>
<h1>PHP Wrapper for Google Chart API Examples - 0.5</h1>
<h1>Quick examples.</h1>

<?php 
require '../inc/gChartInit.php';
?>
<h2>Pie Chart</h2>
<?php 
$piChart = new gPieChart();
$piChart->addDataSet(array(112, 315, 66, 40));
$piChart->setLegend(array("first", "second", "third", "fourth"));
$piChart->setLabels(array("first", "second", "third", "fourth"));
$piChart->setColors(array("ff3344", "11ff11", "22aacc", "3333aa"));
?>
<img src="<?php 
print $piChart->getUrl();
?>
" /> <br> pie chart using the gPieChart class.
<p>
<em>code:</em><br>
<code>
$piChart = new gPieChar();<br>
$piChart->addDataSet(array(112,315,66,40));<br>
$piChart->setLegend(array("first", "second", "third","fourth"));<br>
$piChart->setLabels(array("first", "second", "third","fourth"));<br>
$piChart->setColors(array("ff3344", "11ff11", "22aacc", "3333aa"));<br>
</code>
Exemple #4
0
$piChart1 = new gPieChart(250, 125);
$piChart1->addDataSet(array($onlinecount, $offlinecount, $deadcount));
$piChart1->setLegend(array("Online", "Offline", "Dead"));
$piChart1->setLabels(array(round($onlinecount / $statustotal * 100, 0) . "%", round($offlinecount / $statustotal * 100, 0) . "%", round($deadcount / $statustotal * 100, 0) . "%"));
$piChart1->setColors(array("5D8AA8", "B4CDCD", "E32636"));
$piChart1->addBackgroundFill('bg', '000000');
$piChart2 = new gPieChart(250, 125);
$piChart2->addDataSet(array($admintruecount, $adminfalsecount));
$piChart2->setLegend(array("Admin", "User"));
$piChart2->setLabels(array(round($admintruecount / $statustotal * 100, 0) . "%", round($adminfalsecount / $statustotal * 100, 0) . "%"));
$piChart2->setColors(array("5D8AA8", "B4CDCD"));
$piChart2->addBackgroundFill('bg', '000000');
$piChart3 = new gPieChart(250, 125);
$piChart3->addDataSet(array($windows7count, $windowsvistacount, $windowsxpcount, $unknowncount));
$piChart3->setLegend(array("7", "Vista", "XP", "Unknown"));
$piChart3->setLabels(array(round($windows7count / $statustotal * 100, 0) . "%", round($windowsvistacount / $statustotal * 100, 0) . "%", round($windowsxpcount / $statustotal * 100, 0) . "%", round($unknowncount / $statustotal * 100, 0) . "%"));
$piChart3->setColors(array("5D8AA8", "B4CDCD", "E32636", "EFDECD"));
$piChart3->addBackgroundFill('bg', '000000');
$cclist = array();
$ccvalues = array();
while ($row = mysql_fetch_array($ccs)) {
    array_push($cclist, $row[0]);
    $values = mysql_query("SELECT * FROM clients WHERE cc LIKE '{$row['0']}'");
    array_push($ccvalues, mysql_num_rows($values) / $totalbots * 100);
}
$map1 = new gMapChart();
$map1->setZoomArea('world');
$map1->setStateCodes($cclist);
$map1->addDataSet($ccvalues);
$map1->setColors('000000', array('0099FF', '002288'));
$map1->addBackgroundFill('bg', '000000');