Jump to content

Extension talk:GraphViz/From Meta-Wiki

From mediawiki.org
The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).

Graphviz

Please compare Extension:GraphViz with Extension:Graphviz (lowercase 'v'). -- Tim Chambers 1E4AF729D5CEFFD0

<graphviz> tags

I have installed GraphViz on a Debain server using apt.

I seem to have most/all of the executables installed and have put Graphviz.php in the extensions directory. Unfortunately it seems that MediaWiki is not interpreting the <graphviz> tags.

Is there a 'preferred' way to test the extension(s)?


I trust you also added

include("extensions/Graphviz.php");
$wgGraphVizSettings->dotCommand = "$DOT_PATH/dot";

to your LocalSettings.php. After that you can test if it works with the code:

<graphviz>
digraph G{
  A -> B
}
</graphviz>

If you see a graph with a blob A connected with an arrow to a blob B then it works.


Some of my experiences:

  1. The current sources of Graphviz.php are in Wicle's CVS.
  2. When compiling the Graphviz from the sources I needed the --with-mylibgd to get dot generate .png files.
  3. The graphs seen in IslandSeeds look better because that engine runs on Mac (see [1]} and its follow-up.

--Coriolan 05:37, 14 Jun 2005 (UTC)


Hi,

  • i have installed this extension on MW 1.13.0 and Ubuntu Hardy
  • i have added the path to dot /usr/bin/dot
  • i have included the php to LocalSettings

but, nothing works, <graphviz>...</graphviz> seems to be unreaded. Nothing inside is shown.

  • pngs are created, but damaged
  • the *.map files are empty <map id="G" name="G"> </map>

If I am using MW 1.7.3 I do have the same problem

btw. GraphViz Category Browser is not running, too The Special Page is there, but empty

GraphViz (/usr/bin/dot) is running without trouble

--ViktorD


Windows

If we only want to directly use the GIF file, please modified as following

      ...
      str_replace("\\",'/',
      substr($timelinesrc, 0, strpos($timelinesrc,'{') ))));
      }
      $ext = ".gif";
      $src = $dest . $storagename;
      $imgn = $dest . $storagename . $ext;
      $mapn = $dest . $storagename . '.map';
      if ( $wgGraphVizSettings->named == 'named' || ! ( file_exists( $src.".gif" ) || file_exists(    $src.".err" ) ) )
      {
      $handle = fopen($src, "w");
      fwrite($handle, $timelinesrc);
      fclose($handle);
      $cmdline    = wfEscapeShellArg($wgGraphVizSettings->dotCommand). ' -Tgif   -o '.wfEscapeShellArg($imgn).' '.wfEscapeShellArg($src);
      $cmdlinemap = wfEscapeShellArg($wgGraphVizSettings->dotCommand). ' -Tcmapx -o '.wfEscapeShellArg($mapn).' '.wfEscapeShellArg($src);
      $WshShell = new COM("WScript.Shell");
      $WshShell->Exec($cmdline);
      $WshShell->Exec($cmdlinemap);
      }
      ...	
      $map  = str_replace('</map>','',$map);
      $txt  = '<map name="'.$storagename.'">'.$map.'</map>'.'<img src="'.$wgUploadPath.'/graphviz/'.$storagename.'.gif"'.' usemap="#'.$storagename.'" />';
      }
      unlink($src);
      return $txt;
      }

-- By Bennix, Fudan University, 2008



You must enable internet users to have read/execute access to cmd.exe before trying to use the Graphviz extension. Matt 16:44, 30 April 2008 (UTC)Reply

What's the point in this?

       if (substr(php_uname(), 0, 7) == "Windows") {
           $ext = "gif";
       } else {
           $ext = "png";
       }

.png is used everywhere else in the file, so this actually makes it break! I removed it and changed the $txt line to always use .png.

Also I found it necessary to use

       $ret = `"{$cmdline}"`;

instead of

       $ret = `{$cmdline}`;

because the default windows install directory for Graphviz is "c:\Program Files\Graphviz..." which contains a space. Without the quotes, windows assumes everything following the space is a parameter, which generates only a "'c:\Program' is not recognized as an internal or external command, operable program or batch file." error.


Thanks for the extension, it looks like it could be very useful once I get the hang of it!

--ProgMania 23:20, 3 September 2005 (UTC)Reply

COM("WScript.Shell") instead of shell_exec()

Using using the improved version found below on this page, I had problem getting this to work on a Windows Server 2003 machine with Apache 2.2 and PHP 5.2.6. The shell_exec() command refused to execute the dot program for some reason. Replacing the two shell_exec() calls with this code works for me.

       $WshShell = new COM("WScript.Shell");
       $WshShell->Exec($cmdline);
       $WshShell->Exec($cmdlinemap);

--Oskar, 2008-05-19

I found all the instructions above do not work on my Windows installation. However, the instructions found here worked the first time: http://www.wickle.com/wiki/index.php/Windows_Graphviz_Installation_Instructions. (Segraves, 2009-02-26)

safe_mode and antialiased rendering

please use popen() instead of shell_exec(), so that php safe_mode can work. not all of us want to run our servers as loose as a mexican whore.

i've also modified this plugin to use GraphicsMagick to render antialiased graphs from dot's svg output, it works very nice indeed. --207.109.251.117 11:26, 6 November 2005 (UTC)Reply

Can you please provide the modified plugin? --202.1.193.10 17:45, 13 January 2006 (UTC)Reply

Some Help Getting Graphviz to Work

I have an unusual set up as in I have a Uniform Server's WAMP ( Windows Apache MySQL PHP ) running from a Thumbdrive.
Mediawiki ver 1.5.
Graphviz.php extension installed
The Graphviz is installed in the psedo drive W:\usr\local\ATT\Graphviz

  • The dot.exe is therefore W:\usr\local\ATT\Graphviz\bin

While adding in <graphviz></graphviz> elements does have a Dos Prompt window pop-up momentarily, the resulting graph was never generated.

Has anyone encountered this problem? And found a solution?
Suggestions?

Directories and rights

My experiences from an install under FreeBSD 7.1:

  • Installed GraphViz from ports
    • (cd /usr/ports/graphics/graphviz/; make install clean)
  • Path for dot is: /usr/local/bin/dot, use that in LoacalSettings.php
  • create dir for images: .../wikiurl/images/graphviz/
    • replace ".../wikiurl/" with the full path for your wiki installation
  • chown www .../wikiurl/images/graphviz/
  • a cron entry to cleanup .../wikiurl/images/graphviz/ is a good idea
    • delete all png/gif/maps etc older than 7 days:
    • find .../wikiurl/images/graphviz/ -mtime +7 -type file -delete

--Schatchaos 20:20, 24 January 2009 (UTC)Reply


Deletion of unused images

Hi is it possible to delete all the unused pngs ? i got only 20 images with graphviz, but the creationprocess produced over 400 files...(testing and stuff :) ) Is it possible to delete those ? They mess up my box :-/