Javascript 无法在MG数据表中加载Json数据

Javascript 无法在MG数据表中加载Json数据,javascript,html,json,d3.js,Javascript,Html,Json,D3.js,我是D3.js的新手。 我创建了一个脚本,但无法将任何json数据加载到表中 d3.json('C:\Software\Data\dirk\development\D3_TestLab\data\StatusTabel.json', function (data) { var table_data = data var table1 = MG.data_table({ data: table_data, //title: '',

我是D3.js的新手。 我创建了一个脚本,但无法将任何json数据加载到表中

d3.json('C:\Software\Data\dirk\development\D3_TestLab\data\StatusTabel.json', function (data) {

    var table_data = data

    var table1 = MG.data_table({
        data: table_data,
        //title: '',
        //description: 'A table has many of the same properties as any other data graphic.',
        show_tooltips: true
    })

        .target('#div1')

        .number({ accessor: 'BU', label: 'BU', width: 120, font_size: 14, layout: 'center' })
        .number({ accessor: 'Lines', label: '# Lines', width: 190, font_size: 14, layout: 'center' })
      //.number({accessor: 'Errors', label: 'Errors', width: 170, font_size: 14, color: function(d){ return d > 0 ? '#f70101' : 'auto'; })
        .number({ accessor: 'Errors', label: 'Errors', width: 190, font_size: 14, color: 'red', allign: 'center' })
        .number({ accessor: 'Shift', label: 'Shift', width: 270, font_size: 14 })

        .display();
})

我没有检查你的逻辑,但我能提出的几点是

1) 尝试将url从更改为json文件: 'C:\Software\Data\dirk\development\D3\u TestLab\Data\StatusTabel.json' 致: 'file:///C:/Software/Data/dirk/development/D3_TestLab/data/StatusTabel.json"

2) 函数(数据)应具有另一个参数错误。i、 函数(错误,数据){…}


希望这有帮助。

如上所述,函数应该有两个参数
函数(错误,数据)
。如果您甚至正在接收JSON文件,也要进行调试,请尝试添加
console.log(JSON.stringify(data))在读取JSON后立即执行。通过这种方式,您可以查看通话是否正常