(this sketch doesn't work completely because it cannot load the external cvs file)
Every 4 years a curious coincidence occurs.
I wonder how many Germans will try to vote totally drunk after a whole day at the Oktoberfest...
Uses the grafica.js library:
https://github.com/jagracar/grafica.js
The data was obtained from Google trends
var sketch = function (p) {
// Global variables
var table, plot;
var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var daysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var daysPerMonthLeapYear = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
// Load the table before the sketch is run
p.preload = function () {
// Load the Oktoberfest vs. Bundestagswahl (German elections day) Google
// search history file (obtained from the Google trends page).
// The csv file has the following format:
// year,month,day,oktoberfest,bundestagswahl
// 2004,0,1,5,1
// ...
table = p.loadTable("https://raw.githubusercontent.com/jagracar/grafica.js/master/examples/data/OktoberfestVSGermanElections.csv", "header");
};
// Initial setup
p.setup = function () {
// Create the canvas
var canvas = p.createCanvas(800, 400);
// Save the table data in two GPointsArrays
var pointsOktoberfest = [];
var pointsElections = [];
for (var row = 0; row < table.getRowCount(); row++) {
var data = table.getRow(row);
var year = data.getNum("year");
var month = data.getNum("month");
var day = data.getNum("day");
var date = getExactDate(year, month, day);
var oktoberfestCount = data.getNum("oktoberfest");
var electionsCount = data.getNum("bundestagswahl");
pointsOktoberfest[row] = new GPoint(date, oktoberfestCount, monthNames[month]);
pointsElections[row] = new GPoint(date, electionsCount, monthNames[month]);
}
// Create the plot
plot = new GPlot(p);
plot.setDim(700, 300);
plot.setTitleText("Oktoberfest vs. Bundestagwahl Google search history");
plot.getXAxis().setAxisLabelText("Year");
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.