Show an error in place of a t-w plot when there is no data to display.

This commit is contained in:
Chris H-C 2015-11-19 10:52:48 -05:00
Родитель f517d65b12
Коммит 469309260b
1 изменённых файлов: 13 добавлений и 0 удалений

Просмотреть файл

@ -143,6 +143,12 @@ window.TelemetryWrapper.go = function (params, element) {
evolutionsByKey[keycount.key] = oldEvolutionsByKey[keycount.key]);
}
if (!Object.keys(evolutionsByKey).length) {
// Uh-oh, there's no data for the provided params. Bail!
showError('No data to graph', params, element);
return;
}
Object.keys(evolutionsByKey).forEach(key => {
var evolutions = evolutionsByKey[key];
if (!evolutions.length) {
@ -562,6 +568,13 @@ window.TelemetryWrapper.go = function (params, element) {
return filterOptions;
}
function showError(msg, params, element) {
var msgEl = document.createElement('pre');
msgEl.className = 'graph-container error';
msgEl.textContent = msg + '\n' + JSON.stringify(params, ' ', 2);
element.appendChild(msgEl);
}
function formatNumber(number) {
// lifted from dist.js
if (number == Infinity) { return 'Infinity'; } // TODO: i18n?