2

第一步

准备环境,在linux 下准备lnmp 环境

第二步

下载GraphViz.php, 下载地址:

http://pear.php.net/package/Image_GraphViz/download

第一个demo

 require_once 'Image/GraphViz.php';
 $gv = new Image_GraphViz();
 $gv->addEdge(array('wake up'        => 'visit bathroom'));
 $gv->addEdge(array('visit bathroom' => 'make coffee'));
 $gv->image();

请输入图片描述

第二个demo

<?php

require_once 'Image/GraphViz.php';

  $graph = new Image_GraphViz();

  $graph->addNode(
    'Node1',
    array(
      'URL'   => 'http://link1',
      'label' => 'This is a label',
      'shape' => 'box'
    )
  );

  $graph->addNode(
    'Node2',
    array(
      'URL'      => 'http://link2',
      'fontsize' => '14'
    )
  );

  $graph->addNode(
    'Node3',
    array(
      'URL'      => 'http://link3',
      'fontsize' => '20'
    )
  );

  $graph->addEdge(
    array(
      'Node1' => 'Node2'
    ),
    array(
      'label' => 'Edge Label'
    )
  );

  $graph->addEdge(
     array(
       'Node1' => 'Node2'
     ),
     array(
      'color' => 'red'
   )
  );
  $graph->image();

请输入图片描述


小渝人儿
1.1k 声望849 粉丝

前端工程师


引用和评论

0 条评论