Home forums Using CanvasJS json file

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by  Vishwas R 2 weeks, 1 day ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #20608

    natasha11
    Member

    I wanted to make a dropdown list, when a user clicks on the drop down, it will show the charts.

    This is my website. http://fkiattendance.xyz/staff_report.php

    But the charts doesnt come out. it shows in the json_encode.

    staff_report.php
    <script type=”text/javascript”>
    window.onload = function () {
    var chart = new CanvasJS.Chart(“chartContainer”,{
    title:{
    text:”Attendance”
    },
    data: [{
    type: “column”,
    dataPoints : [],
    }]
    });

    $.getJSON(“report.php?type=”+TME2073, function(data) {
    $.each((data), function(key, value){
    chart.options.data[0].dataPoints.push({label: new Date(value[0]), y: parseInt(value[1])});

    });
    chart.render();
    updateChart();
    });

    function updateChart() {
    $.getJSON(“report.php?type=”+TME2073, function(data) {
    chart.options.data[0].dataPoints = [];
    chart.options.data[1].dataPoints = [];
    $.each((data), function(key, value){
    chart.options.data[0].dataPoints.push({label: new Date(value[0]), y: parseInt(value[1])});

    });

    chart.render();
    });
    }

    setInterval(function(){updateChart()}, 1000);
    }
    </script>

    #20614

    Vishwas R
    Keymaster

    @natasha11,

    It seems like dataPoints are not being updated properly.
    Chart from JSON

    Can you kindly share the sample project with sample JSON over google-drive or onedrive so that we can understand it better and help you out?


    Vishwas R
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.