2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2020-07-28 01:04:01 +02:00
|
|
|
const Plotly = require("plotly.js/lib/core");
|
|
|
|
|
|
|
|
Plotly.register([require("plotly.js/lib/bar"), require("plotly.js/lib/pie")]);
|
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const font_14pt = {
|
2020-07-15 01:29:15 +02:00
|
|
|
family: "Source Sans Pro",
|
2017-02-08 02:24:31 +01:00
|
|
|
size: 14,
|
2020-07-15 01:29:15 +02:00
|
|
|
color: "#000000",
|
2017-02-08 02:24:31 +01:00
|
|
|
};
|
2017-06-30 21:37:59 +02:00
|
|
|
|
2019-12-06 09:35:13 +01:00
|
|
|
let last_full_update = Infinity;
|
2017-02-08 02:24:31 +01:00
|
|
|
|
2017-01-11 21:44:59 +01:00
|
|
|
// TODO: should take a dict of arrays and do it for all keys
|
|
|
|
function partial_sums(array) {
|
2019-11-02 00:06:25 +01:00
|
|
|
let accumulator = 0;
|
2020-07-02 01:45:54 +02:00
|
|
|
return array.map((o) => {
|
2017-06-30 21:37:59 +02:00
|
|
|
accumulator += o;
|
|
|
|
return accumulator;
|
|
|
|
});
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes date is a round number of hours
|
|
|
|
function floor_to_local_day(date) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const date_copy = new Date(date.getTime());
|
2017-01-11 21:44:59 +01:00
|
|
|
date_copy.setHours(0);
|
|
|
|
return date_copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assumes date is a round number of hours
|
|
|
|
function floor_to_local_week(date) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const date_copy = floor_to_local_day(date);
|
2017-01-11 21:44:59 +01:00
|
|
|
date_copy.setHours(-24 * date.getDay());
|
|
|
|
return date_copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
function format_date(date, include_hour) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const months = [
|
2020-07-15 01:29:15 +02:00
|
|
|
i18n.t("January"),
|
|
|
|
i18n.t("February"),
|
|
|
|
i18n.t("March"),
|
|
|
|
i18n.t("April"),
|
|
|
|
i18n.t("May"),
|
|
|
|
i18n.t("June"),
|
|
|
|
i18n.t("July"),
|
|
|
|
i18n.t("August"),
|
|
|
|
i18n.t("September"),
|
|
|
|
i18n.t("October"),
|
|
|
|
i18n.t("November"),
|
|
|
|
i18n.t("December"),
|
2018-05-07 01:38:14 +02:00
|
|
|
];
|
2019-11-02 00:06:25 +01:00
|
|
|
const month_str = months[date.getMonth()];
|
|
|
|
const year = date.getFullYear();
|
|
|
|
const day = date.getDate();
|
2017-01-11 21:44:59 +01:00
|
|
|
if (include_hour) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const hour = date.getHours();
|
2017-06-30 21:37:59 +02:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const str = hour >= 12 ? "PM" : "AM";
|
2017-06-30 21:37:59 +02:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
return month_str + " " + day + ", " + (hour % 12) + ":00" + str;
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
2020-07-15 01:29:15 +02:00
|
|
|
return month_str + " " + day + ", " + year;
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
|
|
|
|
2017-03-07 05:50:26 +01:00
|
|
|
function update_last_full_update(end_times) {
|
|
|
|
if (end_times.length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
last_full_update = Math.min(last_full_update, end_times[end_times.length - 1]);
|
2019-11-02 00:06:25 +01:00
|
|
|
const update_time = new Date(last_full_update * 1000);
|
2020-07-15 00:34:28 +02:00
|
|
|
const locale_date = update_time.toLocaleDateString("en-US", {
|
|
|
|
year: "numeric",
|
|
|
|
month: "long",
|
|
|
|
day: "numeric",
|
|
|
|
});
|
2019-11-02 00:06:25 +01:00
|
|
|
const locale_time = update_time.toLocaleTimeString().replace(":00 ", " ");
|
2017-03-07 05:50:26 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#id_last_full_update").text(locale_time + " on " + locale_date);
|
|
|
|
$("#id_last_full_update").closest(".last-update").show();
|
2017-03-07 05:50:26 +01:00
|
|
|
}
|
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
$(() => {
|
2017-03-07 05:50:26 +01:00
|
|
|
$('span[data-toggle="tooltip"]').tooltip({
|
|
|
|
animation: false,
|
2020-07-15 01:29:15 +02:00
|
|
|
placement: "top",
|
|
|
|
trigger: "manual",
|
2017-03-07 05:50:26 +01:00
|
|
|
});
|
2020-07-20 21:55:26 +02:00
|
|
|
$("#id_last_update_question_sign")
|
|
|
|
.on("mouseenter", () => {
|
|
|
|
$("span.last_update_tooltip").tooltip("show");
|
|
|
|
})
|
|
|
|
.on("mouseleave", () => {
|
|
|
|
$("span.last_update_tooltip").tooltip("hide");
|
|
|
|
});
|
2018-01-03 20:48:56 +01:00
|
|
|
// Add configuration for any additional tooltips here.
|
2017-03-07 05:50:26 +01:00
|
|
|
});
|
|
|
|
|
2017-02-06 09:32:07 +01:00
|
|
|
function populate_messages_sent_over_time(data) {
|
|
|
|
if (data.end_times.length === 0) {
|
|
|
|
// TODO: do something nicer here
|
|
|
|
return;
|
|
|
|
}
|
2016-12-20 02:30:08 +01:00
|
|
|
|
2017-02-06 09:32:07 +01:00
|
|
|
// Helper functions
|
|
|
|
function make_traces(dates, values, type, date_formatter) {
|
2020-07-02 01:45:54 +02:00
|
|
|
const text = dates.map((date) => date_formatter(date));
|
2020-07-20 22:18:43 +02:00
|
|
|
const common = {x: dates, type, hoverinfo: "none", text};
|
2017-02-06 09:32:07 +01:00
|
|
|
return {
|
2020-07-15 00:34:28 +02:00
|
|
|
human: {
|
|
|
|
// 5062a0
|
|
|
|
name: i18n.t("Humans"),
|
|
|
|
y: values.human,
|
|
|
|
marker: {color: "#5f6ea0"},
|
2020-02-09 04:06:28 +01:00
|
|
|
...common,
|
|
|
|
},
|
2020-07-15 00:34:28 +02:00
|
|
|
bot: {
|
|
|
|
// a09b5f bbb56e
|
|
|
|
name: i18n.t("Bots"),
|
|
|
|
y: values.bot,
|
|
|
|
marker: {color: "#b7b867"},
|
2020-02-09 04:06:28 +01:00
|
|
|
...common,
|
|
|
|
},
|
|
|
|
me: {
|
2020-07-15 00:34:28 +02:00
|
|
|
name: i18n.t("Me"),
|
|
|
|
y: values.me,
|
|
|
|
marker: {color: "#be6d68"},
|
2020-02-09 04:06:28 +01:00
|
|
|
...common,
|
|
|
|
},
|
2017-02-06 09:32:07 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const layout = {
|
2020-07-15 01:29:15 +02:00
|
|
|
barmode: "group",
|
2017-01-11 21:44:59 +01:00
|
|
|
width: 750,
|
|
|
|
height: 400,
|
2020-07-16 22:40:18 +02:00
|
|
|
margin: {l: 40, r: 0, b: 40, t: 0},
|
2016-12-20 02:30:08 +01:00
|
|
|
xaxis: {
|
2017-01-11 21:44:59 +01:00
|
|
|
fixedrange: true,
|
2020-07-16 22:40:18 +02:00
|
|
|
rangeslider: {bordercolor: "#D8D8D8", borderwidth: 1},
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "date",
|
2016-12-20 02:30:08 +01:00
|
|
|
},
|
2020-07-16 22:40:18 +02:00
|
|
|
yaxis: {fixedrange: true, rangemode: "tozero"},
|
2017-01-11 21:44:59 +01:00
|
|
|
legend: {
|
2020-07-15 00:34:28 +02:00
|
|
|
x: 0.62,
|
|
|
|
y: 1.12,
|
|
|
|
orientation: "h",
|
|
|
|
font: font_14pt,
|
2017-01-11 21:44:59 +01:00
|
|
|
},
|
2017-02-08 02:24:31 +01:00
|
|
|
font: font_14pt,
|
2017-01-11 21:44:59 +01:00
|
|
|
};
|
|
|
|
|
2017-02-06 09:32:07 +01:00
|
|
|
function make_rangeselector(x, y, button1, button2) {
|
2020-07-15 00:34:28 +02:00
|
|
|
return {
|
2020-07-20 22:18:43 +02:00
|
|
|
x,
|
|
|
|
y,
|
2020-07-15 00:34:28 +02:00
|
|
|
buttons: [
|
|
|
|
{stepmode: "backward", ...button1},
|
|
|
|
{stepmode: "backward", ...button2},
|
2020-08-10 20:29:51 +02:00
|
|
|
{step: "all", label: i18n.t("All time")},
|
2020-07-15 00:34:28 +02:00
|
|
|
],
|
|
|
|
};
|
2017-02-06 09:32:07 +01:00
|
|
|
}
|
2017-09-17 00:57:41 +02:00
|
|
|
|
2017-02-06 09:32:07 +01:00
|
|
|
// This is also the cumulative rangeselector
|
2019-11-02 00:06:25 +01:00
|
|
|
const daily_rangeselector = make_rangeselector(
|
2020-07-15 00:34:28 +02:00
|
|
|
0.68,
|
|
|
|
-0.62,
|
2020-07-15 01:29:15 +02:00
|
|
|
{count: 10, label: i18n.t("Last 10 days"), step: "day"},
|
2020-07-15 00:34:28 +02:00
|
|
|
{count: 30, label: i18n.t("Last 30 days"), step: "day"},
|
|
|
|
);
|
2019-11-02 00:06:25 +01:00
|
|
|
const weekly_rangeselector = make_rangeselector(
|
2020-07-15 00:34:28 +02:00
|
|
|
0.656,
|
|
|
|
-0.62,
|
2020-07-15 01:29:15 +02:00
|
|
|
{count: 2, label: i18n.t("Last 2 months"), step: "month"},
|
2020-07-15 00:34:28 +02:00
|
|
|
{count: 6, label: i18n.t("Last 6 months"), step: "month"},
|
|
|
|
);
|
2017-02-02 01:07:41 +01:00
|
|
|
|
2017-02-06 09:32:07 +01:00
|
|
|
function add_hover_handler() {
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById("id_messages_sent_over_time").on("plotly_hover", (data) => {
|
2017-06-30 21:37:59 +02:00
|
|
|
$("#hoverinfo").show();
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById("hover_date").innerText =
|
2017-02-06 09:32:07 +01:00
|
|
|
data.points[0].data.text[data.points[0].pointNumber];
|
2019-11-02 00:06:25 +01:00
|
|
|
const values = [null, null, null];
|
2020-07-02 01:45:54 +02:00
|
|
|
data.points.forEach((trace) => {
|
2017-02-06 09:32:07 +01:00
|
|
|
values[trace.curveNumber] = trace.y;
|
|
|
|
});
|
2020-07-15 01:29:15 +02:00
|
|
|
const hover_text_ids = ["hover_me", "hover_human", "hover_bot"];
|
|
|
|
const hover_value_ids = ["hover_me_value", "hover_human_value", "hover_bot_value"];
|
2019-11-02 00:06:25 +01:00
|
|
|
for (let i = 0; i < values.length; i += 1) {
|
2017-03-21 04:19:52 +01:00
|
|
|
if (values[i] !== null) {
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById(hover_text_ids[i]).style.display = "inline";
|
|
|
|
document.getElementById(hover_value_ids[i]).style.display = "inline";
|
2017-03-21 04:19:52 +01:00
|
|
|
document.getElementById(hover_value_ids[i]).innerText = values[i];
|
|
|
|
} else {
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById(hover_text_ids[i]).style.display = "none";
|
|
|
|
document.getElementById(hover_value_ids[i]).style.display = "none";
|
2017-03-21 04:19:52 +01:00
|
|
|
}
|
2017-02-06 09:32:07 +01:00
|
|
|
}
|
|
|
|
});
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const start_dates = data.end_times.map(
|
|
|
|
(timestamp) =>
|
|
|
|
// data.end_times are the ends of hour long intervals.
|
|
|
|
new Date(timestamp * 1000 - 60 * 60 * 1000),
|
2020-07-02 01:45:54 +02:00
|
|
|
);
|
2017-01-11 21:44:59 +01:00
|
|
|
|
|
|
|
function aggregate_data(aggregation) {
|
2019-11-02 00:06:25 +01:00
|
|
|
let start;
|
|
|
|
let is_boundary;
|
2020-07-15 01:29:15 +02:00
|
|
|
if (aggregation === "day") {
|
2017-01-11 21:44:59 +01:00
|
|
|
start = floor_to_local_day(start_dates[0]);
|
|
|
|
is_boundary = function (date) {
|
|
|
|
return date.getHours() === 0;
|
|
|
|
};
|
2020-07-15 01:29:15 +02:00
|
|
|
} else if (aggregation === "week") {
|
2017-01-11 21:44:59 +01:00
|
|
|
start = floor_to_local_week(start_dates[0]);
|
|
|
|
is_boundary = function (date) {
|
|
|
|
return date.getHours() === 0 && date.getDay() === 0;
|
|
|
|
};
|
|
|
|
}
|
2019-11-02 00:06:25 +01:00
|
|
|
const dates = [start];
|
|
|
|
const values = {human: [], bot: [], me: []};
|
|
|
|
let current = {human: 0, bot: 0, me: 0};
|
|
|
|
let i_init = 0;
|
2017-01-11 21:44:59 +01:00
|
|
|
if (is_boundary(start_dates[0])) {
|
2020-07-15 00:34:28 +02:00
|
|
|
current = {
|
|
|
|
human: data.everyone.human[0],
|
|
|
|
bot: data.everyone.bot[0],
|
|
|
|
me: data.user.human[0],
|
|
|
|
};
|
2017-01-11 21:44:59 +01:00
|
|
|
i_init = 1;
|
|
|
|
}
|
2019-11-02 00:06:25 +01:00
|
|
|
for (let i = i_init; i < start_dates.length; i += 1) {
|
2017-01-11 21:44:59 +01:00
|
|
|
if (is_boundary(start_dates[i])) {
|
|
|
|
dates.push(start_dates[i]);
|
|
|
|
values.human.push(current.human);
|
|
|
|
values.bot.push(current.bot);
|
2017-03-21 04:19:52 +01:00
|
|
|
values.me.push(current.me);
|
|
|
|
current = {human: 0, bot: 0, me: 0};
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
2018-05-18 22:13:08 +02:00
|
|
|
current.human += data.everyone.human[i];
|
|
|
|
current.bot += data.everyone.bot[i];
|
2017-03-21 04:19:52 +01:00
|
|
|
current.me += data.user.human[i];
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
|
|
|
values.human.push(current.human);
|
|
|
|
values.bot.push(current.bot);
|
2017-03-21 04:19:52 +01:00
|
|
|
values.me.push(current.me);
|
2017-02-06 09:32:07 +01:00
|
|
|
return {
|
2020-07-20 22:18:43 +02:00
|
|
|
dates,
|
|
|
|
values,
|
2020-07-15 00:34:28 +02:00
|
|
|
last_value_is_partial: !is_boundary(
|
|
|
|
new Date(start_dates[start_dates.length - 1].getTime() + 60 * 60 * 1000),
|
|
|
|
),
|
|
|
|
};
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Generate traces
|
2019-11-02 00:06:25 +01:00
|
|
|
let date_formatter = function (date) {
|
2017-01-11 21:44:59 +01:00
|
|
|
return format_date(date, true);
|
|
|
|
};
|
2019-11-02 00:06:25 +01:00
|
|
|
let values = {me: data.user.human, human: data.everyone.human, bot: data.everyone.bot};
|
2017-01-11 21:44:59 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
let info = aggregate_data("day");
|
2017-01-11 21:44:59 +01:00
|
|
|
date_formatter = function (date) {
|
|
|
|
return format_date(date, false);
|
|
|
|
};
|
2019-11-02 00:06:25 +01:00
|
|
|
const last_day_is_partial = info.last_value_is_partial;
|
2020-07-15 01:29:15 +02:00
|
|
|
const daily_traces = make_traces(info.dates, info.values, "bar", date_formatter);
|
2017-01-11 21:44:59 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
info = aggregate_data("week");
|
2017-01-11 21:44:59 +01:00
|
|
|
date_formatter = function (date) {
|
2017-09-05 09:00:32 +02:00
|
|
|
return i18n.t("Week of __date__", {date: format_date(date, false)});
|
2017-01-11 21:44:59 +01:00
|
|
|
};
|
2019-11-02 00:06:25 +01:00
|
|
|
const last_week_is_partial = info.last_value_is_partial;
|
2020-07-15 01:29:15 +02:00
|
|
|
const weekly_traces = make_traces(info.dates, info.values, "bar", date_formatter);
|
2017-01-11 21:44:59 +01:00
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
const dates = data.end_times.map((timestamp) => new Date(timestamp * 1000));
|
2020-07-15 00:34:28 +02:00
|
|
|
values = {
|
|
|
|
human: partial_sums(data.everyone.human),
|
|
|
|
bot: partial_sums(data.everyone.bot),
|
|
|
|
me: partial_sums(data.user.human),
|
|
|
|
};
|
2017-01-11 21:44:59 +01:00
|
|
|
date_formatter = function (date) {
|
|
|
|
return format_date(date, true);
|
|
|
|
};
|
2020-07-15 01:29:15 +02:00
|
|
|
const cumulative_traces = make_traces(dates, values, "scatter", date_formatter);
|
2017-01-11 21:44:59 +01:00
|
|
|
|
2017-02-06 09:32:07 +01:00
|
|
|
// Functions to draw and interact with the plot
|
2017-01-11 21:44:59 +01:00
|
|
|
|
2017-02-06 09:32:07 +01:00
|
|
|
// We need to redraw plot entirely if switching from (the cumulative) line
|
|
|
|
// graph to any bar graph, since otherwise the rangeselector shows both (plotly bug)
|
2019-11-02 00:06:25 +01:00
|
|
|
let clicked_cumulative = false;
|
2017-01-11 21:44:59 +01:00
|
|
|
|
2017-02-06 09:32:07 +01:00
|
|
|
function draw_or_update_plot(rangeselector, traces, last_value_is_partial, initial_draw) {
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#daily_button, #weekly_button, #cumulative_button").removeClass("selected");
|
|
|
|
$("#id_messages_sent_over_time > div").removeClass("spinner");
|
2017-02-08 04:40:54 +01:00
|
|
|
if (initial_draw) {
|
|
|
|
traces.human.visible = true;
|
2020-07-15 01:29:15 +02:00
|
|
|
traces.bot.visible = "legendonly";
|
|
|
|
traces.me.visible = "legendonly";
|
2017-02-08 04:40:54 +01:00
|
|
|
} else {
|
2020-07-15 01:29:15 +02:00
|
|
|
const plotDiv = document.getElementById("id_messages_sent_over_time");
|
2017-03-21 04:19:52 +01:00
|
|
|
traces.me.visible = plotDiv.data[0].visible;
|
|
|
|
traces.human.visible = plotDiv.data[1].visible;
|
|
|
|
traces.bot.visible = plotDiv.data[2].visible;
|
2017-02-08 04:40:54 +01:00
|
|
|
}
|
2017-01-11 21:44:59 +01:00
|
|
|
layout.xaxis.rangeselector = rangeselector;
|
2017-02-06 09:32:07 +01:00
|
|
|
if (clicked_cumulative || initial_draw) {
|
2020-07-15 00:34:28 +02:00
|
|
|
Plotly.newPlot(
|
|
|
|
"id_messages_sent_over_time",
|
|
|
|
[traces.me, traces.human, traces.bot],
|
|
|
|
layout,
|
|
|
|
{displayModeBar: false},
|
|
|
|
);
|
2017-02-06 09:32:07 +01:00
|
|
|
add_hover_handler();
|
2017-01-11 21:44:59 +01:00
|
|
|
} else {
|
2020-07-15 01:29:15 +02:00
|
|
|
Plotly.deleteTraces("id_messages_sent_over_time", [0, 1, 2]);
|
|
|
|
Plotly.addTraces("id_messages_sent_over_time", [traces.me, traces.human, traces.bot]);
|
|
|
|
Plotly.relayout("id_messages_sent_over_time", layout);
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#id_messages_sent_over_time").attr("last_value_is_partial", last_value_is_partial);
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
|
|
|
|
2017-02-06 09:32:07 +01:00
|
|
|
// Click handlers for aggregation buttons
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#daily_button").on("click", function () {
|
2017-02-06 09:32:07 +01:00
|
|
|
draw_or_update_plot(daily_rangeselector, daily_traces, last_day_is_partial, false);
|
2017-06-30 21:37:59 +02:00
|
|
|
$(this).addClass("selected");
|
2017-01-11 21:44:59 +01:00
|
|
|
clicked_cumulative = false;
|
|
|
|
});
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#weekly_button").on("click", function () {
|
2017-02-06 09:32:07 +01:00
|
|
|
draw_or_update_plot(weekly_rangeselector, weekly_traces, last_week_is_partial, false);
|
2017-06-30 21:37:59 +02:00
|
|
|
$(this).addClass("selected");
|
2017-01-11 21:44:59 +01:00
|
|
|
clicked_cumulative = false;
|
|
|
|
});
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#cumulative_button").on("click", function () {
|
2017-01-11 21:44:59 +01:00
|
|
|
clicked_cumulative = false;
|
2017-02-06 09:32:07 +01:00
|
|
|
draw_or_update_plot(daily_rangeselector, cumulative_traces, false, false);
|
2017-06-30 21:37:59 +02:00
|
|
|
$(this).addClass("selected");
|
2017-01-11 21:44:59 +01:00
|
|
|
clicked_cumulative = true;
|
|
|
|
});
|
2017-02-02 01:07:41 +01:00
|
|
|
|
2017-02-06 09:32:07 +01:00
|
|
|
// Initial drawing of plot
|
|
|
|
if (weekly_traces.human.x.length < 12) {
|
|
|
|
draw_or_update_plot(daily_rangeselector, daily_traces, last_day_is_partial, true);
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#daily_button").addClass("selected");
|
2017-02-06 09:32:07 +01:00
|
|
|
} else {
|
|
|
|
draw_or_update_plot(weekly_rangeselector, weekly_traces, last_week_is_partial, true);
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#weekly_button").addClass("selected");
|
2017-02-06 09:32:07 +01:00
|
|
|
}
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
|
|
|
|
2017-02-07 23:30:34 +01:00
|
|
|
function round_to_percentages(values, total) {
|
2020-07-02 01:45:54 +02:00
|
|
|
return values.map((x) => {
|
2017-02-08 06:00:04 +01:00
|
|
|
if (x === total) {
|
2020-07-15 01:29:15 +02:00
|
|
|
return "100%";
|
2017-02-08 06:00:04 +01:00
|
|
|
}
|
2017-02-09 09:03:25 +01:00
|
|
|
if (x === 0) {
|
2020-07-15 01:29:15 +02:00
|
|
|
return "0%";
|
2017-02-09 09:03:25 +01:00
|
|
|
}
|
2020-07-15 00:34:28 +02:00
|
|
|
const unrounded = (x / total) * 100;
|
2017-06-30 21:37:59 +02:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const precision = Math.min(
|
2017-06-30 21:37:59 +02:00
|
|
|
6, // this is the max precision (two #, 4 decimal points; 99.9999%).
|
|
|
|
Math.max(
|
|
|
|
2, // the minimum amount of precision (40% or 6.0%).
|
2020-07-02 02:16:03 +02:00
|
|
|
Math.floor(-Math.log10(100 - unrounded)) + 3,
|
|
|
|
),
|
2017-06-30 21:37:59 +02:00
|
|
|
);
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
return unrounded.toPrecision(precision) + "%";
|
2017-02-07 23:30:34 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-02-10 00:39:42 +01:00
|
|
|
// Last label will turn into "Other" if time_series data has a label not in labels
|
|
|
|
function compute_summary_chart_data(time_series_data, num_steps, labels_) {
|
2020-02-12 07:46:27 +01:00
|
|
|
const data = new Map();
|
2020-05-27 00:50:02 +02:00
|
|
|
for (const [key, array] of Object.entries(time_series_data)) {
|
|
|
|
if (array.length < num_steps) {
|
|
|
|
num_steps = array.length;
|
2017-02-03 03:16:19 +01:00
|
|
|
}
|
2019-11-02 00:06:25 +01:00
|
|
|
let sum = 0;
|
|
|
|
for (let i = 1; i <= num_steps; i += 1) {
|
2020-05-27 00:50:02 +02:00
|
|
|
sum += array[array.length - i];
|
2017-02-03 03:16:19 +01:00
|
|
|
}
|
2020-02-12 07:46:27 +01:00
|
|
|
data.set(key, sum);
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
2019-11-02 00:06:25 +01:00
|
|
|
const labels = labels_.slice();
|
|
|
|
const values = [];
|
2020-07-02 01:45:54 +02:00
|
|
|
labels.forEach((label) => {
|
2020-02-12 07:46:27 +01:00
|
|
|
if (data.has(label)) {
|
|
|
|
values.push(data.get(label));
|
|
|
|
data.delete(label);
|
2017-02-10 00:39:42 +01:00
|
|
|
} else {
|
|
|
|
values.push(0);
|
2017-02-03 03:16:19 +01:00
|
|
|
}
|
2017-02-10 00:39:42 +01:00
|
|
|
});
|
2020-02-12 07:46:27 +01:00
|
|
|
if (data.size !== 0) {
|
2018-06-04 21:13:07 +02:00
|
|
|
labels[labels.length - 1] = "Other";
|
2020-03-03 00:24:25 +01:00
|
|
|
for (const sum of data.values()) {
|
2020-02-12 07:46:27 +01:00
|
|
|
values[labels.length - 1] += sum;
|
2017-02-02 10:20:53 +01:00
|
|
|
}
|
|
|
|
}
|
2020-07-02 01:45:54 +02:00
|
|
|
const total = values.reduce((a, b) => a + b, 0);
|
2017-02-07 23:30:34 +01:00
|
|
|
return {
|
2020-07-20 22:18:43 +02:00
|
|
|
values,
|
|
|
|
labels,
|
2017-02-09 09:03:25 +01:00
|
|
|
percentages: round_to_percentages(values, total),
|
2020-07-20 22:18:43 +02:00
|
|
|
total,
|
2017-02-07 23:30:34 +01:00
|
|
|
};
|
2017-01-11 21:44:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function populate_messages_sent_by_client(data) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const layout = {
|
2017-02-09 09:03:25 +01:00
|
|
|
width: 750,
|
|
|
|
height: null, // set in draw_plot()
|
2020-07-16 22:40:18 +02:00
|
|
|
margin: {l: 3, r: 40, b: 40, t: 0},
|
2017-02-08 02:24:31 +01:00
|
|
|
font: font_14pt,
|
2020-07-16 22:40:18 +02:00
|
|
|
xaxis: {range: null}, // set in draw_plot()
|
|
|
|
yaxis: {showticklabels: false},
|
2017-02-09 09:03:25 +01:00
|
|
|
showlegend: false,
|
2017-02-07 23:30:34 +01:00
|
|
|
};
|
|
|
|
|
2017-02-10 00:39:42 +01:00
|
|
|
// sort labels so that values are descending in the default view
|
2019-11-02 00:06:25 +01:00
|
|
|
const everyone_month = compute_summary_chart_data(
|
2020-07-15 00:34:28 +02:00
|
|
|
data.everyone,
|
|
|
|
30,
|
|
|
|
data.display_order.slice(0, 12),
|
|
|
|
);
|
2019-11-02 00:06:25 +01:00
|
|
|
const label_values = [];
|
|
|
|
for (let i = 0; i < everyone_month.values.length; i += 1) {
|
2017-02-10 00:39:42 +01:00
|
|
|
label_values.push({
|
2018-05-18 22:13:08 +02:00
|
|
|
label: everyone_month.labels[i],
|
|
|
|
value: everyone_month.labels[i] === "Other" ? -1 : everyone_month.values[i],
|
2017-02-10 00:39:42 +01:00
|
|
|
});
|
|
|
|
}
|
2020-07-02 01:45:54 +02:00
|
|
|
label_values.sort((a, b) => b.value - a.value);
|
2019-11-02 00:06:25 +01:00
|
|
|
const labels = [];
|
2020-07-15 00:34:28 +02:00
|
|
|
label_values.forEach((item) => {
|
|
|
|
labels.push(item.label);
|
|
|
|
});
|
2017-02-10 00:39:42 +01:00
|
|
|
|
2017-02-09 03:38:30 +01:00
|
|
|
function make_plot_data(time_series_data, num_steps) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const plot_data = compute_summary_chart_data(time_series_data, num_steps, labels);
|
2017-02-09 09:03:25 +01:00
|
|
|
plot_data.values.reverse();
|
|
|
|
plot_data.labels.reverse();
|
|
|
|
plot_data.percentages.reverse();
|
2019-11-02 00:06:25 +01:00
|
|
|
const annotations = {values: [], labels: [], text: []};
|
|
|
|
for (let i = 0; i < plot_data.values.length; i += 1) {
|
2017-02-10 00:39:42 +01:00
|
|
|
if (plot_data.values[i] > 0) {
|
|
|
|
annotations.values.push(plot_data.values[i]);
|
|
|
|
annotations.labels.push(plot_data.labels[i]);
|
2020-07-15 00:34:28 +02:00
|
|
|
annotations.text.push(
|
|
|
|
" " + plot_data.labels[i] + " (" + plot_data.percentages[i] + ")",
|
|
|
|
);
|
2017-02-10 00:39:42 +01:00
|
|
|
}
|
2017-02-09 09:03:25 +01:00
|
|
|
}
|
2017-02-09 03:38:30 +01:00
|
|
|
return {
|
|
|
|
trace: {
|
2017-02-09 09:03:25 +01:00
|
|
|
x: plot_data.values,
|
|
|
|
y: plot_data.labels,
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "bar",
|
|
|
|
orientation: "h",
|
2017-02-09 03:38:30 +01:00
|
|
|
sort: false,
|
|
|
|
textinfo: "text",
|
2017-02-09 09:03:25 +01:00
|
|
|
hoverinfo: "none",
|
2020-07-16 22:40:18 +02:00
|
|
|
marker: {color: "#537c5e"},
|
|
|
|
font: {family: "Source Sans Pro", size: 18, color: "#000000"},
|
2017-02-09 09:03:25 +01:00
|
|
|
},
|
|
|
|
trace_annotations: {
|
2017-02-10 00:39:42 +01:00
|
|
|
x: annotations.values,
|
|
|
|
y: annotations.labels,
|
2020-07-15 01:29:15 +02:00
|
|
|
mode: "text",
|
|
|
|
type: "scatter",
|
|
|
|
textposition: "middle right",
|
2017-02-10 00:39:42 +01:00
|
|
|
text: annotations.text,
|
2017-02-09 03:38:30 +01:00
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const plot_data = {
|
2018-05-18 22:13:08 +02:00
|
|
|
everyone: {
|
|
|
|
cumulative: make_plot_data(data.everyone, data.end_times.length),
|
|
|
|
year: make_plot_data(data.everyone, 365),
|
|
|
|
month: make_plot_data(data.everyone, 30),
|
|
|
|
week: make_plot_data(data.everyone, 7),
|
2017-02-07 23:30:34 +01:00
|
|
|
},
|
|
|
|
user: {
|
2017-02-09 03:38:30 +01:00
|
|
|
cumulative: make_plot_data(data.user, data.end_times.length),
|
2017-03-05 11:44:35 +01:00
|
|
|
year: make_plot_data(data.user, 365),
|
|
|
|
month: make_plot_data(data.user, 30),
|
|
|
|
week: make_plot_data(data.user, 7),
|
2017-02-02 01:07:41 +01:00
|
|
|
},
|
2017-01-11 21:44:59 +01:00
|
|
|
};
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
let user_button = "everyone";
|
2019-11-02 00:06:25 +01:00
|
|
|
let time_button;
|
2017-03-05 11:44:35 +01:00
|
|
|
if (data.end_times.length >= 30) {
|
2020-07-15 01:29:15 +02:00
|
|
|
time_button = "month";
|
|
|
|
$("#messages_by_client_last_month_button").addClass("selected");
|
2017-03-05 11:44:35 +01:00
|
|
|
} else {
|
2020-07-15 01:29:15 +02:00
|
|
|
time_button = "cumulative";
|
|
|
|
$("#messages_by_client_cumulative_button").addClass("selected");
|
2017-03-05 11:44:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (data.end_times.length < 365) {
|
2017-06-30 21:37:59 +02:00
|
|
|
$("#pie_messages_sent_by_client button[data-time='year']").remove();
|
2017-03-05 11:44:35 +01:00
|
|
|
if (data.end_times.length < 30) {
|
2017-06-30 21:37:59 +02:00
|
|
|
$("#pie_messages_sent_by_client button[data-time='month']").remove();
|
2017-03-05 11:44:35 +01:00
|
|
|
if (data.end_times.length < 7) {
|
2017-06-30 21:37:59 +02:00
|
|
|
$("#pie_messages_sent_by_client button[data-time='week']").remove();
|
2017-03-05 11:44:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-11 21:44:59 +01:00
|
|
|
|
2017-02-07 23:30:34 +01:00
|
|
|
function draw_plot() {
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#id_messages_sent_by_client > div").removeClass("spinner");
|
2019-11-02 00:06:25 +01:00
|
|
|
const data_ = plot_data[user_button][time_button];
|
2017-02-09 09:03:25 +01:00
|
|
|
layout.height = layout.margin.b + data_.trace.x.length * 30;
|
2020-02-12 01:35:16 +01:00
|
|
|
layout.xaxis.range = [0, Math.max(...data_.trace.x) * 1.3];
|
2020-07-15 00:34:28 +02:00
|
|
|
Plotly.newPlot(
|
|
|
|
"id_messages_sent_by_client",
|
|
|
|
[data_.trace, data_.trace_annotations],
|
|
|
|
layout,
|
|
|
|
{displayModeBar: false, staticPlot: true},
|
|
|
|
);
|
2017-02-07 23:30:34 +01:00
|
|
|
}
|
2017-01-11 21:44:59 +01:00
|
|
|
|
2017-02-07 23:30:34 +01:00
|
|
|
draw_plot();
|
|
|
|
|
|
|
|
// Click handlers
|
|
|
|
function set_user_button(button) {
|
2017-06-30 21:37:59 +02:00
|
|
|
$("#pie_messages_sent_by_client button[data-user]").removeClass("selected");
|
|
|
|
button.addClass("selected");
|
2017-02-07 23:30:34 +01:00
|
|
|
}
|
2017-01-11 21:44:59 +01:00
|
|
|
|
2017-02-07 23:30:34 +01:00
|
|
|
function set_time_button(button) {
|
2017-06-30 21:37:59 +02:00
|
|
|
$("#pie_messages_sent_by_client button[data-time]").removeClass("selected");
|
|
|
|
button.addClass("selected");
|
2017-02-07 23:30:34 +01:00
|
|
|
}
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#pie_messages_sent_by_client button").on("click", function () {
|
2017-06-30 21:37:59 +02:00
|
|
|
if ($(this).attr("data-user")) {
|
|
|
|
set_user_button($(this));
|
|
|
|
user_button = $(this).attr("data-user");
|
|
|
|
}
|
|
|
|
if ($(this).attr("data-time")) {
|
|
|
|
set_time_button($(this));
|
|
|
|
time_button = $(this).attr("data-time");
|
|
|
|
}
|
2017-02-07 23:30:34 +01:00
|
|
|
draw_plot();
|
2017-01-11 21:44:59 +01:00
|
|
|
});
|
2017-02-07 23:30:34 +01:00
|
|
|
|
2017-01-11 21:44:59 +01:00
|
|
|
// handle links with @href started with '#' only
|
2020-07-15 01:29:15 +02:00
|
|
|
$(document).on("click", 'a[href^="#"]', function (e) {
|
2017-01-11 21:44:59 +01:00
|
|
|
// target element id
|
2020-07-15 01:29:15 +02:00
|
|
|
const id = $(this).attr("href");
|
2017-01-11 21:44:59 +01:00
|
|
|
// target element
|
2019-11-02 00:06:25 +01:00
|
|
|
const $id = $(id);
|
2017-01-11 21:44:59 +01:00
|
|
|
if ($id.length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// prevent standard hash navigation (avoid blinking in IE)
|
|
|
|
e.preventDefault();
|
2020-07-15 01:29:15 +02:00
|
|
|
const pos = $id.offset().top + $(".page-content")[0].scrollTop - 50;
|
|
|
|
$(".page-content").animate({scrollTop: pos + "px"}, 500);
|
2017-01-11 21:44:59 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function populate_messages_sent_by_message_type(data) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const layout = {
|
2020-07-16 22:40:18 +02:00
|
|
|
margin: {l: 90, r: 0, b: 0, t: 0},
|
2017-06-30 21:37:59 +02:00
|
|
|
width: 750,
|
2017-01-11 21:44:59 +01:00
|
|
|
height: 300,
|
2017-02-08 02:24:31 +01:00
|
|
|
font: font_14pt,
|
2017-02-07 23:30:34 +01:00
|
|
|
};
|
|
|
|
|
2017-02-09 03:38:30 +01:00
|
|
|
function make_plot_data(time_series_data, num_steps) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const plot_data = compute_summary_chart_data(
|
2019-10-26 00:21:32 +02:00
|
|
|
time_series_data,
|
|
|
|
num_steps,
|
2020-07-02 02:16:03 +02:00
|
|
|
data.display_order,
|
2019-10-26 00:21:32 +02:00
|
|
|
);
|
2019-11-02 00:06:25 +01:00
|
|
|
const labels = [];
|
|
|
|
for (let i = 0; i < plot_data.labels.length; i += 1) {
|
2020-07-15 01:29:15 +02:00
|
|
|
labels.push(plot_data.labels[i] + " (" + plot_data.percentages[i] + ")");
|
2017-02-09 09:03:25 +01:00
|
|
|
}
|
2020-08-10 20:29:51 +02:00
|
|
|
const total_string = plot_data.total.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
2017-02-09 03:38:30 +01:00
|
|
|
return {
|
|
|
|
trace: {
|
2017-02-09 09:03:25 +01:00
|
|
|
values: plot_data.values,
|
2020-07-20 22:18:43 +02:00
|
|
|
labels,
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "pie",
|
|
|
|
direction: "clockwise",
|
2017-02-09 03:38:30 +01:00
|
|
|
rotation: -90,
|
|
|
|
sort: false,
|
|
|
|
textinfo: "text",
|
2020-07-15 01:29:15 +02:00
|
|
|
text: plot_data.labels.map(() => ""),
|
2017-02-09 09:03:25 +01:00
|
|
|
hoverinfo: "label+value",
|
2017-02-09 03:38:30 +01:00
|
|
|
pull: 0.05,
|
|
|
|
marker: {
|
2020-07-15 01:29:15 +02:00
|
|
|
colors: ["#68537c", "#be6d68", "#b3b348"],
|
2017-02-09 03:38:30 +01:00
|
|
|
},
|
|
|
|
},
|
2020-08-10 20:29:51 +02:00
|
|
|
total_str: i18n.t("<b>Total messages</b>: __total_messages__", {
|
|
|
|
total_messages: total_string,
|
|
|
|
}),
|
2017-02-09 03:38:30 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const plot_data = {
|
2018-05-18 22:13:08 +02:00
|
|
|
everyone: {
|
|
|
|
cumulative: make_plot_data(data.everyone, data.end_times.length),
|
|
|
|
year: make_plot_data(data.everyone, 365),
|
|
|
|
month: make_plot_data(data.everyone, 30),
|
|
|
|
week: make_plot_data(data.everyone, 7),
|
2017-02-07 23:30:34 +01:00
|
|
|
},
|
|
|
|
user: {
|
2017-02-09 03:38:30 +01:00
|
|
|
cumulative: make_plot_data(data.user, data.end_times.length),
|
2017-03-05 11:44:35 +01:00
|
|
|
year: make_plot_data(data.user, 365),
|
|
|
|
month: make_plot_data(data.user, 30),
|
|
|
|
week: make_plot_data(data.user, 7),
|
2017-02-02 01:07:41 +01:00
|
|
|
},
|
2017-01-11 21:44:59 +01:00
|
|
|
};
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
let user_button = "everyone";
|
2019-11-02 00:06:25 +01:00
|
|
|
let time_button;
|
2017-03-05 11:44:35 +01:00
|
|
|
if (data.end_times.length >= 30) {
|
2020-07-15 01:29:15 +02:00
|
|
|
time_button = "month";
|
|
|
|
$("#messages_by_type_last_month_button").addClass("selected");
|
2017-03-05 11:44:35 +01:00
|
|
|
} else {
|
2020-07-15 01:29:15 +02:00
|
|
|
time_button = "cumulative";
|
|
|
|
$("#messages_by_type_cumulative_button").addClass("selected");
|
2017-03-05 11:44:35 +01:00
|
|
|
}
|
2020-07-15 01:29:15 +02:00
|
|
|
const totaldiv = document.getElementById("pie_messages_sent_by_type_total");
|
2017-01-11 21:44:59 +01:00
|
|
|
|
2017-03-05 11:44:35 +01:00
|
|
|
if (data.end_times.length < 365) {
|
2017-06-30 21:37:59 +02:00
|
|
|
$("#pie_messages_sent_by_type button[data-time='year']").remove();
|
2017-03-05 11:44:35 +01:00
|
|
|
if (data.end_times.length < 30) {
|
2017-06-30 21:37:59 +02:00
|
|
|
$("#pie_messages_sent_by_type button[data-time='month']").remove();
|
2017-03-05 11:44:35 +01:00
|
|
|
if (data.end_times.length < 7) {
|
2017-06-30 21:37:59 +02:00
|
|
|
$("#pie_messages_sent_by_type button[data-time='week']").remove();
|
2017-03-05 11:44:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-07 23:30:34 +01:00
|
|
|
function draw_plot() {
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#id_messages_sent_by_message_type > div").removeClass("spinner");
|
2020-07-15 00:34:28 +02:00
|
|
|
Plotly.newPlot(
|
|
|
|
"id_messages_sent_by_message_type",
|
|
|
|
[plot_data[user_button][time_button].trace],
|
|
|
|
layout,
|
|
|
|
{displayModeBar: false},
|
|
|
|
);
|
2017-02-09 03:38:30 +01:00
|
|
|
totaldiv.innerHTML = plot_data[user_button][time_button].total_str;
|
2017-02-07 23:30:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
draw_plot();
|
|
|
|
|
|
|
|
// Click handlers
|
|
|
|
function set_user_button(button) {
|
2017-06-30 21:37:59 +02:00
|
|
|
$("#pie_messages_sent_by_type button[data-user]").removeClass("selected");
|
|
|
|
button.addClass("selected");
|
2017-02-07 23:30:34 +01:00
|
|
|
}
|
2017-01-11 21:44:59 +01:00
|
|
|
|
2017-02-07 23:30:34 +01:00
|
|
|
function set_time_button(button) {
|
2017-06-30 21:37:59 +02:00
|
|
|
$("#pie_messages_sent_by_type button[data-time]").removeClass("selected");
|
|
|
|
button.addClass("selected");
|
2017-02-07 23:30:34 +01:00
|
|
|
}
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#pie_messages_sent_by_type button").on("click", function () {
|
2017-06-30 21:37:59 +02:00
|
|
|
if ($(this).attr("data-user")) {
|
|
|
|
set_user_button($(this));
|
|
|
|
user_button = $(this).attr("data-user");
|
|
|
|
}
|
|
|
|
if ($(this).attr("data-time")) {
|
|
|
|
set_time_button($(this));
|
|
|
|
time_button = $(this).attr("data-time");
|
|
|
|
}
|
2017-02-07 23:30:34 +01:00
|
|
|
draw_plot();
|
2017-01-11 21:44:59 +01:00
|
|
|
});
|
2016-12-20 02:30:08 +01:00
|
|
|
}
|
|
|
|
|
2017-02-07 23:06:41 +01:00
|
|
|
function populate_number_of_users(data) {
|
2019-11-02 00:06:25 +01:00
|
|
|
const layout = {
|
2017-02-07 23:06:41 +01:00
|
|
|
width: 750,
|
|
|
|
height: 370,
|
2020-07-16 22:40:18 +02:00
|
|
|
margin: {l: 40, r: 0, b: 65, t: 20},
|
2017-02-07 23:06:41 +01:00
|
|
|
xaxis: {
|
|
|
|
fixedrange: true,
|
2020-07-16 22:40:18 +02:00
|
|
|
rangeslider: {bordercolor: "#D8D8D8", borderwidth: 1},
|
2017-02-07 23:06:41 +01:00
|
|
|
rangeselector: {
|
2020-07-15 00:34:28 +02:00
|
|
|
x: 0.64,
|
|
|
|
y: -0.79,
|
2017-02-07 23:06:41 +01:00
|
|
|
buttons: [
|
2020-07-16 22:40:18 +02:00
|
|
|
{count: 2, label: i18n.t("Last 2 months"), step: "month", stepmode: "backward"},
|
|
|
|
{count: 6, label: i18n.t("Last 6 months"), step: "month", stepmode: "backward"},
|
|
|
|
{step: "all", label: i18n.t("All time")},
|
2020-07-15 00:34:28 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2020-07-16 22:40:18 +02:00
|
|
|
yaxis: {fixedrange: true, rangemode: "tozero"},
|
2017-02-08 02:24:31 +01:00
|
|
|
font: font_14pt,
|
2017-02-07 23:06:41 +01:00
|
|
|
};
|
2017-02-08 03:07:05 +01:00
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
const end_dates = data.end_times.map((timestamp) => new Date(timestamp * 1000));
|
2017-02-08 03:07:05 +01:00
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
const text = end_dates.map((date) => format_date(date, false));
|
2017-02-08 03:07:05 +01:00
|
|
|
|
2018-05-19 22:43:02 +02:00
|
|
|
function make_traces(values, type) {
|
|
|
|
return {
|
|
|
|
x: end_dates,
|
|
|
|
y: values,
|
2020-07-20 22:18:43 +02:00
|
|
|
type,
|
2018-05-19 22:43:02 +02:00
|
|
|
name: i18n.t("Active users"),
|
2020-07-15 01:29:15 +02:00
|
|
|
hoverinfo: "none",
|
2020-07-20 22:18:43 +02:00
|
|
|
text,
|
2018-05-19 22:43:02 +02:00
|
|
|
visible: true,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2018-05-26 19:18:53 +02:00
|
|
|
function add_hover_handler() {
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById("id_number_of_users").on("plotly_hover", (data) => {
|
2018-05-26 19:18:53 +02:00
|
|
|
$("#users_hover_info").show();
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById("users_hover_date").innerText =
|
2018-05-26 19:18:53 +02:00
|
|
|
data.points[0].data.text[data.points[0].pointNumber];
|
2019-11-02 00:06:25 +01:00
|
|
|
const values = [null, null, null];
|
2020-07-02 01:45:54 +02:00
|
|
|
data.points.forEach((trace) => {
|
2018-05-26 19:18:53 +02:00
|
|
|
values[trace.curveNumber] = trace.y;
|
|
|
|
});
|
2019-11-02 00:06:25 +01:00
|
|
|
const hover_value_ids = [
|
2020-07-15 00:34:28 +02:00
|
|
|
"users_hover_1day_value",
|
|
|
|
"users_hover_15day_value",
|
|
|
|
"users_hover_all_time_value",
|
|
|
|
];
|
2019-11-02 00:06:25 +01:00
|
|
|
for (let i = 0; i < values.length; i += 1) {
|
2018-05-26 19:18:53 +02:00
|
|
|
if (values[i] !== null) {
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById(hover_value_ids[i]).style.display = "inline";
|
2018-05-26 19:18:53 +02:00
|
|
|
document.getElementById(hover_value_ids[i]).innerText = values[i];
|
|
|
|
} else {
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById(hover_value_ids[i]).style.display = "none";
|
2018-05-26 19:18:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
const _1day_trace = make_traces(data.everyone._1day, "bar");
|
|
|
|
const _15day_trace = make_traces(data.everyone._15day, "scatter");
|
|
|
|
const all_time_trace = make_traces(data.everyone.all_time, "scatter");
|
2017-02-08 03:07:05 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#id_number_of_users > div").removeClass("spinner");
|
2017-12-03 12:21:05 +01:00
|
|
|
|
2018-05-19 22:43:02 +02:00
|
|
|
// Redraw the plot every time for simplicity. If we have perf problems with this in the
|
|
|
|
// future, we can copy the update behavior from populate_messages_sent_over_time
|
|
|
|
function draw_or_update_plot(trace) {
|
2020-07-15 00:34:28 +02:00
|
|
|
$("#1day_actives_button, #15day_actives_button, #all_time_actives_button").removeClass(
|
|
|
|
"selected",
|
|
|
|
);
|
2020-07-15 01:29:15 +02:00
|
|
|
Plotly.newPlot("id_number_of_users", [trace], layout, {displayModeBar: false});
|
2018-05-26 19:18:53 +02:00
|
|
|
add_hover_handler();
|
2018-05-19 22:43:02 +02:00
|
|
|
}
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#1day_actives_button").on("click", function () {
|
2018-05-19 22:43:02 +02:00
|
|
|
draw_or_update_plot(_1day_trace);
|
|
|
|
$(this).addClass("selected");
|
|
|
|
});
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#15day_actives_button").on("click", function () {
|
2018-05-19 22:43:02 +02:00
|
|
|
draw_or_update_plot(_15day_trace);
|
|
|
|
$(this).addClass("selected");
|
|
|
|
});
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#all_time_actives_button").on("click", function () {
|
2018-05-19 22:43:02 +02:00
|
|
|
draw_or_update_plot(all_time_trace);
|
|
|
|
$(this).addClass("selected");
|
|
|
|
});
|
|
|
|
|
|
|
|
// Initial drawing of plot
|
2019-02-01 08:04:46 +01:00
|
|
|
draw_or_update_plot(all_time_trace, true);
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#all_time_actives_button").addClass("selected");
|
2017-02-07 23:06:41 +01:00
|
|
|
}
|
|
|
|
|
2020-06-11 12:57:43 +02:00
|
|
|
function populate_messages_read_over_time(data) {
|
|
|
|
if (data.end_times.length === 0) {
|
|
|
|
// TODO: do something nicer here
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Helper functions
|
|
|
|
function make_traces(dates, values, type, date_formatter) {
|
2020-07-02 01:45:54 +02:00
|
|
|
const text = dates.map((date) => date_formatter(date));
|
2020-07-20 22:18:43 +02:00
|
|
|
const common = {x: dates, type, hoverinfo: "none", text};
|
2020-06-11 12:57:43 +02:00
|
|
|
return {
|
|
|
|
everyone: {
|
2020-07-15 00:34:28 +02:00
|
|
|
name: i18n.t("Everyone"),
|
|
|
|
y: values.everyone,
|
|
|
|
marker: {color: "#5f6ea0"},
|
2020-06-11 12:57:43 +02:00
|
|
|
...common,
|
|
|
|
},
|
|
|
|
me: {
|
2020-07-15 00:34:28 +02:00
|
|
|
name: i18n.t("Me"),
|
|
|
|
y: values.me,
|
|
|
|
marker: {color: "#be6d68"},
|
2020-06-11 12:57:43 +02:00
|
|
|
...common,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
const layout = {
|
2020-07-15 01:29:15 +02:00
|
|
|
barmode: "group",
|
2020-06-11 12:57:43 +02:00
|
|
|
width: 750,
|
|
|
|
height: 400,
|
2020-07-16 22:40:18 +02:00
|
|
|
margin: {l: 40, r: 0, b: 40, t: 0},
|
2020-06-11 12:57:43 +02:00
|
|
|
xaxis: {
|
|
|
|
fixedrange: true,
|
2020-07-16 22:40:18 +02:00
|
|
|
rangeslider: {bordercolor: "#D8D8D8", borderwidth: 1},
|
2020-07-15 01:29:15 +02:00
|
|
|
type: "date",
|
2020-06-11 12:57:43 +02:00
|
|
|
},
|
2020-07-16 22:40:18 +02:00
|
|
|
yaxis: {fixedrange: true, rangemode: "tozero"},
|
2020-06-11 12:57:43 +02:00
|
|
|
legend: {
|
2020-07-15 00:34:28 +02:00
|
|
|
x: 0.62,
|
|
|
|
y: 1.12,
|
|
|
|
orientation: "h",
|
|
|
|
font: font_14pt,
|
2020-06-11 12:57:43 +02:00
|
|
|
},
|
|
|
|
font: font_14pt,
|
|
|
|
};
|
|
|
|
|
|
|
|
function make_rangeselector(x, y, button1, button2) {
|
2020-07-15 00:34:28 +02:00
|
|
|
return {
|
2020-07-20 22:18:43 +02:00
|
|
|
x,
|
|
|
|
y,
|
2020-07-15 00:34:28 +02:00
|
|
|
buttons: [
|
|
|
|
{stepmode: "backward", ...button1},
|
|
|
|
{stepmode: "backward", ...button2},
|
2020-09-22 15:14:57 +02:00
|
|
|
{step: "all", label: i18n.t("All time")},
|
2020-07-15 00:34:28 +02:00
|
|
|
],
|
|
|
|
};
|
2020-06-11 12:57:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is also the cumulative rangeselector
|
|
|
|
const daily_rangeselector = make_rangeselector(
|
2020-07-15 00:34:28 +02:00
|
|
|
0.68,
|
|
|
|
-0.62,
|
2020-07-15 01:29:15 +02:00
|
|
|
{count: 10, label: i18n.t("Last 10 days"), step: "day"},
|
2020-07-15 00:34:28 +02:00
|
|
|
{count: 30, label: i18n.t("Last 30 days"), step: "day"},
|
|
|
|
);
|
2020-06-11 12:57:43 +02:00
|
|
|
const weekly_rangeselector = make_rangeselector(
|
2020-07-15 00:34:28 +02:00
|
|
|
0.656,
|
|
|
|
-0.62,
|
2020-07-15 01:29:15 +02:00
|
|
|
{count: 2, label: i18n.t("Last 2 months"), step: "month"},
|
2020-07-15 00:34:28 +02:00
|
|
|
{count: 6, label: i18n.t("Last 6 months"), step: "month"},
|
|
|
|
);
|
2020-06-11 12:57:43 +02:00
|
|
|
|
|
|
|
function add_hover_handler() {
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById("id_messages_read_over_time").on("plotly_hover", (data) => {
|
2020-06-11 12:57:43 +02:00
|
|
|
$("#read_hover_info").show();
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById("read_hover_date").innerText =
|
2020-06-11 12:57:43 +02:00
|
|
|
data.points[0].data.text[data.points[0].pointNumber];
|
|
|
|
const values = [null, null];
|
2020-07-02 01:45:54 +02:00
|
|
|
data.points.forEach((trace) => {
|
2020-06-11 12:57:43 +02:00
|
|
|
values[trace.curveNumber] = trace.y;
|
|
|
|
});
|
2020-07-15 01:29:15 +02:00
|
|
|
const read_hover_text_ids = ["read_hover_me", "read_hover_everyone"];
|
|
|
|
const read_hover_value_ids = ["read_hover_me_value", "read_hover_everyone_value"];
|
2020-06-11 12:57:43 +02:00
|
|
|
for (let i = 0; i < values.length; i += 1) {
|
|
|
|
if (values[i] !== null) {
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById(read_hover_text_ids[i]).style.display = "inline";
|
|
|
|
document.getElementById(read_hover_value_ids[i]).style.display = "inline";
|
2020-06-11 12:57:43 +02:00
|
|
|
document.getElementById(read_hover_value_ids[i]).innerText = values[i];
|
|
|
|
} else {
|
2020-07-15 01:29:15 +02:00
|
|
|
document.getElementById(read_hover_text_ids[i]).style.display = "none";
|
|
|
|
document.getElementById(read_hover_value_ids[i]).style.display = "none";
|
2020-06-11 12:57:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
const start_dates = data.end_times.map(
|
|
|
|
(timestamp) =>
|
|
|
|
// data.end_times are the ends of hour long intervals.
|
|
|
|
new Date(timestamp * 1000 - 60 * 60 * 1000),
|
2020-07-02 01:45:54 +02:00
|
|
|
);
|
2020-06-11 12:57:43 +02:00
|
|
|
|
|
|
|
function aggregate_data(aggregation) {
|
|
|
|
let start;
|
|
|
|
let is_boundary;
|
2020-07-15 01:29:15 +02:00
|
|
|
if (aggregation === "day") {
|
2020-06-11 12:57:43 +02:00
|
|
|
start = floor_to_local_day(start_dates[0]);
|
|
|
|
is_boundary = function (date) {
|
|
|
|
return date.getHours() === 0;
|
|
|
|
};
|
2020-07-15 01:29:15 +02:00
|
|
|
} else if (aggregation === "week") {
|
2020-06-11 12:57:43 +02:00
|
|
|
start = floor_to_local_week(start_dates[0]);
|
|
|
|
is_boundary = function (date) {
|
|
|
|
return date.getHours() === 0 && date.getDay() === 0;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
const dates = [start];
|
|
|
|
const values = {everyone: [], me: []};
|
|
|
|
let current = {everyone: 0, me: 0};
|
|
|
|
let i_init = 0;
|
|
|
|
if (is_boundary(start_dates[0])) {
|
2020-07-15 00:34:28 +02:00
|
|
|
current = {everyone: data.everyone.read[0], me: data.user.read[0]};
|
2020-06-11 12:57:43 +02:00
|
|
|
i_init = 1;
|
|
|
|
}
|
|
|
|
for (let i = i_init; i < start_dates.length; i += 1) {
|
|
|
|
if (is_boundary(start_dates[i])) {
|
|
|
|
dates.push(start_dates[i]);
|
|
|
|
values.everyone.push(current.everyone);
|
|
|
|
values.me.push(current.me);
|
|
|
|
current = {everyone: 0, me: 0};
|
|
|
|
}
|
|
|
|
current.everyone += data.everyone.read[i];
|
|
|
|
current.me += data.user.read[i];
|
|
|
|
}
|
|
|
|
values.everyone.push(current.everyone);
|
|
|
|
values.me.push(current.me);
|
|
|
|
return {
|
2020-07-20 22:18:43 +02:00
|
|
|
dates,
|
|
|
|
values,
|
2020-07-15 00:34:28 +02:00
|
|
|
last_value_is_partial: !is_boundary(
|
|
|
|
new Date(start_dates[start_dates.length - 1].getTime() + 60 * 60 * 1000),
|
|
|
|
),
|
|
|
|
};
|
2020-06-11 12:57:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Generate traces
|
|
|
|
let date_formatter = function (date) {
|
|
|
|
return format_date(date, true);
|
|
|
|
};
|
|
|
|
let values = {me: data.user.read, everyone: data.everyone.read};
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
let info = aggregate_data("day");
|
2020-06-11 12:57:43 +02:00
|
|
|
date_formatter = function (date) {
|
|
|
|
return format_date(date, false);
|
|
|
|
};
|
|
|
|
const last_day_is_partial = info.last_value_is_partial;
|
2020-07-15 01:29:15 +02:00
|
|
|
const daily_traces = make_traces(info.dates, info.values, "bar", date_formatter);
|
2020-06-11 12:57:43 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
info = aggregate_data("week");
|
2020-06-11 12:57:43 +02:00
|
|
|
date_formatter = function (date) {
|
|
|
|
return i18n.t("Week of __date__", {date: format_date(date, false)});
|
|
|
|
};
|
|
|
|
const last_week_is_partial = info.last_value_is_partial;
|
2020-07-15 01:29:15 +02:00
|
|
|
const weekly_traces = make_traces(info.dates, info.values, "bar", date_formatter);
|
2020-06-11 12:57:43 +02:00
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
const dates = data.end_times.map((timestamp) => new Date(timestamp * 1000));
|
2020-07-15 00:34:28 +02:00
|
|
|
values = {everyone: partial_sums(data.everyone.read), me: partial_sums(data.user.read)};
|
2020-06-11 12:57:43 +02:00
|
|
|
date_formatter = function (date) {
|
|
|
|
return format_date(date, true);
|
|
|
|
};
|
2020-07-15 01:29:15 +02:00
|
|
|
const cumulative_traces = make_traces(dates, values, "scatter", date_formatter);
|
2020-06-11 12:57:43 +02:00
|
|
|
|
|
|
|
// Functions to draw and interact with the plot
|
|
|
|
|
|
|
|
// We need to redraw plot entirely if switching from (the cumulative) line
|
|
|
|
// graph to any bar graph, since otherwise the rangeselector shows both (plotly bug)
|
|
|
|
let clicked_cumulative = false;
|
|
|
|
|
|
|
|
function draw_or_update_plot(rangeselector, traces, last_value_is_partial, initial_draw) {
|
2020-07-15 00:34:28 +02:00
|
|
|
$("#read_daily_button, #read_weekly_button, #read_cumulative_button").removeClass(
|
|
|
|
"selected",
|
|
|
|
);
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#id_messages_read_over_time > div").removeClass("spinner");
|
2020-06-11 12:57:43 +02:00
|
|
|
if (initial_draw) {
|
|
|
|
traces.everyone.visible = true;
|
2020-07-15 01:29:15 +02:00
|
|
|
traces.me.visible = "legendonly";
|
2020-06-11 12:57:43 +02:00
|
|
|
} else {
|
2020-07-15 01:29:15 +02:00
|
|
|
const plotDiv = document.getElementById("id_messages_read_over_time");
|
2020-06-11 12:57:43 +02:00
|
|
|
traces.me.visible = plotDiv.data[0].visible;
|
|
|
|
traces.everyone.visible = plotDiv.data[1].visible;
|
|
|
|
}
|
|
|
|
layout.xaxis.rangeselector = rangeselector;
|
|
|
|
if (clicked_cumulative || initial_draw) {
|
2020-07-15 00:34:28 +02:00
|
|
|
Plotly.newPlot("id_messages_read_over_time", [traces.me, traces.everyone], layout, {
|
|
|
|
displayModeBar: false,
|
|
|
|
});
|
2020-06-11 12:57:43 +02:00
|
|
|
add_hover_handler();
|
|
|
|
} else {
|
2020-07-15 01:29:15 +02:00
|
|
|
Plotly.deleteTraces("id_messages_read_over_time", [0, 1]);
|
|
|
|
Plotly.addTraces("id_messages_read_over_time", [traces.me, traces.everyone]);
|
|
|
|
Plotly.relayout("id_messages_read_over_time", layout);
|
2020-06-11 12:57:43 +02:00
|
|
|
}
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#id_messages_read_over_time").attr("last_value_is_partial", last_value_is_partial);
|
2020-06-11 12:57:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Click handlers for aggregation buttons
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#read_daily_button").on("click", function () {
|
2020-06-11 12:57:43 +02:00
|
|
|
draw_or_update_plot(daily_rangeselector, daily_traces, last_day_is_partial, false);
|
|
|
|
$(this).addClass("selected");
|
|
|
|
clicked_cumulative = false;
|
|
|
|
});
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#read_weekly_button").on("click", function () {
|
2020-06-11 12:57:43 +02:00
|
|
|
draw_or_update_plot(weekly_rangeselector, weekly_traces, last_week_is_partial, false);
|
|
|
|
$(this).addClass("selected");
|
|
|
|
clicked_cumulative = false;
|
|
|
|
});
|
|
|
|
|
2020-07-20 21:26:58 +02:00
|
|
|
$("#read_cumulative_button").on("click", function () {
|
2020-06-11 12:57:43 +02:00
|
|
|
clicked_cumulative = false;
|
|
|
|
draw_or_update_plot(daily_rangeselector, cumulative_traces, false, false);
|
|
|
|
$(this).addClass("selected");
|
|
|
|
clicked_cumulative = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Initial drawing of plot
|
|
|
|
if (weekly_traces.everyone.x.length < 12) {
|
|
|
|
draw_or_update_plot(daily_rangeselector, daily_traces, last_day_is_partial, true);
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#read_daily_button").addClass("selected");
|
2020-06-11 12:57:43 +02:00
|
|
|
} else {
|
|
|
|
draw_or_update_plot(weekly_rangeselector, weekly_traces, last_week_is_partial, true);
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#read_weekly_button").addClass("selected");
|
2020-06-11 12:57:43 +02:00
|
|
|
}
|
|
|
|
}
|
2018-05-17 22:25:31 +02:00
|
|
|
|
|
|
|
function get_chart_data(data, callback) {
|
|
|
|
$.get({
|
2020-07-15 01:29:15 +02:00
|
|
|
url: "/json/analytics/chart_data" + page_params.data_url_suffix,
|
2020-07-20 22:18:43 +02:00
|
|
|
data,
|
2018-05-17 22:25:31 +02:00
|
|
|
idempotent: true,
|
2020-07-20 22:18:43 +02:00
|
|
|
success(data) {
|
2018-05-17 22:25:31 +02:00
|
|
|
callback(data);
|
|
|
|
update_last_full_update(data.end_times);
|
|
|
|
},
|
2020-07-20 22:18:43 +02:00
|
|
|
error(xhr) {
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#id_stats_errors").show().text(JSON.parse(xhr.responseText).msg);
|
2018-05-17 22:25:31 +02:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
get_chart_data(
|
2020-07-15 01:29:15 +02:00
|
|
|
{chart_name: "messages_sent_over_time", min_length: "10"},
|
2020-07-02 02:16:03 +02:00
|
|
|
populate_messages_sent_over_time,
|
2018-05-17 22:25:31 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
get_chart_data(
|
2020-07-15 01:29:15 +02:00
|
|
|
{chart_name: "messages_sent_by_client", min_length: "10"},
|
2020-07-02 02:16:03 +02:00
|
|
|
populate_messages_sent_by_client,
|
2018-05-17 22:25:31 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
get_chart_data(
|
2020-07-15 01:29:15 +02:00
|
|
|
{chart_name: "messages_sent_by_message_type", min_length: "10"},
|
2020-07-02 02:16:03 +02:00
|
|
|
populate_messages_sent_by_message_type,
|
2018-05-17 22:25:31 +02:00
|
|
|
);
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
get_chart_data({chart_name: "number_of_humans", min_length: "10"}, populate_number_of_users);
|
2020-06-11 12:57:43 +02:00
|
|
|
|
|
|
|
get_chart_data(
|
2020-07-15 01:29:15 +02:00
|
|
|
{chart_name: "messages_read_over_time", min_length: "10"},
|
2020-07-02 02:16:03 +02:00
|
|
|
populate_messages_read_over_time,
|
2020-06-11 12:57:43 +02:00
|
|
|
);
|