Report not found

There was a problem finding this report.
Playoff Length - Chart 1
April 30, 2014 · Refreshed almost 5 years ago
Description
Full blog post: http://blog.modeanalytics.com/are-the-playoffs-taking-forever/

Collaborators

Run History
SELECT x.season, MAX(CASE WHEN x.league = 'mlb' THEN x.full_length_of_playoffs ELSE NULL END) AS MLB, MAX(CASE WHEN x.league = 'nfl' THEN x.full_length_of_playoffs ELSE NULL END) AS NFL, MAX(CASE WHEN x.league = 'nba' THEN x.full_length_of_playoffs ELSE NULL END) AS NBA, MAX(CASE WHEN x.league = 'nhl' THEN x.full_length_of_playoffs ELSE NULL END) AS NHL FROM ( SELECT z.league, CASE WHEN LENGTH(z.season) = 5 THEN CASE WHEN LEFT(RIGHT(z.season,2),1) IN ('0','1') THEN CONCAT('20',RIGHT(z.season,2))::INT ELSE CONCAT('19',RIGHT(z.season,2))::INT END ELSE z.season::INT END AS season, EXTRACT('DAY' FROM z.pl_full_end - z.pl_full_start) AS full_length_of_playoffs FROM ( SELECT t.league, t.season, MIN(CASE WHEN t.game_type != 'regular_season' THEN t.date ELSE NULL END) AS pl_full_start, MAX(CASE WHEN t.game_type != 'regular_season' THEN t.date ELSE NULL END) AS pl_full_end FROM benn.professional_sports_game_log t WHERE t.date >= '1969-01-01' GROUP BY 1,2 ) z ) x WHERE x.season >= 1970 AND (x.season != 1994 OR x.league != 'mlb') AND (x.season != 1982 OR x.league != 'nfl') AND (x.season != 1995 OR x.league != 'nhl') AND (x.season != 2005 OR x.league != 'nhl') AND (x.season != 2013 OR x.league != 'nhl') AND (x.season != 1999 OR x.league != 'nba') AND (x.season != 2012 OR x.league != 'nba') GROUP BY 1 ORDER BY 1
SELECT x.season, MAX(CASE WHEN x.league = 'mlb' THEN x.full_length_of_playoffs ELSE NULL END) AS MLB, MAX(CASE WHEN x.league = 'nfl' THEN x.full_length_of_playoffs ELSE NULL END) AS NFL, MAX(CASE WHEN x.league = 'nba' THEN x.full_length_of_playoffs ELSE NULL END) AS NBA, MAX(CASE WHEN x.league = 'nhl' THEN x.full_length_of_playoffs ELSE NULL END) AS NHL FROM ( SELECT z.league, CASE WHEN LENGTH(z.season) = 5 THEN CASE WHEN LEFT(RIGHT(z.season,2),1) IN ('0','1') THEN CONCAT('20',RIGHT(z.season,2))::INT ELSE CONCAT('19',RIGHT(z.season,2))::INT END ELSE z.season::INT END AS season, EXTRACT('DAY' FROM z.pl_full_end - z.pl_full_start) AS full_length_of_playoffs FROM ( SELECT t.league, t.season, MIN(CASE WHEN t.game_type != 'regular_season' THEN t.date ELSE NULL END) AS pl_full_start, MAX(CASE WHEN t.game_type != 'regular_season' THEN t.date ELSE NULL END) AS pl_full_end FROM benn.professional_sports_game_log t WHERE t.date >= '1969-01-01' GROUP BY 1,2 ) z ) x WHERE x.season >= 1970 AND (x.season != 1994 OR x.league != 'mlb') AND (x.season != 1982 OR x.league != 'nfl') AND (x.season != 1995 OR x.league != 'nhl') AND (x.season != 2005 OR x.league != 'nhl') AND (x.season != 2013 OR x.league != 'nhl') AND (x.season != 1999 OR x.league != 'nba') AND (x.season != 2012 OR x.league != 'nba') GROUP BY 1 ORDER BY 1
<style> body { font-family: Helvetica, Arial, sans-serif; font-size: 12px; text-align:center; } .axis path { display: none; } .axis line { shape-rendering: crispEdges; stroke: #000; } .axis .minor line { stroke: #e2e2e2; } .line { fill: none; stroke-width: 3px; } </style> <body> <div id="graph"> <h2>Playoff Length in Days</h2> </div> <script> var margin = {top: 30, right: 40, bottom: 30, left: 40}, width = 800 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; var x = d3.scale.linear() .range([0, width]); var y = d3.scale.linear() .range([height, 0]); var color = d3.scale.category10(); var xAxis = d3.svg.axis() .scale(x) .orient("bottom") .tickFormat(d3.format("d")); var yAxis = d3.svg.axis() .scale(y) .tickFormat(formatY) .tickSize(width) .orient("right"); var line = d3.svg.line() .defined(function(d) { return d.lenVal != 0; }) .x(function(d) { return x(d.season); }) .y(function(d) { return y(d.lenVal); }); var svg = d3.select("#graph").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); function formatY(d) { if (d === y.domain()[1]) { return d + " wins"; } else if (d === y.domain()[0]) { return ""; } else { return d;} } data = dataset.content color.domain(d3.keys(data[0]).filter(function(key) { return key !== "season"; })); var leagues = color.domain().map(function(name) { return { name: name, values: data.map(function(d) { return {season: d.season, lenVal: +d[name]}; }) }; }); x.domain(d3.extent(data, function(d) { return d.season; })); y.domain([ 0,d3.max(leagues, function(c) { return d3.max(c.values, function(v) { return v.lenVal; }); }) ]); svg.append("g") .attr("class", "x axis") .attr("transform", "translate(0," + height + ")") .call(xAxis); gy = svg.append("g") .attr("class", "y axis") .call(yAxis); gy.selectAll("text") .attr("x", -20) .attr("dy", 5); gy.selectAll("g").filter(function(d) { return d; }) .classed("minor", true); var league = svg.selectAll(".league") .data(leagues) .enter().append("g") .attr("class", "league"); league.append("path") .attr("class", "line") .attr("d", function(d) { return line(d.values); }) .style("stroke", function(d) { return color(d.name); }); var legend = svg.selectAll(".legend") .data(leagues) .enter().append("g") .attr("class", "legend") legend.append("rect") .attr("x",function(d,i) { return ((width+margin.left)/2 - 130) + (i *65); }) .attr("y",-20) .attr("width",18) .attr("height", 18) .style("fill", function(d) { return color(d.name); }); legend.append("text") .attr("x",function(d,i) { return ((width+margin.left)/2 - 130) + 24 + (i *65); }) .attr("y", -12) .attr("dy", ".35em") .text(function(d) { return d.name.toUpperCase(); }); </script>
{{ dataSourceName(params.queryId) }}

The dataset is too large to view in browser

Export

Looks like something went wrong with your query.

{{ DS.queryRuns[params.queryId].errorMessage }}
This query was cancelled