【发布时间】:2019-11-05 14:33:20
【问题描述】:
这一定是格式问题,但我的图表不接受来自真实来源的新数据...我注意到 Go.js 没有生成哈希 ID
function updateGraph(node_list,myDiagram){
var model = $(go.TreeModel);
//add some dummy data
model.nodeDataArray =
[
{ key: 1, parent: 1, color: "lightblue"},
{ key: 2, parent: 1 , color: "lightblue"},
{ key: 3, parent: 2, color: "lightblue"}
];
//add real data
for(let id = 1; id < node_list.length; id++){
model.nodeDataArray.push({key: node_list[id].getNodeID(), parent: node_list[id].getNodeID(), color: "lightblue"});
}
console.log(model.nodeDataArray);
myDiagram.model = model;
}
控制台:
0: {key: 1, parent: 1, color: "lightblue", __gohashid: 409}
1: {key: 2, parent: 1, color: "lightblue", __gohashid: 410}
2: {key: 3, parent: 2, color: "lightblue", __gohashid: 411}
3: {key: "step_02_set_incoming_file_permissions", parent: "step_02_set_incoming_file_permissions", color: "lightblue"}
4: {key: "step_025_truncate", parent: "step_025_truncate", color: "lightblue"}
5: {key: "step_03_extract_item_sold_details", parent: "step_03_extract_item_sold_details", color: "lightblue"}
但是,如果我将虚拟数据设置为控制台打印出的硬编码值:
model.nodeDataArray =
[
{key: "step_02_set_incoming_file_permissions", parent: "step_01_starting_email", color: "lightblue"},
{key: "step_025_truncate", parent: "step_02_set_incoming_file_permissions", color: "lightblue"},
{key: "step_03_extract_item_sold_details", parent: "step_025_truncate", color: "lightblue"}
];
我得到一个带有哈希 id 的输出:
【问题讨论】:
标签: javascript gojs