i'm starting learn d3 , seems powerful framework. i'm trying load following html simple python webserver. can see .json file loaded, don't see json getting printed in console log of chrome browser.
<!doctype html> <html> <head> <meta charset="utf-8"/> <title>d3 tests</title> <script type="text/javascript" src="resources/d3.v3/d3.v3.js"></script> </head> <body> <script type="text/javascript"> var dataset; console.log("before json"); d3.json("pie-chart-data.json",function(error,data){ if (error) return console.warn(error); dataset = data; console.log("dataset is: "+dataset); }); console.log("after json"); </script> </body> </html> and here's json file- pie-chart-data.json
[ {key: "one",y: 5}, {key: "two",y: 2}, {key: "three",y: 9}, {key: "four",y: 7}, {key: "five",y: 4}, {key: "six",y: 3}, {key: "seven",y: .5} ] i see "before json" , "after json" getting printed console, don't see "dataset is" log. going wrong - please help.
thanks, k.
the json file malformed, must have double quotes around keys, , numbers must begin digit or minus sign (not point).
[ {"key": "one", "y": 5}, {"key": "two", "y": 2}, {"key": "three", "y": 9}, {"key": "four", "y": 7}, {"key": "five", "y": 4}, {"key": "six", "y": 3}, {"key": "seven", "y": 0.5} ] the complete json specification , syntax can found in json.org.
Comments
Post a Comment