how to auto update morris graph

I have a php page(index.php) which gets ajax data from a php page(cj.php) to create a area graph. but this graph doesn’t update automatically. Everytime i need to refresh the whole page to see new data in the graph. how to update morris graph data automatically without reloading the whole page.

here is my cj.php code:


 $rows = '';
 $query = "SELECT * FROM device ORDER BY date DESC LIMIT 0, 2000";
 $result = mysqli_query($con,$query);
 $total_rows =  $result->num_rows;
 $rows = mysqli_fetch_all($result, MYSQLI_ASSOC);
echo json_encode($rows);


and this is my index.php code:

 <div class="col-md-12"> <div id="chart"></div>

        url: "ajax/cj.php",
        type: "POST",
        dataType: "json",
        success: function (data) {


       function Graph(data) {

      var chart =  new Morris.Area({
            element: 'chart',
            data: data,
            xkey: 'date',
            ykeys: ['value'],
            labels: ['Bin Level'],
            lineColors: ['#c4b601']