spring-beans-visualized icon indicating copy to clipboard operation
spring-beans-visualized copied to clipboard

Graph is not getting plotted

Open DragonPulse opened this issue 6 years ago • 3 comments

The Graph is not getting plotted. the issue is in index.html var beans = typeFilter != '' ? json[0].beans.filter(function(b){ return beanTypeContains(b, typeFilter)}) : json[0].beans;

json[o].beans is undefined.

but the app.js line 41 res.send(body) is able to send the response. Seems like some issue with parsing the json form server

DragonPulse avatar Feb 20 '19 23:02 DragonPulse

I also have the same problem using Docker -> a page with 2 inputs ("Filter beans" and "Highlight beans") is displayed, as well as a message Loading data next to the Redraw button, but nothing is displayed... In the console docker displays Beans info located on: http://user:[email protected]:8080/actuator/beans and effectively if I click on the link a JSON is displayed. I also think that in the README should be added the docker option -p 3000:3000 otherwise is not easy to see anything...

j75 avatar Dec 13 '19 11:12 j75

Finally I've got my graph by modifying index.html as shown below:

var beans = typeFilter != ''
                ? json.contexts.application.beans.filter(function(b) { return beanTypeContains(b, typeFilter)})
                : json.contexts.application.beans;
        var beansArray = Object.keys(beans).map((bean) => ({
          bean,
          ...beans[bean],
        }));
        var beanNodes = beansArray.map(function (b) {
      return {
        name: b.bean,
        group: 1,
        isHighlighted: beanTypeContains(b, highlightBeans)
      }
    });
...
   var beanLinks = beansArray.flatMap(beanToLinks); 

j75 avatar Dec 16 '19 14:12 j75

IDK, but it is not worked for me :( My solution:

 var beans = typeFilter != ''
                ? json.contexts.application.beans.filter(function(b) { return beanTypeContains(b, typeFilter)})
                : json.contexts.application.beans;
        var beansArray = Object.keys(beans).map((bean) => ({
          bean,
          ...beans[bean],
        }));
        var beanNodes = beansArray.map(function (b) {
      return {
        name: b.bean,
        group: 1,
        isHighlighted: beanTypeContains(b, highlightBeans)
      }
    });

    beans = Object.entries(beans).map(function ([k,v],_){
      v.bean = k;
      return v;
    });
    var beanNodes = beans.map(function (b){
      return {
        name: b.bean,
        group: 1,
        isHighlighted: beanTypeContains(b, highlightBeans)
      }
    });

    var beanNodesHash = {};
    beanNodes.forEach(function (n, index){ beanNodesHash[n.name] = index; })

    function nameToId(name) {
      return beanNodesHash[name];
    }

    function beanToLinks(bean) {
      return bean.dependencies.map(function (reference) {
        return {
          source: nameToId(reference),
          target: nameToId(bean.bean),
          value: 1
        };
      }).filter(function (link){
        return link.source != undefined && link.target != undefined;
      });
    }

    var beanLinks = beansArray.flatMap(beanToLinks);

hexi03 avatar Aug 15 '24 06:08 hexi03