diff --git a/runbot/static/src/js/stats.js b/runbot/static/src/js/stats.js index 6c5ae0fb..383f6601 100644 --- a/runbot/static/src/js/stats.js +++ b/runbot/static/src/js/stats.js @@ -162,7 +162,7 @@ function fetchUpdateChart() { function generateLegend() { var legend = $(""); for (data of config.data.datasets) { - var legendElement = $(`
  • ${data.label}
  • `) + var legendElement = $(`
  • ${data.label}
  • `) if (data.hidden){ legendElement.addClass('disabled') } @@ -228,6 +228,20 @@ function updateUrl(){ window.location.hash = new URLSearchParams(config.searchParams).toString(); } +async function waitForChart() { + + function loop(resolve) { + if (window.Chart) { + resolve(); + } else { + setTimeout(loop.bind(null, resolve),10); + } + } + return new Promise((resolve) => { + loop(resolve); + }) +} + window.onload = function() { config.searchParams = { limit: 25, @@ -256,6 +270,5 @@ window.onload = function() { fetchUpdateChart(); } - - fetchUpdateChart(); + waitForChart().then(fetchUpdateChart); }; diff --git a/runbot/templates/build_stats.xml b/runbot/templates/build_stats.xml index 3fef5612..e2d73693 100644 --- a/runbot/templates/build_stats.xml +++ b/runbot/templates/build_stats.xml @@ -96,8 +96,8 @@
    -
    -
    +
    +
    Mode: