d3.csv('z_passing-stats-2014.csv', function(error, raw) { function readLabels(d, i) { return d.name + ', ' + d.school + ', ' + d.conference; } var dataset = []; var color = new ColorMap(); raw.forEach(function(v, i) { dataset.push({ x: Number(v['Passing Attempts']), y: Number(v['Passing Yards']), name: v['Player'], school: v['School'], conference: v['Conf'] }); }); d3.select('body') .append('h1') .text('JDR VI8 for CS725@ODU'); d3.select('body') .append('h4') .text(intro); // ------------------------------------------------------------------------- d3.select('body') .append('p') .text(problem0); var plot0 = new Scatterplot(dataset); plot0.draw(); raw.forEach(function(v, i) { dataset[i].color = color.byConference(v['Conf']); }); plot0.recolor(); plot0.makeHoverLabels(readLabels); d3.select('body') .append('p') .text(explanation0); d3.select('body') .append('hr'); // ------------------------------------------------------------------------- d3.select('body') .append('p') .text(problem1); var plot1 = new Scatterplot(dataset); plot1.draw(); raw.forEach(function(v, i) { dataset[i].color = color.byConferenceBlindSafe(v['Conf']); }); plot1.recolor(); plot1.makeHoverLabels(readLabels); d3.select('body') .append('p') .text(explanation1); d3.select('body') .append('hr'); // ------------------------------------------------------------------------- d3.select('body') .append('p') .text(problem2); var plot2 = new Scatterplot(dataset); plot2.draw(); raw.forEach(function(v, i) { dataset[i].color = color.byConferencePhotocopySafe(v['Conf']); }); plot2.recolor(); plot2.makeHoverLabels(readLabels); d3.select('body') .append('p') .text(explanation2); d3.select('body') .append('hr'); // ------------------------------------------------------------------------- d3.select('body') .append('p') .text(problem3); var fiveDataset = []; raw.forEach(function(v, i) { if (color.inBigFive(v['Conf'])) { fiveDataset.push(dataset[i]); } }); var plot3 = new Scatterplot(fiveDataset); plot3.draw(); fiveDataset.forEach(function(v, i) { v.color = color.byBigFive(v.conference); }); plot3.recolor(); plot3.makeHoverLabels(readLabels); d3.select('body') .append('p') .text(explanation3); d3.select('body') .append('p') .text(extraQuestion); d3.select('body') .append('p') .text(extraAnswer); d3.select('body') .append('hr'); // ------------------------------------------------------------------------- d3.select('body') .append('p') .text(problem4); var topFive = []; for (var i = 0; i < 5 && i < raw.length; ++i) { topFive.push(dataset[i]); } var plot4 = new Scatterplot(topFive); plot4.draw(); topFive.forEach(function(v, i) { v.color = color.fiveByMultiHue(i); }); plot4.recolor(); plot4.makeHoverLabels(readLabels); d3.select('body') .append('p') .text(explanation4); d3.select('body') .append('hr'); // ------------------------------------------------------------------------- d3.select('body') .append('p') .text(problem5); var plot5 = new Scatterplot(topFive); plot5.draw(); topFive.forEach(function(v, i) { v.color = color.fiveBySingleHue(i); }); plot5.recolor(); plot5.makeHoverLabels(readLabels); d3.select('body') .append('p') .text(explanation5); // ------------------------------------------------------------------------- plot0.drawAxisLabels('Passing Yards', 'Passing Attempts'); plot1.drawAxisLabels('Passing Yards', 'Passing Attempts'); plot2.drawAxisLabels('Passing Yards', 'Passing Attempts'); plot3.drawAxisLabels('Passing Yards', 'Passing Attempts'); plot4.drawAxisLabels('Passing Yards', 'Passing Attempts'); plot5.drawAxisLabels('Passing Yards', 'Passing Attempts'); // ------------------------------------------------------------------------- var mw = 25; var mh = 25; var mp = 10; plot0.drawLegend(color.getConferenceColors(), mw, mh, mp); plot1.drawLegend(color.getConferenceBlindSafeColors(), mw, mh, mp); plot2.drawLegend(color.getConferencePhotocopySafeColors(), mw, mh, mp); plot3.drawLegend(color.getBigFiveColors(), mw, mh, mp); plot4.drawLegend(color.getMultiHueColors(), mw, mh, mp); plot5.drawLegend(color.getSingleHueColors(), mw, mh, mp); });