当前位置: 首页>>代码示例>>PHP>>正文


PHP Graph::NumString方法代码示例

本文整理汇总了PHP中Graph::NumString方法的典型用法代码示例。如果您正苦于以下问题:PHP Graph::NumString方法的具体用法?PHP Graph::NumString怎么用?PHP Graph::NumString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph的用法示例。


在下文中一共展示了Graph::NumString方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: GetGridPoints

 /**
  * Returns the grid points as an associative array:
  * array($value => $position)
  */
 public function GetGridPoints($min_space, $start)
 {
     $points = array();
     $max_div = $this->length / $min_space;
     $pow_div = $this->lgmax - $this->lgmin;
     $div = 1;
     $this->grid_space = $this->length / $pow_div * $div;
     $spoints = array();
     if ($this->divisions) {
         $this->grid_split = $this->divisions;
     } else {
         $this->grid_split = $this->FindDivision($this->grid_space, $min_space);
     }
     if ($this->grid_split) {
         for ($l = $this->grid_split; $l < $this->base; $l += $this->grid_split) {
             $spoints[] = log($l, $this->base);
         }
     }
     $l = $this->lgmin;
     while ($l <= $this->lgmax) {
         $val = pow($this->base, $l) * ($this->negative ? -1 : 1);
         // convert to string to use as array key
         $point = $this->units_before . Graph::NumString($val) . $this->units_after;
         $pos = $this->Position($val);
         $position = $start + $this->direction * $pos;
         $points[] = new GridPoint($position, $point, $val);
         // add in divisions between powers
         if ($l < $this->lgmax) {
             foreach ($spoints as $l1) {
                 $val = pow($this->base, $l + $l1) * ($this->negative ? -1 : 1);
                 $point = $this->units_before . Graph::NumString($val) . $this->units_after;
                 $pos = $this->Position($val);
                 $position = $start + $this->direction * $pos;
                 $points[] = new GridPoint($position, $point, $val);
             }
         }
         ++$l;
     }
     usort($points, $this->direction < 0 ? 'gridpoint_rsort' : 'gridpoint_sort');
     return $points;
 }
开发者ID:roarkmccolgan,项目名称:dellconvergedmaturity,代码行数:45,代码来源:SVGGraphAxisLog.php

