예제 #1
0
 /**
  * Output a graph as SVG.
  * @param stack_abstract_graph $g the graph to display.
  * @param string $id an id to add to the SVG node in the HTML.
  */
 public static function render(stack_abstract_graph $g, $id)
 {
     $renderer = new self($g);
     list($minx, $maxx) = $g->x_range();
     $width = ceil((2 + $maxx - $minx) * self::SCALE / 2);
     $height = ceil((0.3 + $g->max_depth()) * self::SCALE);
     $output = '';
     $output .= html_writer::start_tag('svg', array('id' => $id, 'class' => 'stack_abstract_graph', 'width' => $width . 'px', 'height' => $height . 'px', 'version' => '1.1', 'xmlns' => 'http://www.w3.org/2000/svg'));
     $output .= $renderer->to_svg();
     $output .= html_writer::end_tag('svg');
     return $output;
 }