我有三个要在Crossfilter上过滤的图表。基本上,当我在图表上进行过滤时,这些功能也在我的传单地图上进行过滤。
var markersLayer = new L.LayerGroup();
xdata = crossfilter(data);
all = xdata.groupAll();
dataCount.dimension(xdata)
.group(all);
var cities = xdata.dimension(function (d) { return d.City; });
var districttype = xdata.dimension(function (d) { return d.district; });
var allDim = xdata.dimension(function(d) {return d;});
...........
typeChart.on("filtered", function (chart, filter) {
//console.log('11111111111');
//console.log(locations.top(Infinity));
updateMap(locations.top(Infinity));
});
dc.renderAll();
// Called when dc.js is filtered (typically from user click interaction)
var onFilt = function(chart, filter) {
console.log('fffff');
updateMap(locations.top(Infinity));
};
citiesChart.on("filtered", function (chart, filter) {
//console.log('11111111111');
//console.log(locations.top(Infinity));
updateMap(locations.top(Infinity));
});
dc.renderAll();
// Called when dc.js is filtered (typically from user click interaction)
var onFilt = function(chart, filter) {
console.log('fffff');
updateMap(locations.top(Infinity));
};
districtChart.on("filtered", function (chart, filter) {
//console.log('11111111111');
//console.log(locations.top(Infinity));
updateMap(locations.top(Infinity));
});
dc.renderAll();
// Called when dc.js is filtered (typically from user click interaction)
var onFilt = function(chart, filter) {
console.log('fffff');
updateMap(locations.top(Infinity));
};
});
我希望传单可以根据图表的过滤方式放大地图。在脚本的结尾,我将其添加为缩放功能。
markersLayer.clearLayers();
allDim.top(Infinity).forEach(function (d) {
var marker = L.marker([d.latitude, d.longitude]);
markersLayer.addLayer(marker);
});
map.addLayer(markersLayer);
map.fitBounds(markersLayer.getBounds());
dc.renderAll();
错误:未捕获ReferenceError:未定义allDim
我有两个问题。我收到此错误代码,因为AllDim在我的RenderAll函数之前。但是,如果我将我的getbound函数放在过滤函数之前,则图表将不再显示。反正要解决这个问题?
第二,这是在跨滤镜上使用获取范围进行缩放的正确方法吗?我找不到使用此功能的任何良好示例。