Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
GoJS Diagram not loading at initial call

I have been trying to load a graph from a default selected value in a drop down list. This is the html for the select element.

            <select class="custom-select" id="activity">
                <option disabled value="">Select an activity</option>
                <option selected value="Running">Running</option>
            </select>

And then the javascript goes like this.

   function loop() {
        setTimeout(function () {
            load(activities.value);
            loop();
        }, 5000);
    }



    var activities = document.getElementById("activity");

    load(activities.value);

I tried this and the graph just dows not not load up. But then i tried this

   function loop() {
        setTimeout(function () {
            load(activities.value);
            loop();
        }, 5000);
    }



    var activities = document.getElementById("activity");
    load(activities.value);
    loop();
function load(activity){
    graph= {"class": "go.GraphLinksModel",
                "nodeDataArray": [{}],
                "linkDataArray": [{}]
                 }
    myDiagram.model = go.Model.fromJson(graph);
}

And the initial function call just before loop() does not load the graph. But after 5 seconds once the loop kicks in the graph loads up. And every 5 seconds it keeps loading up just like it should. I also tried adding a onchange event listener to the drop down with 2 more options and added.

    activities.addEventListener("change", () => {
        load(activities.value);});

and once i changed back and forth the graphs load up.

I also tried the myDiagram.requestUpdate(); right after the load(activities.value);.

Where an going wrong? What am i doing wrong?. Appreciate all advices and questions for any more clarification and ofcourse some answers if anyone can help.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I found the solution to be the problem to be the load function initially being called before the div element is available. After adding a window.addEventListener('DOMContentLoaded', init); it is working fine now.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda