コード例 #1
0
 public static function GoogleCharts()
 {
     if (empty(self::$GoogleCharts)) {
         include_once __DIR__ . '/class.GoogleCharts.php';
         self::$GoogleCharts = new GoogleCharts(self::$jQObj);
     }
     return self::$GoogleCharts;
 }
コード例 #2
0
<?php

include_once __DIR__ . '/classes/class.nUberJTools.php';
$result = array(0 => array('id' => 1, 'lesson' => 'Community Health Care', 'lesson_activity' => 'CHC.001', 'count(<50%)' => 7, 'count(Between 50-60%)' => 4, 'count(>60%)' => 9), 1 => array('id' => 2, 'lesson' => 'Community Health Care', 'lesson_activity' => 'CHC.002', 'count(<50%)' => 32, 'count(Between 50-60%)' => 11, 'count(>60%)' => 65), 2 => array('id' => 3, 'lesson' => 'Community Health Care', 'lesson_activity' => 'CHC.003', 'count(<50%)' => 44, 'count(Between 50-60%)' => 12, 'count(>60%)' => 76));
$Googlizer = nUberJTools::GoogleCharts();
$title = "My Trend Chart";
// Set options in general
$options['legend'] = 'none';
$options['is3D'] = 'true';
foreach ($result as $i => $row) {
    // The incr setting allows for unique identifier when making multiple charts
    $settings["incr"] = $i;
    // Create a holder name for the javascript function
    $settings['id'] = "trend" . $settings["incr"];
    // Create a title
    $settings['title'] = "PieChart " . $i;
    // Assign data for js function to use
    $settings['data'] = array("Title" => $settings['title'], "cond1" => $row['count(<50%)'], "cond2" => $row['count(Between 50-60%)'], "cond3" => $row['count(>60%)']);
    // Returns the assembled js data arrays and the js function that displays chart
    // Create the piechart
    $Googlizer->CreateChart($settings)->jScripter()->MakeContainer(array("w" => 500, "h" => 500, "unit" => "px", "wrap" => "div"));
}
// This applies the javascript options
echo $Googlizer->ChartOptions($options)->ChartKind(GoogleCharts::PIE)->CreateJavascript(array("wrap" => true, "lib" => true));
?>
 
<html> 
<body> 
<?php 
echo $Googlizer->Containers();
?>