Oktoberfest example

(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

by Javier Graciá Carpio

HTML

<script src="https://cdn.rawgit.com/jagracar/grafica.js/master/releases/grafica.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.0.0/p5.min.js"></script>

JavaScript

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");
       ...