4

I am new to ZingChart.I am following this tutorial here http://www.zingchart.com/docs/features/feeds/#feeds__js

I wrote a html file ZingFeed.html

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<script>

var chartData={"refresh":{
    "type":"feed",
    "transport":"js",
    "url":"feed()",
    "interval":200
};


window.onload=function(){
    zingchart.render({
        id:"chartDiv",
        data:chartData,
        height:600,
        width:"100%"
    });
};

window.feed = function(callback) {
    var tick = {};
    tick.plot0 = parseInt(10+900*Math.random(), 10);
    callback(JSON.stringify(tick));
};

</script>
<div id='chartDiv'></div>
</body>
</html>

Nothing gets rendered on the screen. Your help will be highly beneficial and highly valued.

Nikita Shah
  • 301
  • 2
  • 9

1 Answers1

4

First: are you loading the ZingChart library? I'm only asking since it's not included in your demo. If not, paste this in the <head> of our file:

<script src='http://cdn.zingchart.com/zingchart.min.js'></script>

Your chartData object is also missing a type.

There's also a missing closing bracket in your chartData object.

Here's a working example. I work on the ZingChart team. Let me know if I can help with something else.

<!DOCTYPE html>
<html>

<head>
    <meta charset="ISO-8859-1">
    <title>Insert title here</title>
    <script src='http://cdn.zingchart.com/zingchart.min.js'></script>
</head>

<body>
    <script>
    var chartData = {
        "type":"line",
        "refresh": {
            "type": "feed",
            "transport": "js",
            "url": "feed()",
            "interval": 200
        },
        "series":[
            {
                "values":[]
            }
        ]
    };


    window.onload = function() {
        zingchart.render({
            id: "chartDiv",
            data: chartData,
            height: 600,
            width: "100%"
        });
    };

    window.feed = function(callback) {
        var tick = {};
        tick.plot0 = parseInt(10 + 900 * Math.random(), 10);
        callback(JSON.stringify(tick));
    };
    </script>
    <div id='chartDiv'></div>
</body>

</html>
Patrick RoDee
  • 1,106
  • 6
  • 9
  • Thank you :) I am looking forward to creating a live chart .Data could come from rest api.Could you direct me where i should be looking for. http://www.zingchart.com/demos/real-time-data-feed-chart/ I read this up, woulsd like to know more on how exactly to use ZingCharts. Thanks in advance :) – Nikita Shah Apr 24 '15 at 08:32
  • http://stackoverflow.com/questions/29894115/zing-feed-get-data-from-rest-api could you please take a look at this new doubt that i am facing Thaks in advance. – Nikita Shah Apr 27 '15 at 11:11