Nisanth
Nisanth

Reputation: 333

How to make a Dynamic Line Graph in PHP - Mysql

I want to make a dynamic line graph in php with mysql data. Please verify my Attached Image enter image description here

How to get this type of graph ?

Upvotes: 0

Views: 1104

Answers (1)

crazyglasses
crazyglasses

Reputation: 540

Use this tutorial to plot graphs using Google visualisation.

https://developers.google.com/chart/interactive/docs/php_example

If you want to make it dynamic, you have to use AJAX to call a function in PHP which updates the graph every x seconds. To do that, update the function the following way

setInterval(function(){
$.ajax({url: "getData.php",
      dataType: "json",
      async: false


    }, dataType: "json"});
}, 1000);

This will repeat the call every 1 second. As the setIntervals second parameter is in Milliseconds.

Upvotes: 0

Related Questions