Home forums Using CanvasJS Problem in coding

This topic contains 2 replies, has 2 voices, and was last updated by  Hemel619619 1 month, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #22031

    Hemel619619
    Member

    <!DOCTYPE HTML>
    <html>
    <head>
    <script>

    window.onload = function () {

    var dps1 = [], dps2 = [], dps3 = [];
    var chart = new CanvasJS.Chart(“chartContainer”,{
    title:{
    text: “Y Values based on Frequency of Date”
    },
    axisX:{
    title: “Date”
    },
    axisY:{
    title: “Frequecy of dates”
    },
    data: [
    {
    type: “stackedArea100”,
    name: “STANDSTILL”,
    showInLegend: “true”,
    yValueFormatString: “#,##0.##\”%\””,
    dataPoints: dps1
    },
    {
    type: “stackedArea100”,
    name: “ON FOOT”,
    showInLegend: “true”,
    yValueFormatString: “#,##0.##\”%\””,
    dataPoints: dps2
    },
    {
    type: “stackedArea100”,
    name: “ON VEHICLE”,
    showInLegend: “true”,
    yValueFormatString: “#,##0.##\”%\””,
    dataPoints: dps3
    }
    ]
    });

    getData();
    chart.render();

    function getData() {
    $.getJSON(“https://api.myjson.com/bins/a98dm”, function(data) {

    for(var i = 0; i < data.length; i++){
    dps1.push({
    label: data[i].label,
    y: data[i].y1
    });
    dps2.push({
    label: data[i].label,
    y: data[i].y2
    });
    dps3.push({
    label: data[i].label,
    y: data[i].y3
    });
    }
    });

    setInterval(function(){
    getData();
    chart.render();
    }, 20000);

    </script>
    </head>
    <body>
    <div id=”chartContainer” style=”height: 600px; width: 100%;”></div>
    <script src=”https://canvasjs.com/assets/script/canvasjs.min.js”></script>
    </body>
    </html>

    I don’t know why this coding is not working! Please let me know where is the problem???

    #22037

    Priyanka M S
    Member

    @hemel619619,

    Please take a look at this updated jsfiddle.

    __
    Priyanka M S
    Team CanvasJS

    #22041

    Hemel619619
    Member

    THANK YOU. IT WORKED.

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

You must be logged in to reply to this topic.