in public/charts.js [91:129]
async function addSeriesToChart(ctx, opts) {
const resp = await fetchQueryData(opts);
const y_axis = selectAxis(resp.field);
const seriesColor = randomColor();
const seriesConfig = {
key: resp.repo,
label: `${resp.repo} - ${resp.field}`,
color: seriesColor,
axis: y_axis,
};
// Collect graph info
// TODO: Lock labels
const labels = Object.keys(resp.data).sort();
// Create a Chart.js based on the series config
const dataSet = {
label: seriesConfig.label,
type: "line",
borderColor: seriesConfig.color,
fill: false,
data: [],
yAxisID: seriesConfig.axis.id,
};
// Accumulate the data
dataSet.data = labels.map((label) => {
return resp.data[label];
});
// TODO: Just this
CHART_AXES.push(y_axis);
CHART_DATA.labels = labels;
CHART_DATA.datasets.push(dataSet);
// Once we have all data, draw the chart
drawChart(ctx);
}