當前位置: 首頁>>代碼示例>>PHP>>正文


PHP graph::draw_stack方法代碼示例

本文整理匯總了PHP中graph::draw_stack方法的典型用法代碼示例。如果您正苦於以下問題:PHP graph::draw_stack方法的具體用法?PHP graph::draw_stack怎麽用?PHP graph::draw_stack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在graph的用法示例。


在下文中一共展示了graph::draw_stack方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: foreach

        $hours[$i] = $i;
    }
    $rawlogs = report_log_userday($user->id, $courseselect, $daystart, $logreader);
    if (empty($rawlogs)) {
        return;
    }
    foreach ($rawlogs as $rawlog) {
        $logs[$rawlog->hour] = $rawlog->num;
    }
    $graph = new graph(750, 400);
    $a = new stdClass();
    $a->coursename = format_string($course->shortname, true, array('context' => $coursecontext));
    $a->username = fullname($user, true);
    $graph->parameter['title'] = get_string("hitsoncoursetoday", "", $a);
    $graph->x_data = $hours;
    $graph->y_data['logs'] = $logs;
    $graph->y_order = array('logs');
    if (!empty($CFG->preferlinegraphs)) {
        $graph->y_format['logs'] = array('colour' => 'blue', 'line' => 'line');
    } else {
        $graph->y_format['logs'] = array('colour' => 'blue', 'bar' => 'fill', 'bar_size' => 0.9);
    }
    $graph->parameter['y_label_left'] = get_string("hits");
    $graph->parameter['label_size'] = "12";
    $graph->parameter['x_axis_angle'] = 0;
    $graph->parameter['x_label_angle'] = 0;
    $graph->parameter['shadow'] = 'none';
    error_reporting(5);
    // Ignore most warnings such as font problems etc.
    $graph->draw_stack();
}
開發者ID:janaece,項目名稱:globalclassroom4_clean,代碼行數:31,代碼來源:graph.php

示例2: draw

 /**
  * Draw a graph image. Staked area
  * @param $title string : title of graph
  * @param $x_label string : x label
  * @param $y_label string : y label
  * @param $legends array : array of strings, values are the names of every serie
  * @param $x_data array : x labels
  * @param $y_data matrix : array of array of numbers first array is indexed by legend.
  * @return nothing
  */
 public static function draw($title, $x_label, $y_label, $x_data, $y_data, $legends = null, $type_bar = false)
 {
     $graph = new graph(750, 400);
     $graph->parameter['title'] = $title;
     $graph->parameter['x_label'] = $x_label;
     $graph->parameter['y_label_left'] = $y_label;
     $graph->x_data = $x_data;
     if ($legends == null) {
         $graph->parameter['shadow'] = 'gray66';
         $graph->y_data = array('default_serie' => $y_data);
         $legends = array('default_serie');
         $cn = 0;
     } else {
         $graph->parameter['shadow'] = 'none';
         $graph->y_data = $y_data;
         $cn = 1;
     }
     $graph->y_order = $legends;
     $graph->y_format = array();
     $are_ints = true;
     $max_value = 0;
     foreach ($legends as $name) {
         $graph->y_format[$name] = array('colour' => self::$colors[$cn++ % count(self::$colors)]);
         if ($name != 'default_serie') {
             $graph->y_format[$name]['legend'] = $name;
         }
         if ($type_bar) {
             $graph->y_format[$name]['bar'] = 'fill';
             $graph->y_format[$name]['bar_size'] = 0.9;
         } else {
             $graph->y_format[$name]['area'] = 'fill';
         }
         foreach ($graph->y_data[$name] as $value) {
             $max_value = max($max_value, $value);
             $are_ints = $are_ints && (int) ($value * 100) % 100 == 0;
         }
     }
     if ($are_ints && $max_value <= 14) {
         $graph->parameter['y_axis_gridlines'] = $max_value + 1;
         $graph->parameter['y_decimal_left'] = 0;
     } else {
         $range = 0.1;
         for ($i = 0; $i < 30; $i++) {
             if ($range * 15 > $max_value) {
                 break;
             }
             $range = $range * 2.5;
             if ($range * 15 > $max_value) {
                 break;
             }
             $range *= 2;
             if ($range * 15 > $max_value) {
                 break;
             }
             $range *= 2;
         }
         $rem = $max_value - (int) ($max_value / $range) * $range;
         if ($rem > 0) {
             $max_value = $max_value + $range - $rem;
         }
         $gridlines = (int) ($max_value / $range) + 1;
         $graph->parameter['y_axis_gridlines'] = $gridlines;
         $graph->parameter['y_max_left'] = $max_value;
         $graph->parameter['y_min_left'] = 0;
         if ($max_value >= 1) {
             $graph->parameter['y_resolution_left'] = 4;
             //Don't ajust y_max
         } else {
             $graph->parameter['y_resolution_left'] = 0;
         }
         if ((int) $range == $range) {
             $graph->parameter['y_decimal_left'] = 0;
         } elseif ((int) ($range * 10) == 10 * $range) {
             $graph->parameter['y_decimal_left'] = 1;
         } else {
             $graph->parameter['y_decimal_left'] = 2;
         }
     }
     $graph->parameter['label_size'] = "12";
     $graph->parameter['legend_size'] = "10";
     $graph->parameter['x_label_angle'] = 0;
     $graph->parameter['tick_length'] = 0;
     $graph->parameter['legend'] = 'inside-top';
     $graph->parameter['shadow_offset'] = 5;
     $graph->parameter['shadow_below_axis'] = false;
     error_reporting(5);
     // ignore warnings
     $graph->draw_stack();
 }
開發者ID:go38,項目名稱:moodle-mod_vpl,代碼行數:99,代碼來源:vpl_graph.class.php


注:本文中的graph::draw_stack方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。