learn d3.js I like this one. Creating histogram with raw data from the Csv file,
CSV
x, y 2,16 3,18 5,18 12,19 < / Pre> D3
d3 Csv ("data.csv", function) {var map = data.map (function (i) {return parasif float (iy);}) var histogram = d3 layout. Ostogram () .bins (4) (Map) ... etc. This was my initial call and it works.
Putting the same data in a valid Jason format like this , "X": ["2", "3", "5", "<" , "12"]}]
Calling data does not work,
d3.json ("data.json", function ( Jason) {var map = data.map (function (I) Returns parasif float (iy);}) histogram = d3 layout. Ostogram () .bins (4) (map) How can I d3? Js is the native .json file interpreted as a CSV format in the same way that I have to change which code is low. Is it possible? Documentation I Ead really confused me and to work with my example Do not think the best tutorial on YouTube .csv and no json's Yoga. I need to use json.
Try this data for your Jason file:
["X "": "2", "y": "16"}, {"x": "3", "y": "18"}, {"x": "5", "y": parsefloat (Iy) (bus) can get rid of (only) "18"}, {"x": "12", "y": "19"}] return < Code> iy ) If you specify your data in a number instead of a string. CSV values are forced in strings, while JSON numbers can be obtained.
Edit: Change the following line to: d3.json ("data.json", function ( error , < Strong> data ) {. Note the parameter name. Your code should work later.
No comments:
Post a Comment