Javascript 未捕获类型错误:无法读取属性';调度事件';空的

Javascript 未捕获类型错误:无法读取属性';调度事件';空的,javascript,d3.js,Javascript,D3.js,我在运行函数时遇到上述错误。目标是当用户在搜索框中输入一个数字时,它应该在可视化中缩放到该数字。下面是我的代码- function zoom1() { var input1 = document.getElementById("myInput1").value; //value from searchbox console.log("input from searchbox :"+input1); d3.json("intervals.

我在运行函数时遇到上述错误。目标是当用户在搜索框中输入一个数字时,它应该在可视化中缩放到该数字。下面是我的代码-

function zoom1() {
 var input1 = document.getElementById("myInput1").value; //value from searchbox
  console.log("input from searchbox :"+input1);

 d3.json("intervals.json", function(alldata)  // entering json file  to look for oid
 {
    // console.log("all data from json"+alldata);
    var i=0;
    for (i = 0; i < alldata.records.length; i++)  //for loop for getting the "oid"  alldata.records.length;
    {
    
      conceptid1 = alldata.records[i].eag;  //saving all the oid in conceptid
      console.log("conceptid1: "+conceptid1);
      var conceptid2 = conceptid1.toString();
      console.log("conceptid2: "+conceptid2);
      if (conceptid2  === input1) //if the user input1 matches conceptid2
      {
         console.log("inside if conceptid2:"+conceptid2);
        
         console.log(document.getElementById(conceptid2).dispatchEvent(new Event('click'))); // zoom
      }

    }

 });
}
函数zoom1(){
var input1=document.getElementById(“myInput1”).value;//来自searchbox的值
日志(“来自搜索框的输入:“+input1”);
d3.json(“interval.json”,函数(alldata)//输入json文件以查找oid
{
//log(“来自json的所有数据”+所有数据);
var i=0;
for(i=0;i
您能否共享
conceptid2
的控制台日志

顺便说一下,请使用ES6语法。这是一种更新、更好的编写JS的方法。以下是用ES6编写的代码:

const zoom=()=>{
让value=document.querySelector(“#myInput1”).value;
log(`Input${value}`);
d3.json(“interval.json”,(alldata)=>{
const{records}=alldata;
for(设i=0;i
无论如何,我不想太努力,但我希望这有帮助:)