Связывание функции с аргументами 3djs - PullRequest
0 голосов
/ 15 марта 2019

Я пытаюсь подключить узлы в 3Djs:

const linkedByIndex = {};

  d3GraphData.links.forEach(d => {
    linkedByIndex[`${d.source.index},${d.target.index}`] = 1;
    console.log(d.source.index + " " + d.target.index);
   // console.log(a.index + " " b.index);
  });

  function isConnected(a, b) {
           alert("conectado");

   return linkedByIndex[`${a.index},${b.index}`] || 
   linkedByIndex[`${b.index},${a.index}`] || 
   a.index === b.index;
  } 

  function fade(opacity) {
        alert("fade");

        return function(d) {
            node.style("stroke-opacity", function(o) {
                thisOpacity = isConnected(d, o) ? 1 : opacity;
                this.setAttribute('fill-opacity', thisOpacity);
                return thisOpacity;
            });

            link.style("stroke-opacity", function(o) {
                return o.source === d || o.target === d ? 1 : opacity;
            });
        };
    }

при запуске программы:

console.log(a.index + " " b.index);

Покажите мне следующую информацию:

0 1 
1 2 
2 3 
3 4

и alert fade работает, но alert conectado не отображается.

Есть что-то пропустить?Любые предложения приветствуются.

спасибо

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...