Home forums Using CanvasJS CODE not working in Notepad++

This topic contains 4 replies, has 2 voices, and was last updated by  Vishwas R 3 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #22114

    Hemel619619
    Member

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

    window.onload = function () {

    var dps1 = [], dps2 = [], dps3 = [];
    var chart = new CanvasJS.Chart(“chartContainer”,{
    title:{
    text: “TIME SLOT vs. MOVEMENT CATEGORY”
    },
    axisX:{
    title: “TIME SLOT”
    },
    axisY:{
    title: “Percentage of movement category”
    },
    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(chart) {

    $.when($.getJSON(“https://api.myjson.com/bins/ozzmq”, 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
    });

    }
    })).done(function(){
    chart.render();
    });
    }

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

    });

    </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 really wanna know why this code is not running in notepad++? Is there any problem in this code?

    #22115

    Vishwas R
    Keymaster

    @hemel619619,

    You need to include jQuery in your page to use jQuery methods like getJSON, when and done. Including jQuery should work fine in your case.

    Please try adding <script src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script> in your html page.


    Vishwas R
    Team CanvasJS

    #22116

    Hemel619619
    Member

    Thanks vishmas R for trying to help but I am afraid it’s not working still after adding “<script src=”https://canvasjs.com/assets/script/jquery-1.11.1.min.js”></script>”

    Any other way I can try?

    #22117

    Hemel619619
    Member

    I solved the problem. Problem was in mismatched brackets!
    THANK YOU

    #22125

    Vishwas R
    Keymaster

    @hemel619619,

    Glad that its working fine :)


    Vishwas R
    Team CanvasJS

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

You must be logged in to reply to this topic.