I am new to crossfilter and am trying to "count" the number of elements at each location (LatLng) and then use this as the radius for my d3 circles:
d3.tsv("DH_Doigv2.tsv", function (data) {
var ndx = crossfilter(data);
var all = ndx.groupAll();
dc.dataCount(".dc-data-count")
.dimension(ndx)
.group(all);
data.forEach(function (d) {
d.year = +d.Date
d.id = d.Item;
d.LatLng = new L.LatLng(+d.SoundLat, +d.SoundLon);
});
var stateCount = ndx.dimension(function (d) {return d.LatLng;});
var stateCountGroup = stateCount.group();
var dataTablesm = dc.dataTable("#data-table-sm");
var allDim = ndx.dimension(function(d) {return d;});
var feature = g.selectAll("circle")
.data(data)
.enter().append("circle")
.style("stroke", "black")
.style("opacity", .6)
.style("fill", "red")
.attr("r", function(d) {
console.log(stateCountGroup.all().value);
return stateCountGroup.all()[d].value*5; })
.attr("transform", function(d){
//console.log(d.values[0].LatLng, d.values.length);
var coor = map.latLngToLayerPoint(d.LatLng);
return "translate(" +
coor.x + "," +
coor.y + ")";
})
But I am getting an "undefined" message as well as "TypeError: stateCountGroup.all(...)[d] is undefined" in the console. This is supposed to be a d3 layer over a Leaflet map. Ultimately, I'd like to be able to click on the circle and have another area display only those particular items (jpeg) like this: http://photogrammar.yale.edu/labs/crossfilter/california/ although I am not using a chloropleth rather I'm using a Leaflet map like this: https://github.com/austinlyons/dcjs-leaflet-untappd Where he has the data table driving everything, I'd like to have the map driving everything.
Related to this question: Not all d3 points are showing in correct position on leaflet map