Creation of flowcharts/diagrams with php/mysql/js

2.3k views Asked by At

im building a site and i need to build a flowchart/diagram with data that i will get from a mysql database, so, i get the data and i want to put it in a flowchart.

Something like this http://philogb.github.io/jit/static/v20/Jit/Examples/Spacetree/example2.html

but i want the "values" to be tables, with 4 coluns and 2 rows;

like this, where the values will gotten from my mysql database.

something like this

    google.setOnLoadCallback(drawChart);

    function drawChart() {
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Name');
    data.addColumn('string', 'Manager');
    data.addColumn('string', 'ToolTip');

    data.addRows([
    [{v:'OMT', f:'<table border="1" style="width:100%"><tr><td rowspan="2">OMT</td><td>02:05:13</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>50</td><td>52</td><td>54</td></tr></table>'}, '', ''],
    [{v:'OMTC', f:'<table border="1" style="width:100%"><tr><td rowspan="2">OMTC</td><td>00:35:12</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>20</td><td>22</td><td>24</td></tr></table>'}, 'OMT', 'OMTC'],
    [{v:'OMTJ', f:'<table border="1" style="width:100%"><tr><td rowspan="2">OMTJ</td><td>00:00:00</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>00</td><td>00</td><td>00</td></tr></table>'}, 'OMT', 'OMTJ'],
    [{v:'OMTR', f:'<table border="1" style="width:100%"><tr><td rowspan="2">OMTR</td><td>01:05:00</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>22</td><td>24</td><td>26</td></tr></table>'}, 'OMT', 'OMTR'],
    [{v:'OMTS', f:'<table border="1" style="width:100%"><tr><td rowspan="2">OMTS</td><td>00:25:01</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>04</td><td>06</td><td>08</td></tr></table>'}, 'OMT', 'OMTS'],
    [{v: 'NMTF6-01' ,f:'<table border="1" style="width:100%"><tr><td rowspan="2">NMTF6-01</td><td>00:35:00</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>06</td><td>08</td><td>10</td></tr></table>'}, 'OMTR', ''],
    [{v: 'BPCL6-03' ,f:'<table border="1" style="width:100%"><tr><td rowspan="2">BPCL6-03</td><td>00:22:00</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>02</td><td>04</td><td>06</td></tr></table>'}, 'OMTR', ''],
    [{v: 'BPCL6-02' ,f:'<table border="1" style="width:100%"><tr><td rowspan="2">BPCL6-02</td><td>00:08:00</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>10</td><td>12</td><td>14</td></tr></table>'}, 'OMTR', ''],
    [{v: 'CXAT6-04' ,f:'<table border="1" style="width:100%"><tr><td rowspan="2">CXAT6-04</td><td>00:10:00</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>04</td><td>06</td><td>08</td></tr></table>'}, 'OMTC', ''],
    [{v: 'CXAT6-03' ,f:'<table border="1" style="width:100%"><tr><td rowspan="2">CXAT6-03</td><td>00:13:02</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>12</td><td>14</td><td>16</td></tr></table>'}, 'OMTC', ''],
    [{v: 'CXAT6-02' ,f:'<table border="1" style="width:100%"><tr><td rowspan="2">CXAT6-02</td><td>00:12:10</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>00</td><td>02</td><td>04</td></tr></table>'}, 'OMTC', ''],
    [{v: 'SPAT6-02' ,f:'<table border="1" style="width:100%"><tr><td rowspan="2">SPAT6-02</td><td>00:25:01</td><td>00:25:00</td><td>00:25:00</td></tr><tr><td>04</td><td>06</td><td>08</td></tr></table>'}, 'OMTS', ''],           

    ]);

     var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
     chart.draw(data, {allowHtml:true});
     }

http://jsfiddle.net/a4tzhtos/16/ but i wanted to be dynamic like the first example, and i want the chart growing for the side because will be a pretty large chart.

im using php, mysql and javascript.

1

There are 1 answers

0
Sebastian On

In a commercial scenario, you might want to take a look at yFiles for HTML. It's a Javascript/HTML5 diagramming library that can do what you are looking for:

As far as I understand your requirements, a combination of these two demos should be pretty much exactly what you are looking for:

The data table node style demo shows how to create a data table visualization and the collapsible tree demo shows the requested animated expand/collapse feature. In this demo the data is all kept in memory, but it can also be fetched dynamically from the server as required. The GWT demo that is also part of the package shows this specific aspect, e.g.

Disclaimer: I work for the company that creates the above mentioned library. I do not represent my employer on SO, though. My posts and comments are my own.