1

I am currently learning the basics of D3, and am currently attempting to load a csv file to my console. My problem is that whenever I attempt to load the data, based on online tutorials when I run d3.csv() I should end up with an array, filled with the objects in my csv file.

However, when I inspect the console after running my code, I only see that it has logged each object individually, instead of as an array.

Currently, my html doc looks like this:

<html lang="en">
    <head>
        < meta charset="utf-8">
        < title>D3 Page Template</title>
        < script type="text/javascript" src="../d3.js"></script>
    </head>
    <body>
        <script type="text/javascript">
            d3.select("body").append("p").text("It's a paragraph!");
    </script>
    <script> d3.csv("/data/food.csv", function(data) {
            console.log(data);
        });
    </script>
    </body>
</html>

I have read and watched through numerous tutorials as to how to load this data to the console, though I cannot see what I am not implementing correctly. Intuitively, I expect that once the data is logged to the console, I should be able to call it by simply typing data into the console, or input data[1] to get the first element for example.

Can anyone please help me to understand what I have done incorrectly, and how to log the data correctly? Any insights or guidance are greatly appreciated!

0 Answers0