【问题标题】:"undefined" appearing in json.nodes.map but json appears ok. Why?json.nodes.map 中出现“未定义”,但 json 显示正常。为什么?
【发布时间】:2017-10-17 05:44:24
【问题描述】:

我在 d3 中有一个几乎完美的图表,但有一个我似乎无法弄清楚的问题。

我使用json.nodes.map 确定图表图例中的各个项目,但由于某种原因,数组中出现了“未定义”类型。生成列表的完整代码如下:

  var listTypes = d3.set(json.nodes.map(function(d){return d.type})).values();

  console.log(listTypes);
  listColors = [];

  listPositions = [];

  lineWidths = [];

  listBorders = [];

  function typeList(typename) {

      types = [];
      for(var key in json.nodes) {
      if (json.nodes[key].type === typename) {
            types[key] = json.nodes[key];
            }
      }

      return types;
  }

  function linkList(typename) {
       links = []
       for(var key in json.links) {

       if (json.links[key].source.type === typename) {
            links[key] = json.links[key];
            }
       if (json.links[key].target.type === typename) {
            links[key] = json.links[key];
            }
       }

       return links;
       }

function poppedType(typename) {
        popped = []
        popped["types"] = typeList(typename)
        popped["links"] = linkList(typename)

        return popped;
        }

function poppedNodes(poppeddata) {
//  console.log(poppeddata["types"]);
      var popnode = json.nodes;
      popnode.enter();

console.log(json.nodes);
      for(var key in popnode){
          var nodekey = key;
          for(var key in poppeddata["types"]) {
            if (popnode[nodekey].id === poppeddata["types"][key]["id"]) {
                console.log(nodekey + ", " + key + ", " + poppeddata["types"][key]["id"] + ", " + popnode[nodekey].id);
                //function(d, nodekey) {console.log(d.id)};
                popnode.splice(nodekey, 1);
                //console.log(popnode.exit());
            }
        }
  }
  popnode.exit().remove();  
}


  for(l = 0; l < listTypes.length; l++){
        for (var key in json.nodes){
          if (listTypes[l] === json.nodes[key].type) {
            if (listColors.indexOf(json.nodes[key].color) > -1)
            {}
            else
              {
                lineWidths.push(json.nodes[key].type.length);
                listColors.push(json.nodes[key].color);
                listBorders.push("aliceblue");
                var xlegend = (Math.floor(l / 10) * 100 );
                var ycounter;
                var ylegend;
                var oldxlegend;

                if (l===0) {
                  ycounter = 1;
                }

                if (ycounter < 10) {
                    listPositions.push(ycounter * 20);
                    ycounter++;
                }
                else 
                {
                    listPositions.push(ycounter * 20);
                    ycounter = 1;                    
                }

              }
          }
          else {}
       }
      }

 var urlColors = d3.set(json.nodes.map(function(d){return d.url_color})).values();

  for (u = 0; u < urlColors.length; u++) {

        if (urlColors[u] === "red") {
            if (listTypes.indexOf("Has draft transcription") > -1)
            {}
            else {
            listTypes.push("Has draft transcription");
            lineWidths.push("Has draft transcription".length);
            listColors.push("aliceblue");
            listBorders.push(urlColors[u]);
            listPositions.push(Math.max.apply(Math,listPositions) + 20);
            }
        }
        if (urlColors[u] === "chartreuse") {
            if (listTypes.indexOf("Has proofed transcription") > -1)
            {}
            else {
            listTypes.push("Has proofed transcription");
            lineWidths.push("Has proofed transcription".length);
            listColors.push("aliceblue");
            listBorders.push(urlColors[u]);
            listPositions.push(Math.max.apply(Math,listPositions) + 20);
            }
        }
        if (urlColors[u] === "cyan") {
            if (listTypes.indexOf("Has external URL") > -1)
            {}
            else {
            listTypes.push("Has external URL");
            lineWidths.push("Has external URL".length);
            listColors.push("aliceblue");
            listBorders.push(urlColors[u]);
            listPositions.push(Math.max.apply(Math,listPositions) + 20);
            }
        }

  }

我正在对 listTypes 数组进行一些添加,但我通过 listTypesconsole.log 确定未定义的结果是通过 json.nodes.map 函数生成的:

(12) ["person", "work", "witness", "multiple_author_work", "undefined", "other_work", "other_Lydgate_work", "location", "city", "region", "country", "edition"]

只有当存在“other_work”类型时才会出现“未定义”,但我的 json(通过 php 动态生成)显示没有空类型。可以看到该 json 的一个示例 here - 如果需要,我也可以将其添加为文件。

