n = document.getElementById("aggregation").value;

        Plotly.d3.csv("chartdata.php?agg=" + aggregation, function (err, rows) {

            function unpack(rows, key) {
                return rows.map(function (row) {
                    return row[key];
                });
            }

            var trace1 = {
                type: "scatter",
                name: "m3",
                x: unpack(rows, "ts"),
                y: unpack(rows, "m3"),
                line: { color: "#3399ff" }
        