我正在使用d3.js图表及其依赖的数据如下:
var graph = {
"nodes" : [{"name" : "Appointments"},{"name" : "Store Visit"},{"name" : "Visit History"},{"name" : "Resume Store Visit"}],
"links" : [{"source":"Store Visit","target":"Appointments","value":6},
{"source":"Appointments","target":"Visit History","value":7},
{"source":"Visit History","target":"Store Visit","value":2},
{"source":"Resume Store Visit","target":"Visit History","value":1},
{"source":"Appointments","target":"Resume Store Visit","value":5}]
};
我的REST服务返回完全相同的数据,但属性名称是Source,Target和Value(注意首字母大写)
这会打破错误
Uncaught TypeError: Cannot read property 'weight' of undefinedl.start @ d3.v3.min.js:4(anonymous function) @ userflowd3.html:64(anonymous function) @ d3.v3.min.js:1t @ d3.v3.min.js:1u @ d3.v3.min.js:1
那么,json返回data.items将属性值替换为小写的方式是什么?
答案 0 :(得分:0)
所以我必须这样做 像
finish_coordinates.X = ...