当前位置: 首页>>代码示例>>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;未经允许,请勿转载。