You probably use a framework or standalone library to the load data into your apps, and if that's overkill for your needs ? What if you ' re just putting together a quick demo? This lesson demonstrates D3 's APIs for loading data on it own, as well as some helpful methods for inspecting your data a nd preparing it for use with D3.
function LoadData () {D3.json ('Data/data.json', function (data) {varextent =d3.extent (data, function (d) {returnd.age}); //get the value rangeConsole.log ("#Extent", extent); varMin =d3.min (data, function (d) {returnd.age}); Console.log ("#Min", Min); varMax =D3.max (data, function (d) {returnd.age}); Console.log ("#Max", Max); varAges = D3.Set(data, function (d) {returnd.age}); //get unique value out of dataConsole.log ("#Ages", Ages.values ()); varScale =d3.scalelinear (). Domain (extent). Range ([0, -]); Console.log (Scale ( at)) })}
[D3] Load and Inspect Data with D3 v4