我有一个用以下格式填充数据的折线图:
[{"id":"3",
"testSource_id":"2",
"dateTimeTaken":"2013-01-01 14:05:14",
"dateTimeReceived":"2013-03-01 14:05:45",
"reading":"0.90000",
"testSourceLocationDescription":"Somewhere",
"parameter_id":"3",
"inspectionPoint_id":"2",
"testSourceLowerLimit":"3.000000000000000",
"testSourceUpperLimit":"11.000000000000000",
"testSourceLocationLongtitude":"-8.459472656250000",
"testSourceLocationLatitude":"54.201010239738880",
"parameterType":"Flouride",
"unitMeasurement":"F",
"client_id":"1"},......................
我正在尝试根据从地图上的点击事件传递的值来过滤此数据。值 - i - 正确传递,但由于某种原因,我的过滤器函数没有返回它应该返回的所有数据,例如当返回100时返回一个包含45个对象的数组?有人可以帮忙吗?
d3.json("Data.php", function(error,data) {
var data = data.filter(function(d) { return d.inspectionPoint_id == i; })
console.log(data)
data.forEach(function(d) {
d.inspectionPoint_id = +d.inspectionPoint_id;
d.dateTimeTaken = parseDate(d.dateTimeTaken);
d.reading = +d.reading;
d.parameterType = d.parameterType;});
答案 0 :(得分:0)
是d3.json与.php文件兼容吗?
https://github.com/mbostock/d3/wiki/Requests#convenience-methods