示例2: DrawLabel

 /**
  * Draws a label
  */
 protected function DrawLabel($dataset, $index, &$gobject)
 {
     if (is_null($gobject['item']) && empty($gobject['content'])) {
         return '';
     }
     if (is_null($gobject['item'])) {
         // convert to string - numbers will confuse TextSize()
         $content = (string) $gobject['content'];
     } else {
         if (is_callable($this->data_label_callback)) {
             $content = call_user_func($this->data_label_callback, $dataset, $gobject['item']->key, $gobject['item']->value);
             if (is_null($content)) {
                 $content = '';
             }
         } else {
             $content = $gobject['item']->Data('label');
         }
         if (is_null($content)) {
             $content = !is_null($gobject['content']) ? $gobject['content'] : $this->units_before_label . Graph::NumString($gobject['item']->value) . $this->units_label;
         }
     }
     if ($content == '') {
         return '';
     }
     $style = $this->graph->DataLabelStyle($dataset, $index, $gobject['item']);
     if (!is_null($gobject['item'])) {
         $this->ItemStyles($style, $gobject['item']);
     } elseif ($dataset === '_user') {
         $this->UserStyles($style, $gobject);
     }
     $type = $style['type'];
     $font_size = max(4, (double) $style['font_size']);
     $space = (double) $style['space'];
     if ($type == 'box' || $type == 'bubble') {
         $label_pad_x = $style['pad_x'];
         $label_pad_y = $style['pad_y'];
     } else {
         $label_pad_x = $label_pad_y = 0;
     }
     // reasonable approximation of the baseline position
     $text_baseline = $font_size * 0.85;
     // get size of label
     list($tw, $th) = Graph::TextSize($content, $font_size, $style['font_adjust'], $this->encoding, $style['angle'], $font_size);
     $label_w = $tw + $label_pad_x * 2;
     $label_h = $th + $label_pad_y * 2;
     $label_wp = $label_w + $space * 2;
     $label_hp = $label_h + $space * 2;
     $pos = NULL;
     if ($dataset === '_user') {
         // user label, so convert coordinates
         $pos = isset($gobject['position']) ? $gobject['position'] : 'above';
         $xy = $this->coords->TransformCoords($gobject['x'], $gobject['y']);
         $gobject['x'] = $xy[0];
         $gobject['y'] = $xy[1];
     } else {
         // try to get position from item
         if (!is_null($gobject['item'])) {
             $pos = $gobject['item']->Data('data_label_position');
         }
         // find out from graph class where this label should go
         if (is_null($pos)) {
             $pos = $this->graph->DataLabelPosition($dataset, $index, $gobject['item'], $gobject['x'], $gobject['y'], $gobject['width'], $gobject['height'], $label_wp, $label_hp);
         }
     }
     // convert position string to an actual location
     list($x, $y, $anchor, $hpos, $vpos) = $res = Graph::RelativePosition($pos, $gobject['y'], $gobject['x'], $gobject['y'] + $gobject['height'], $gobject['x'] + $gobject['width'], $label_w, $label_h, $space, true);
     // if the position is outside, use the alternative colours
     $colour = $style['colour'];
     $back_colour = $style['back_colour'];
     if (strpos($hpos . $vpos, 'o') !== FALSE) {
         if (!empty($style['altcolour'])) {
             $colour = $style['altcolour'];
         }
         if (!empty($style['back_altcolour'])) {
             $back_colour = $style['back_altcolour'];
         }
     }
     $text = array('font-family' => $style['font'], 'font-size' => $font_size, 'fill' => $colour);
     $label_markup = '';
     // rotation
     if ($style['angle'] != 0) {
         // need text size pre-rotation
         list($tbw, $tbh) = Graph::TextSize($content, $font_size, $style['font_adjust'], $this->encoding, 0, $font_size);
         if ($anchor == 'middle') {
             $text['x'] = $x;
         } elseif ($anchor == 'start') {
             $text['x'] = $x + $label_pad_x + ($tw - $tbw) / 2;
         } else {
             $text['x'] = $x - $label_pad_x - ($tw - $tbw) / 2;
         }
         $text['y'] = $y + $label_h / 2 - $tbh / 2 + $text_baseline;
     } else {
         if ($anchor == 'start') {
             $text['x'] = $x + $label_pad_x;
         } elseif ($anchor == 'end') {
             $text['x'] = $x - $label_pad_x;
         } else {
//.........这里部分代码省略.........
开发者ID:ppKrauss,项目名称:openness-metrics,代码行数:101,代码来源:SVGGraphDataLabels.php

示例3: BarTotal

 /**
  * Bar total label
  */
 protected function BarTotal($total, &$bar, $label_above)
 {
     $this->Bar($total, $bar);
     $content = $this->units_before_label . Graph::NumString($total) . $this->units_label;
     $font_size = $this->bar_total_font_size;
     $space = $this->bar_total_space;
     $x = $bar['x'] + $bar['width'] / 2;
     $colour = $this->bar_total_colour;
     $swap = $bar['y'] >= $this->height - $this->pad_bottom - $this->y_axes[$this->main_y_axis]->Zero();
     $y = $swap ? $bar['y'] + $bar['height'] + $font_size + $space : $bar['y'] - $space;
     $offset = 0;
     // make space for label
     if ($label_above) {
         $offset = $this->bar_label_font_size + $this->bar_label_space;
         if (!$swap) {
             $offset = -$offset;
         }
     }
     $text = array('x' => $x, 'y' => $y + $offset, 'text-anchor' => 'middle', 'font-family' => $this->bar_total_font, 'font-size' => $font_size, 'fill' => $this->bar_total_colour);
     if ($this->bar_total_font_weight != 'normal') {
         $text['font-weight'] = $this->bar_total_font_weight;
     }
     return $this->Element('text', $text, NULL, $content);
 }
开发者ID:roarkmccolgan,项目名称:dellconvergedmaturity,代码行数:27,代码来源:SVGGraphStackedBarGraph.php

示例4: FormatTooltip

 /**
  * Override to show key and value
  */
 protected function FormatTooltip(&$item, $dataset, $key, $value)
 {
     $text = is_numeric($key) ? $this->units_before_tooltip_key . Graph::NumString($key) . $this->units_tooltip_key : $key;
     $text .= ', ' . $this->units_before_tooltip . Graph::NumString($value) . $this->units_tooltip;
     return $text;
 }
开发者ID:battelle-dsi-capstone-2015,项目名称:corpus_topic_browser,代码行数:9,代码来源:SVGGraphPointGraph.php

示例5: Draw

 /**
  * Draws the pie graph
  */
 protected function Draw()
 {
     if (!$this->calc_done) {
         $this->Calc();
     }
     $unit_slice = 2.0 * M_PI / $this->total;
     $min_slice_angle = $this->ArrayOption($this->data_label_min_space, 0);
     $vcount = 0;
     // need to store the original position of each value, because the
     // sorted list must still refer to the relevant legend entries
     $position = 0;
     $values = array();
     foreach ($this->values[0] as $item) {
         $values[$item->key] = array($position++, $item->value, $item);
         if (!is_null($item->value)) {
             ++$vcount;
         }
     }
     if ($this->sort) {
         uasort($values, 'pie_rsort');
     }
     $body = '';
     $slice = 0;
     $slices = array();
     $slice_no = 0;
     foreach ($values as $key => $value) {
         // get the original array position of the value
         $original_position = $value[0];
         $item = $value[2];
         $value = $value[1];
         if ($this->legend_show_empty || $item->value != 0) {
             $attr = array('fill' => $this->GetColour($item, $slice, NULL, true, true));
             $this->SetStroke($attr, $item, 0, 'round');
             // store the current style referenced by the original position
             $this->slice_styles[$original_position] = $attr;
             ++$slice;
         }
         if (!$this->GetSliceInfo($slice_no++, $item, $angle_start, $angle_end, $radius_x, $radius_y)) {
             continue;
         }
         // store details for label position and tail
         $this->slice_info[$original_position] = new SVGGraphSliceInfo($angle_start, $angle_end, $radius_x, $radius_y);
         $parts = array();
         if ($this->show_label_key) {
             $parts = explode("\n", $this->GetKey($this->values->AssociativeKeys() ? $original_position : $key));
         }
         if ($this->show_label_amount) {
             $parts[] = $this->units_before_label . Graph::NumString($value) . $this->units_label;
         }
         if ($this->show_label_percent) {
             $parts[] = Graph::NumString($value / $this->total * 100.0, $this->label_percent_decimals) . '%';
         }
         $label_content = implode("\n", $parts);
         // add the data label if the slice angle is big enough
         if ($this->slice_info[$original_position]->Degrees() >= $min_slice_angle) {
             $this->AddDataLabel(0, $original_position, $attr, $item, $this->x_centre, $this->y_centre, 1, 1, $label_content);
         }
         if ($radius_x || $radius_y) {
             if ($this->show_tooltips) {
                 $this->SetTooltip($attr, $item, 0, $key, $value, !$this->compat_events);
             }
             $this->CalcSlice($angle_start, $angle_end, $radius_x, $radius_y, $x1, $y1, $x2, $y2);
             $single_slice = $vcount == 1 || (string) $x1 == (string) $x2 && (string) $y1 == (string) $y2 && (string) $angle_start != (string) $angle_end;
             if ($this->semantic_classes) {
                 $attr['class'] = "series0";
             }
             $path = $this->GetSlice($item, $angle_start, $angle_end, $radius_x, $radius_y, $attr, $single_slice);
             $this_slice = $this->GetLink($item, $key, $path);
             if ($single_slice) {
                 array_unshift($slices, $this_slice);
             } else {
                 $slices[] = $this_slice;
             }
         }
     }
     $series = implode($slices);
     if ($this->semantic_classes) {
         $series = $this->Element('g', array('class' => 'series'), NULL, $series);
     }
     $body .= $series;
     $extras = $this->PieExtras();
     return $body . $extras;
 }
开发者ID:schnitzelx,项目名称:SchoolSurvey,代码行数:86,代码来源:SVGGraphPieGraph.php

示例6: Draw

 /**
  * Draws the pie graph
  */
 protected function Draw()
 {
     if (!$this->calc_done) {
         $this->Calc();
     }
     $speed_in = $this->show_labels && $this->label_fade_in_speed ? $this->label_fade_in_speed / 100.0 : 0;
     $speed_out = $this->show_labels && $this->label_fade_out_speed ? $this->label_fade_out_speed / 100.0 : 0;
     $unit_slice = 2.0 * M_PI / $this->total;
     $ccount = count($this->colours);
     $vcount = 0;
     // need to store the original position of each value, because the
     // sorted list must still refer to the relevant legend entries
     $position = 0;
     $values = array();
     foreach ($this->values[0] as $item) {
         $values[$item->key] = array($position++, $item->value, $item);
         if (!is_null($item->value)) {
             ++$vcount;
         }
     }
     if ($this->sort) {
         uasort($values, 'pie_rsort');
     }
     $body = $labels = '';
     $slice = 0;
     $slices = array();
     $slice_no = 0;
     foreach ($values as $key => $value) {
         // get the original array position of the value
         $original_position = $value[0];
         $item = $value[2];
         $value = $value[1];
         if ($this->legend_show_empty || $item->value != 0) {
             $attr = array('fill' => $this->GetColour($item, $slice % $ccount, true, true));
             $this->SetStroke($attr, $item, 0, 'round');
             // store the current style referenced by the original position
             $this->slice_styles[$original_position] = $attr;
             ++$slice;
         }
         if (!$this->GetSliceInfo($slice_no++, $item, $angle_start, $angle_end, $radius_x, $radius_y)) {
             continue;
         }
         $t_style = NULL;
         if ($this->show_labels) {
             $text['id'] = $this->NewID();
             if ($this->label_fade_in_speed && $this->compat_events) {
                 $text['opacity'] = '0.0';
             }
             // display however many lines of label
             $label = $item->Data('label');
             if (is_null($label)) {
                 $parts = array();
                 if ($this->show_label_key) {
                     $parts = explode("\n", $this->GetKey($this->values->AssociativeKeys() ? $original_position : $key));
                 }
                 if ($this->show_label_amount) {
                     $parts[] = $this->units_before_label . Graph::NumString($value) . $this->units_label;
                 }
                 if ($this->show_label_percent) {
                     $parts[] = Graph::NumString($value / $this->total * 100.0, $this->label_percent_decimals) . '%';
                 }
             } else {
                 $parts = array($label);
             }
             $parts = implode("\n", $parts);
             if ($vcount > 1) {
                 list($xc, $yc) = $this->GetLabelPosition($item, $angle_start, $angle_end, $radius_x, $radius_y, $parts);
             } else {
                 $xc = $yc = 0;
             }
             $tx = $this->x_centre + $xc;
             $ty = $this->y_centre + $yc;
             $text['x'] = $tx;
             $text['y'] = $ty;
             $text['fill'] = $this->label_colour;
             if (!empty($this->label_back_colour)) {
                 $outline = array('stroke-width' => '3px', 'stroke' => $this->label_back_colour, 'stroke-linejoin' => 'round');
                 $t1 = array_merge($outline, $text);
                 $labels .= $this->Text($parts, $this->label_font_size, $t1);
             }
             $labels .= $this->Text($parts, $this->label_font_size, $text);
         }
         if ($radius_x || $radius_y) {
             if ($this->show_tooltips) {
                 $this->SetTooltip($attr, $item, $key, $value, !$this->compat_events);
             }
             if ($speed_in || $speed_out) {
                 $this->SetFader($attr, $speed_in, $speed_out, $text['id'], !$this->compat_events);
             }
             $this->CalcSlice($angle_start, $angle_end, $radius_x, $radius_y, $x1, $y1, $x2, $y2);
             $single_slice = $vcount == 1 || (string) $x1 == (string) $x2 && (string) $y1 == (string) $y2 && (string) $angle_start != (string) $angle_end;
             $path = $this->GetSlice($item, $angle_start, $angle_end, $radius_x, $radius_y, $attr, $single_slice);
             $this_slice = $this->GetLink($item, $key, $path);
             if ($single_slice) {
                 array_unshift($slices, $this_slice);
             } else {
                 $slices[] = $this_slice;
//.........这里部分代码省略.........
开发者ID:roarkmccolgan,项目名称:dellconvergedmaturity,代码行数:101,代码来源:SVGGraphPieGraph.php

示例7: GetGridPoints

 /**
  * Returns the grid points as an array of GridPoints
  */
 public function GetGridPoints($min_space, $start)
 {
     $spacing = $this->Grid($min_space);
     $c = $pos = 0;
     $dlength = $this->length + $spacing * 0.5;
     $points = array();
     if ($dlength / $spacing > 10000) {
         $pcount = $dlength / $spacing;
         throw new Exception("Too many grid points ({$this->min_value}->{$this->max_value} = {$pcount})");
     }
     while ($pos < $dlength) {
         // convert to string to use as array key
         $value = ($pos - $this->zero) / $this->unit_size;
         if (is_callable($this->label_callback)) {
             $text = call_user_func($this->label_callback, $value);
         } else {
             $text = $this->units_before . Graph::NumString($value, $this->decimal_digits) . $this->units_after;
         }
         $position = $start + $this->direction * $pos;
         $points[] = new GridPoint($position, $text, $value);
         $pos = ++$c * $spacing;
     }
     // uneven means the divisions don't fit exactly, so add the last one in
     if ($this->uneven) {
         $pos = $this->length - $this->zero;
         $value = $pos / $this->unit_size;
         if (is_callable($this->label_callback)) {
             $text = call_user_func($this->label_callback, $value);
         } else {
             $text = $this->units_before . Graph::NumString($value, $this->decimal_digits) . $this->units_after;
         }
         $position = $start + $this->direction * $this->length;
         $points[] = new GridPoint($position, $text, $value);
     }
     // using 'GridPoint::sort' silently fails in PHP 5.1.x
     usort($points, $this->direction < 0 ? 'gridpoint_rsort' : 'gridpoint_sort');
     $this->grid_spacing = $spacing;
     return $points;
 }
开发者ID:schnitzelx,项目名称:SchoolSurvey,代码行数:42,代码来源:SVGGraphAxis.php

示例8: BarLabel

 /**
  * Text labels in or above the bar
  */
 protected function BarLabel(&$item, &$bar, $offset_y = null)
 {
     $content = $item->Data('label');
     if (is_null($content)) {
         $content = $this->units_before_label . Graph::NumString($item->value) . $this->units_label;
     }
     $font_size = $this->bar_label_font_size;
     $space = $this->bar_label_space;
     $x = $bar['x'] + $bar['width'] / 2;
     $colour = $this->bar_label_colour;
     $acolour = $this->bar_label_colour_above;
     if (!is_null($offset_y)) {
         $y = $bar['y'] + $offset_y;
     } else {
         $pos = $this->BarLabelPosition($bar);
         $swap = $bar['y'] >= $this->height - $this->pad_bottom - $this->y_axes[$this->main_y_axis]->Zero();
         switch ($pos) {
             case 'above':
                 $y = $swap ? $bar['y'] + $bar['height'] + $font_size + $space : $bar['y'] - $space;
                 if (!empty($acolour)) {
                     $colour = $acolour;
                 }
                 break;
             case 'bottom':
                 $y = $bar['y'] + (!$swap ? $bar['height'] - $this->bar_label_space : $this->bar_label_font_size + $this->bar_label_space);
                 break;
             case 'centre':
                 $y = $bar['y'] + ($bar['height'] + $font_size) / 2;
                 break;
             case 'top':
             default:
                 $y = $bar['y'] + ($swap ? $bar['height'] - $this->bar_label_space : $this->bar_label_font_size + $this->bar_label_space);
                 break;
         }
     }
     $text = array('x' => $x, 'y' => $y, 'text-anchor' => 'middle', 'font-family' => $this->bar_label_font, 'font-size' => $font_size, 'fill' => $colour);
     if ($this->bar_label_font_weight != 'normal') {
         $text['font-weight'] = $this->bar_label_font_weight;
     }
     return $this->Element('text', $text, NULL, $content);
 }
开发者ID:roarkmccolgan,项目名称:dellconvergedmaturity,代码行数:44,代码来源:SVGGraphBarGraph.php

示例9: FormatTooltip

 /**
  * Default format is value only
  */
 protected function FormatTooltip(&$item, $dataset, $key, $value)
 {
     return $this->units_before_tooltip . Graph::NumString($value) . $this->units_tooltip;
 }
开发者ID:ppKrauss,项目名称:openness-metrics,代码行数:7,代码来源:SVGGraph.php

示例10: SetTooltip

 /**
  * Default tooltip contents are key and value, or whatever
  * $key is if $value is not set
  */
 protected function SetTooltip(&$element, &$item, $key, $value = NULL, $duplicate = FALSE)
 {
     // use structured data tooltips if specified
     if (is_array($this->structure) && isset($this->structure['tooltip'])) {
         $text = $item->Data('tooltip');
         if (is_null($text)) {
             return;
         }
     } else {
         // use a sprintf format for the tooltip
         $format = '%s, %s';
         if (is_null($value)) {
             $value = $key;
             $format = '%2$s';
             // value only
         }
         $k = is_numeric($key) ? $this->units_before_tooltip_key . Graph::NumString($key) . $this->units_tooltip_key : $key;
         $v = is_numeric($value) ? $this->units_before_tooltip . Graph::NumString($value) . $this->units_tooltip : $value;
         $text = sprintf($format, $k, $v);
     }
     $text = addslashes(str_replace("\n", '\\n', $text));
     Graph::$javascript->SetTooltip($element, $text, $duplicate);
 }
开发者ID:roarkmccolgan,项目名称:dellconvergedmaturity,代码行数:27,代码来源:SVGGraph.php

示例11: BarTotal

 /**
  * Bar total label
  * $label_above is the item that is above the bar
  */
 protected function BarTotal($total, &$bar, $label_above)
 {
     $this->Bar($total, $bar);
     $content = $this->units_before_label . Graph::NumString($total) . $this->units_label;
     $font_size = $this->bar_total_font_size;
     $space = $this->bar_total_space;
     $x = $bar['x'] + $bar['width'] / 2;
     $font_size = $this->bar_total_font_size;
     $y = $bar['y'] + ($bar['height'] + $font_size) / 2 - $font_size / 8;
     $anchor = 'end';
     $top = $bar['x'] + $bar['width'] - $this->bar_total_space;
     $bottom = $bar['x'] + $this->bar_total_space;
     $swap = $bar['x'] + $bar['width'] <= $this->pad_left + $this->x_axes[$this->main_x_axis]->Zero();
     $x = $swap ? $bottom - $this->bar_total_space * 2 : $top + $this->bar_total_space * 2;
     $anchor = $swap ? 'end' : 'start';
     $offset = 0;
     // make space for label
     if ($label_above) {
         $lcontent = $label_above->Data('label');
         if (is_null($lcontent)) {
             $lcontent = $this->units_before_label . Graph::NumString($label_above->value) . $this->units_label;
         }
         list($text_size) = $this->TextSize($lcontent, $this->bar_label_font_size, $this->bar_label_font_adjust, $this->encoding);
         $offset = $text_size + $this->bar_label_space;
         if ($swap) {
             $offset = -$offset;
         }
     }
     $text = array('x' => $x + $offset, 'y' => $y, 'text-anchor' => $anchor, 'font-family' => $this->bar_total_font, 'font-size' => $font_size, 'fill' => $this->bar_total_colour);
     if ($this->bar_total_font_weight != 'normal') {
         $text['font-weight'] = $this->bar_total_font_weight;
     }
     return $this->Element('text', $text, NULL, $content);
 }
开发者ID:roarkmccolgan,项目名称:dellconvergedmaturity,代码行数:38,代码来源:SVGGraphHorizontalStackedBarGraph.php

示例12: GetText

 /**
  * Returns the text for a grid point
  */
 protected function GetText($value)
 {
     $text = $value;
     // try structured data first
     if ($this->values && $this->values->GetData($value, 'axis_text', $text)) {
         return $text;
     }
     // use the key if it is not the same as the value
     $key = $this->values ? $this->values->GetKey($value) : $value;
     // if there is a callback, use it
     if (is_callable($this->label_callback)) {
         $text = call_user_func($this->label_callback, $value, $key);
     } else {
         if ($key !== $value) {
             $text = $key;
         } else {
             $text = $this->units_before . Graph::NumString($value, $this->decimal_digits) . $this->units_after;
         }
     }
     return $text;
 }
开发者ID:goat1000,项目名称:svggraph,代码行数:24,代码来源:SVGGraphAxis.php

示例13: BarLabel

 /**
  * Text labels in or above the bar
  */
 protected function BarLabel(&$item, &$bar, $offset_x = null)
 {
     $content = $item->Data('label');
     if (is_null($content)) {
         $content = $this->units_before_label . Graph::NumString($item->value) . $this->units_label;
     }
     $font_size = $this->bar_label_font_size;
     $y = $bar['y'] + ($bar['height'] + $font_size) / 2 - $font_size / 8;
     $colour = $this->bar_label_colour;
     $acolour = $this->bar_label_colour_above;
     $anchor = 'end';
     if (!is_null($offset_x)) {
         $x = $bar['x'] + $bar['width'] - $offset_x;
         $anchor = 'start';
     } else {
         $pos = $this->BarLabelPosition($item, $bar);
         $top = $bar['x'] + $bar['width'] - $this->bar_label_space;
         $bottom = $bar['x'] + $this->bar_label_space;
         $swap = $bar['x'] + $bar['width'] <= $this->pad_left + $this->x_axes[$this->main_x_axis]->Zero();
         switch ($pos) {
             case 'above':
                 $x = $swap ? $bottom - $this->bar_label_space * 2 : $top + $this->bar_label_space * 2;
                 $anchor = $swap ? 'end' : 'start';
                 if (!empty($acolour)) {
                     $colour = $acolour;
                 }
                 break;
             case 'bottom':
                 $x = $swap ? $top : $bottom;
                 $anchor = $swap ? 'end' : 'start';
                 break;
             case 'centre':
                 $x = $bar['x'] + $bar['width'] / 2;
                 $anchor = 'middle';
                 break;
             case 'top':
             default:
                 $x = $swap ? $bottom : $top;
                 $anchor = $swap ? 'start' : 'end';
                 break;
         }
     }
     $text = array('x' => $x, 'y' => $y, 'text-anchor' => $anchor, 'font-family' => $this->bar_label_font, 'font-size' => $font_size, 'fill' => $colour);
     if ($this->bar_label_font_weight != 'normal') {
         $text['font-weight'] = $this->bar_label_font_weight;
     }
     return $this->Element('text', $text, NULL, $content);
 }
开发者ID:roarkmccolgan,项目名称:dellconvergedmaturity,代码行数:51,代码来源:SVGGraphHorizontalBarGraph.php

示例14: GetGridPoints

 /**
  * Returns the grid points as an array of GridPoints
  */
 public function GetGridPoints($min_space, $start)
 {
     $spacing = $this->Grid($min_space);
     $c = $pos = 0;
     $dlength = $this->length + $spacing * 0.5;
     $points = array();
     while ($pos < $dlength) {
         // convert to string to use as array key
         $value = ($pos - $this->zero) / $this->unit_size;
         $text = $this->units_before . Graph::NumString($value) . $this->units_after;
         $position = $start + $this->direction * $pos;
         $points[] = new GridPoint($position, $text, $value);
         $pos = ++$c * $spacing;
     }
     // uneven means the divisions don't fit exactly, so add the last one in
     if ($this->uneven) {
         $pos = $this->length - $this->zero;
         $value = $pos / $this->unit_size;
         $text = $this->units_before . Graph::NumString($value) . $this->units_after;
         $position = $start + $this->direction * $this->length;
         $points[] = new GridPoint($position, $text, $value);
     }
     // using 'GridPoint::sort' silently fails in PHP 5.1.x
     usort($points, $this->direction < 0 ? 'gridpoint_rsort' : 'gridpoint_sort');
     $this->grid_spacing = $spacing;
     return $points;
 }
开发者ID:roarkmccolgan,项目名称:dellconvergedmaturity,代码行数:30,代码来源:SVGGraphAxis.php


注:本文中的Graph::NumString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。