in cmd/internal/pages/assets/js/containers.js [68:134]
function drawLineChart(seriesTitles, data, elementId, unit) {
var min = Infinity;
var max = -Infinity;
for (var i = 0; i < data.length; i++) {
// Convert the first column to a Date.
if (data[i] != null) {
data[i][0] = new Date(data[i][0]);
}
// Find min, max.
for (var j = 1; j < data[i].length; j++) {
var val = data[i][j];
if (val < min) {
min = val;
}
if (val > max) {
max = val;
}
}
}
// We don't want to show any values less than 0 so cap the min value at that.
// At the same time, show 10% of the graph below the min value if we can.
var minWindow = min - (max - min) / 10;
if (minWindow < 0) {
minWindow = 0;
}
// Add the definition of each column and the necessary data.
var dataTable = new google.visualization.DataTable();
dataTable.addColumn('datetime', seriesTitles[0]);
for (var i = 1; i < seriesTitles.length; i++) {
dataTable.addColumn('number', seriesTitles[i]);
}
dataTable.addRows(data);
// Create and draw the visualization.
if (!(elementId in window.charts)) {
window.charts[elementId] =
new google.visualization.LineChart(document.getElementById(elementId));
}
// TODO(vmarmol): Look into changing the view window to get a smoother
// animation.
var opts = {
curveType: 'function',
height: 300,
legend: {position: 'none'},
focusTarget: 'category',
vAxis: {
title: unit,
viewWindow: {
min: minWindow,
}
},
legend: {
position: 'bottom'
}
};
// If the whole data series has the same value, try to center it in the chart.
if (min == max) {
opts.vAxis.viewWindow.max = 1.1 * max;
opts.vAxis.viewWindow.min = 0.9 * max;
}
window.charts[elementId].draw(dataTable, opts);
}