From the course: D3.js Essential Training

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Solution: Line chart from scratch scales and generators

Solution: Line chart from scratch scales and generators - D3.js Tutorial

From the course: D3.js Essential Training

Solution: Line chart from scratch scales and generators

(upbeat music) - [Instructor] So how did you get on? As a reminder, the challenge was quite extensive this time. It was to take this flatData.csv, import it using a CSV handler add a scale for x, scale for y, use a line generator, so you'd be adding the x and the y axis and the line generator from CSV data. And that's what we're going to do now. So we say load that file and then do something with the data. And old habits die hard. I always log it first. So there we go. We've successfully imported the file. Let's have a look at the data. So we have a Date value, which is not a JavaScript date object yet. We have a Value, which is a string, and then we have a Month name. So we need to process our data. That's the first thing to do. So we can say data.forEach(). And we can say d.Date = new Date(d.Date), okay? Remember to use capitals. It's very annoying, but it does mimic real world data, which is not always as you wish it would be. So let's clear that and refresh and see what we've got.…

Contents