I’m doing some form of data visualization learning for 180 days because I need to #JFDI.

See post explaining how and why I’m doing this.

**Chapter 4 General Charting Principles**

Three Takeways Today

// Callback function breakdowns

var n = 0 // counter to increment

for (x in data[0])

if (x != day) { //not drawing a line for day value of each object because this is giving x value of coordinate

var movieArea = d3.svg.area() // generator that iterates through each objet that corresponds to one of our movies using day vlaue for x coorindate but iterating through values for each movie for the y coordinates

.x(function(d) {

return xScale(d.day)

})

.y(function(d) {

return yScale(d,x))

})

.y0(function(d) {

return yScale(simpleStacking(d,x) – d[x])

})

}

// Stacking function. Takes incoming bound data and name of attr and loops throuhg the incoming data, adding each value until it reaches current named attribute. As a result, it returns the total value for every movie during this day up to the movie we’ve sent.

function simpleStacking(incomingData, incomingAttribute) {

var newHeight = 0

for (x in incomingData) {

if (x != “day”) {

newHeight += parseInt(incomingData[x]);

if (x == incomingAttribute) {

break;

}

}

}

return newHeight;

};

// Stacking function that alternates vertical position of area drawn p 136