我有点茫然——是什么产生了“未定义”条目,我如何确保我犯的任何错误不会再次发生?

【问题讨论】:

  • "undefined"(字符串)与undefined(原始值)不同
  • 尝试使用for 循环切换您的for..in 循环。
  • @JaromandaX 确实是undefined,而不是"undefined"。 D3 集与 JavaScript 集不完全一样,请看这里:jsfiddle.net/jkgsgaeb/1

标签: javascript arrays json d3.js


【解决方案1】:

这里的问题是您没有 type 某些对象的属性,这将使您的 map 返回 undefined

您不能使用map 跳过元素。但是你可以使用reduce:

var listTypes = d3.set(json.nodes.reduce(function(result, d) {
    if (d.type) result.push(d.type);
    return result;
}, [])).values();

这是带有该代码的 JSON,请检查控制台:

var json = {"nodes":[{"id":"person1","name":"John Lydgate","type":"person","color":"darkred","url_color":"cyan","link":"http:\/\/dx.doi.org\/10.1093\/ref:odnb\/17238"},{"id":"work13","name":"Exposition of the Pater Noster","type":"work","color":"midnightblue","url_color":null,"link":null},{"id":"witness2","name":"Q.G.8","type":"witness","color":"green","url_color":"aliceblue","link":null},{"id":"witness4","name":"Harley 2255","type":"witness","color":"green","url_color":"aliceblue","link":null},{"id":"witness5","name":"Laud misc. 683","type":"witness","color":"green","url_color":"aliceblue","link":null},{"id":"multiple_author_work183","name":"Upon the cross nailed was I for thee","type":"multiple_author_work","color":"mistyrose","url_color":"aliceblue","link":null},{"id":"person5","name":"Anonymous","color":"darkred","url_color":"aliceblue","link":null},{"id":"other_work185","name":"Katherine with glorious Margaret","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"person7","name":"Benedict Burgh","color":"darkred","url_color":"aliceblue","link":null},{"id":"other_work186","name":"Cato Major","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work142","name":"A lamentacioun of our lady Maria","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work83","name":"The Testament of John Lydgate","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work6","name":"Misericordias Domini in Eternum Cantabo","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work11","name":"Song of Vertu","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work17","name":"Fifteen Joys and Sorrows of Our Lady","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work18","name":"Prayers to Ten Saints","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work42","name":"Letabundus","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work46","name":"Having a conceit in my simple wit","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work49","name":"Consulo quisque eris","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work60","name":"Midsomer Rose","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work67","name":"A Praise of Peace","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work77","name":"Stans Puer ad Mensam","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work79","name":"Fifteen O's of Christ","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work98","name":"A dyte of womenhis hornys","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work102","name":"Queen of heaven of hell eke empress","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work104","name":"Rest and refuge to folk disconsolate","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work116","name":"On the Mutability of Man's Nature due to the Seasons, the Elements, the Complexions, and the Planets","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work121","name":"Verses on the Kings of England","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work132","name":"Thou heavenly Queen of grace our lodestar","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work136","name":"Look in thy merour and deeme noon othir wiht","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work143","name":"A Doctryne for Pestilence","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work145","name":"Ye Briton Martyrs famous in perfectness","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work146","name":"Ye devout people which have observance","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work128","name":"Dietary","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"multiple_author_work185","name":"Katherine with glorious Margaret","type":"multiple_author_work","color":"mistyrose","url_color":"aliceblue","link":null},{"id":"other_work230","name":"Benedicta sit sancta Trinitas","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"other_work231","name":"My fair lady so fresh of hue","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work39","name":"Benedictus deus in donis suis","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work40","name":"Deus in Nomine Tuo saluum me Fac","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work43","name":"Ave Iesse Virgula","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work51","name":"Fabula duorum mercatorum","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work62","name":"Legend of St. Austin at Compton","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work66","name":"Mesour is Tresour","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work97","name":"Life of St. Giles","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work99","name":"Gloriosa Dicta sunt de Te","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work101","name":"Put out his head list not for to dare","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work105","name":"Right mighty Prince and it be your will","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work158","name":"The Fifftene Tokyns aforn the Doom","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work126","name":"Fall of Princes","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work224","name":"Te deum Laudamus To the Lord sovereign","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work152","name":"Hail holy Ositha maid of great virtue","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work225","name":"This wide world is so large of space","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work226","name":"Toward Aurora in the month of December","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work227","name":"Timor mortis conturbat me","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work228","name":"Some man goeth still of wisdom and reason","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work229","name":"God is myn Helpere","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work187","name":"A prayer to St. Edmund","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_work181","name":"Early on morrow and toward night also","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"other_work182","name":"A babe is born our bliss to bring","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work1","name":"A Satyrical Ballad against Jack Hare","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work31","name":"Guy of Warwick","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work59","name":"The Miracles of St. Edmund","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work65","name":"Complaint \u00feat Crist maketh of his Passioun","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work81","name":"O blessed Robert innocent and virgin","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work85","name":"Eight Verses of St. Bernard","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work86","name":"O star of Jacob glory of Israel","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work115","name":"The Order of Fools","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work147","name":"Interpretacio Misse","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work151","name":"Blessed Gabriel which broughtest first tiding","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work159","name":"Blessed Thomas rubified with blood","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work154","name":"A prayere to seynt Michaell","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"location2","name":"Jesus College","type":"location","color":"gold","url_color":"aliceblue","link":null},{"id":"location3","name":"British Library","type":"location","color":"gold","url_color":"aliceblue","link":null},{"id":"location4","name":"Bodleian Library","type":"location","color":"gold","url_color":"aliceblue","link":null},{"id":"city1","name":"London","type":"city","color":"darkslategrey","url_color":"aliceblue","link":null},{"id":"city3","name":"Cambridge","type":"city","color":"darkslategrey","url_color":"aliceblue","link":null},{"id":"city4","name":"Oxford","type":"city","color":"darkslategrey","url_color":"aliceblue","link":null},{"id":"region3","name":"Greater London","type":"region","color":"magenta","url_color":"aliceblue","link":null},{"id":"region4","name":"Cambridgeshire","type":"region","color":"magenta","url_color":"aliceblue","link":null},{"id":"region5","name":"Oxfordshire","type":"region","color":"magenta","url_color":"aliceblue","link":null},{"id":"country1","name":"United Kingdom","type":"country","color":"orange","url_color":"aliceblue","link":null},{"id":"edition8","name":"John Lydgate: The Minor Poems, Vol. I: Religious Poems. EETS e.s. 107","type":"edition","color":"indigo","url_color":"aliceblue","link":null},{"id":"edition18","name":"Eine religi\u00f6se Gedichte John Lydgates","type":"edition","color":"indigo","url_color":"aliceblue","link":null}]};

var listTypes = d3.set(json.nodes.reduce(function(result, d){if(d.type){result.push(d.type)}return result;},[])).values();

console.log(listTypes)
&lt;script src="https://d3js.org/d3.v4.min.js"&gt;&lt;/script&gt;

关于您的声明(“但我的 json(通过 php 动态生成)显示没有空类型”),这是一个演示,表明您确实有没有 type 属性的对象:

var json = {"nodes":[{"id":"person1","name":"John Lydgate","type":"person","color":"darkred","url_color":"cyan","link":"http:\/\/dx.doi.org\/10.1093\/ref:odnb\/17238"},{"id":"work13","name":"Exposition of the Pater Noster","type":"work","color":"midnightblue","url_color":null,"link":null},{"id":"witness2","name":"Q.G.8","type":"witness","color":"green","url_color":"aliceblue","link":null},{"id":"witness4","name":"Harley 2255","type":"witness","color":"green","url_color":"aliceblue","link":null},{"id":"witness5","name":"Laud misc. 683","type":"witness","color":"green","url_color":"aliceblue","link":null},{"id":"multiple_author_work183","name":"Upon the cross nailed was I for thee","type":"multiple_author_work","color":"mistyrose","url_color":"aliceblue","link":null},{"id":"person5","name":"Anonymous","color":"darkred","url_color":"aliceblue","link":null},{"id":"other_work185","name":"Katherine with glorious Margaret","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"person7","name":"Benedict Burgh","color":"darkred","url_color":"aliceblue","link":null},{"id":"other_work186","name":"Cato Major","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work142","name":"A lamentacioun of our lady Maria","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work83","name":"The Testament of John Lydgate","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work6","name":"Misericordias Domini in Eternum Cantabo","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work11","name":"Song of Vertu","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work17","name":"Fifteen Joys and Sorrows of Our Lady","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work18","name":"Prayers to Ten Saints","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work42","name":"Letabundus","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work46","name":"Having a conceit in my simple wit","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work49","name":"Consulo quisque eris","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work60","name":"Midsomer Rose","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work67","name":"A Praise of Peace","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work77","name":"Stans Puer ad Mensam","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work79","name":"Fifteen O's of Christ","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work98","name":"A dyte of womenhis hornys","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work102","name":"Queen of heaven of hell eke empress","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work104","name":"Rest and refuge to folk disconsolate","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work116","name":"On the Mutability of Man's Nature due to the Seasons, the Elements, the Complexions, and the Planets","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work121","name":"Verses on the Kings of England","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work132","name":"Thou heavenly Queen of grace our lodestar","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work136","name":"Look in thy merour and deeme noon othir wiht","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work143","name":"A Doctryne for Pestilence","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work145","name":"Ye Briton Martyrs famous in perfectness","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work146","name":"Ye devout people which have observance","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work128","name":"Dietary","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"multiple_author_work185","name":"Katherine with glorious Margaret","type":"multiple_author_work","color":"mistyrose","url_color":"aliceblue","link":null},{"id":"other_work230","name":"Benedicta sit sancta Trinitas","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"other_work231","name":"My fair lady so fresh of hue","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work39","name":"Benedictus deus in donis suis","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work40","name":"Deus in Nomine Tuo saluum me Fac","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work43","name":"Ave Iesse Virgula","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work51","name":"Fabula duorum mercatorum","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work62","name":"Legend of St. Austin at Compton","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work66","name":"Mesour is Tresour","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work97","name":"Life of St. Giles","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work99","name":"Gloriosa Dicta sunt de Te","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work101","name":"Put out his head list not for to dare","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work105","name":"Right mighty Prince and it be your will","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work158","name":"The Fifftene Tokyns aforn the Doom","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work126","name":"Fall of Princes","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work224","name":"Te deum Laudamus To the Lord sovereign","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work152","name":"Hail holy Ositha maid of great virtue","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work225","name":"This wide world is so large of space","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work226","name":"Toward Aurora in the month of December","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work227","name":"Timor mortis conturbat me","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work228","name":"Some man goeth still of wisdom and reason","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work229","name":"God is myn Helpere","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work187","name":"A prayer to St. Edmund","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_work181","name":"Early on morrow and toward night also","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"other_work182","name":"A babe is born our bliss to bring","type":"other_work","color":"khaki","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work1","name":"A Satyrical Ballad against Jack Hare","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work31","name":"Guy of Warwick","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work59","name":"The Miracles of St. Edmund","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work65","name":"Complaint \u00feat Crist maketh of his Passioun","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work81","name":"O blessed Robert innocent and virgin","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work85","name":"Eight Verses of St. Bernard","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work86","name":"O star of Jacob glory of Israel","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work115","name":"The Order of Fools","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work147","name":"Interpretacio Misse","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work151","name":"Blessed Gabriel which broughtest first tiding","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work159","name":"Blessed Thomas rubified with blood","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"other_Lydgate_work154","name":"A prayere to seynt Michaell","type":"other_Lydgate_work","color":"cornflowerblue","url_color":"aliceblue","link":""},{"id":"location2","name":"Jesus College","type":"location","color":"gold","url_color":"aliceblue","link":null},{"id":"location3","name":"British Library","type":"location","color":"gold","url_color":"aliceblue","link":null},{"id":"location4","name":"Bodleian Library","type":"location","color":"gold","url_color":"aliceblue","link":null},{"id":"city1","name":"London","type":"city","color":"darkslategrey","url_color":"aliceblue","link":null},{"id":"city3","name":"Cambridge","type":"city","color":"darkslategrey","url_color":"aliceblue","link":null},{"id":"city4","name":"Oxford","type":"city","color":"darkslategrey","url_color":"aliceblue","link":null},{"id":"region3","name":"Greater London","type":"region","color":"magenta","url_color":"aliceblue","link":null},{"id":"region4","name":"Cambridgeshire","type":"region","color":"magenta","url_color":"aliceblue","link":null},{"id":"region5","name":"Oxfordshire","type":"region","color":"magenta","url_color":"aliceblue","link":null},{"id":"country1","name":"United Kingdom","type":"country","color":"orange","url_color":"aliceblue","link":null},{"id":"edition8","name":"John Lydgate: The Minor Poems, Vol. I: Religious Poems. EETS e.s. 107","type":"edition","color":"indigo","url_color":"aliceblue","link":null},{"id":"edition18","name":"Eine religi\u00f6se Gedichte John Lydgates","type":"edition","color":"indigo","url_color":"aliceblue","link":null}]};

var empty = json.nodes.filter(function(d){
    return !d.type
});

console.log(empty)

【讨论】:

  • 这正是问题所在。当我检查时,我的眼睛正在跳过它。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-09-03
  • 2019-08-29
  • 2021-12-30
  • 1970-01-01
  • 2018-02-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多