Gantt chart with MySQL

Share RGraph:   To help my Google visibility (it can't get much worse!), if you like and use RGraph I'd appreciate it if you could link to me

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Rob on 2nd June 2014
Hi,

I like the RGRAPH library, but experimenting with the GANNT.
Are ther examples to use a mysql database ?
I would like to generate a per line overview with activities with different colours.

             var data = [
                         // First row

                         [
                          [5, 2, null, 'Day 1', 'green'],
                          [7, 1, null, 'Day 1', 'purple'],
                          [8, 2, null, 'Day 1', 'green'],
                          [10, .25, null, 'Day 1', 'yellow'],
                          [11, .5, null, 'Day 1', 'purple'],
                          [16, .5, null, 'Day 1', 'green']
                         ],
Posted by Richard on 3rd June 2014
The only example of MySQL is in the implementation guide:

www.rgraph.net/docs/integration-with-server-side-scripting.html

Keep in mind that you PHP runs first, on your server, and then whatever the output is is sent to the browser - where JavaScript runs. So you could do something like this:

<?php
     $str = array();
     foreach($data as $row) {
               $str[] = sprintf('[%d, %d, null, '%s', '%s']',$row['start'],$row['duration'],$row['complete'],$row['label']);
     }

     $str = implode('.', $str);
?>
  var data = [
              // Rows
              <?php echo $str ?>
              ];

Something like that. I haven't tested it so there might be a small error or two but that show the principle.



Richard

Add a reply




« Back to message list