PHP Classes
elePHPant
Icontem

Diagram 2: Draw an hierarchic diagram from a XML definition

Recommend this page to a friend!
  Info   Screenshots Screenshots   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum (9)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2005-03-21 (11 years ago) RSS 2.0 feedStarStarStarStar 72%Total: 3,170 All time: 1,094 This week: 614Up
Version License Categories
diagram2 1.0.0GNU General Publi...XML, Graphics
Description Author

This package can draw diagrams of hierarchy trees defined in XML files.

The diagram class is a follow-up of another class released here before. Instead of arrays, now it uses XML to define the diagram.

It also implements more features supporting: borders, text colors, fonts, text alignments, backgrounds, paddings, margins, text over the node connections and the thickness of the connections.

The tree XML files define the structure of nodes of the tree as well the graphical attributes that define details of how the diagram should be rendered.

Picture of Diogo Resende
Name: Diogo Resende <contact>
Classes: 10 packages by
Country: Portugal Portugal
Innovation award
Innovation award
Nominee: 4x

Winner: 2x

Details
    Hi,

    This class is so simple I don't think you'll need documentation. The
class draws a diagram with only one root node. You can define properties
for every node on the diagram.
    After instanciating the class you can pass the diagram structure in
2 diferent ways: xml file or xml data. If you pass the xml file it will
then call the xml data function so if you're just opening the xml file
and passing it to the function.. don't bother, just use the xml file
feature.
    The function names are very simple:

        - loadXmlFile()

        With this function you can pass a file path as an argument. It will
        open the file and send the data to loadXmlData() to be parsed.

        - loadXmlData()

        With this function you can pass xml directly to the xml parser of
        the function.

        - Draw()

        After using one of the above function you should call this one
        to draw the diagram. The optional argument can be a path to
        where the image should be saved. If no argument is set, the image
        will be sent to stdout with the apropriate header.

    Now that you know all you need to build a diagram, you might be
wondering how the xml file is. Well, it's simple. The basic structure
is like this:


<?xml version="1.0" encoding="UTF-8"?>
<diagram>
    <node name="this is the name">
        this is the data inside the node
    </node>
</diagram>


    To load this file you would do:

<?php
    include 'class.diagram.php';

    $diagram = new Diagram(realpath('myfirstdiagram.xml'));
    $diagram->Draw();
?>

    This would work if you save the previous xml in myfirstdiagram.xml
and both the file and the class are in the same directory as this php
file. Confused? Hope not.
    You have 2 examples. One simple and another a bit more complex with
two-color backgrounds and text over lines. Hope you like it.
    To view them simply view test1.html and test2.html (on your server,
not offline because it calls test.php).
    Any doubt, e-mail me at: me (at) diogoresende (dot) net

    Diogo Resende
Screenshots  
  • test.png
  Files folder image Files  
File Role Description
Plain text file class.diagram-ext.php Class Class extension
Accessible without login Plain text file class.diagram.php Class Main class
Plain text file class.xmlparser.php Class Small auxiliary class to parse xml
Plain text file readme.txt Doc. Read it first if you're not sure what you're doing
Plain text file test.php Example This will load one of the two examples
HTML file test1.html Data Example 1
Plain text file test1.xml Data Test1 diagram in xml format
HTML file test2.html Data Example 2
Plain text file test2.php Example This will load the class with an array
Plain text file test2.xml Data Test2 diagram in xml format
Plain text file test4.php Example Test class extension

 Version Control Unique User Downloads Download Rankings  
 0%
Total:3,170
This week:0
All time:1,094
This week:614Up
User Ratings User Comments (2)
 All time
Utility:95%StarStarStarStarStar
Consistency:90%StarStarStarStarStar
Documentation:75%StarStarStarStar
Examples:88%StarStarStarStarStar
Tests:-
Videos:-
Overall:72%StarStarStarStar
Rank:189
 
Excellent
7 years ago (kishore kumar)
80%StarStarStarStarStar
good exam.
8 years ago (Nguyen Duy Hai)
75%StarStarStarStar