1

I am making cartographic visualisation in D3 with topoJson. I have visualised cities as points with a given radius. However, I want to see this attribute based on how many values I have there (let's say kindergartens in each city) - that is for Glasgow 57, Dundee 26.

enter image description here

So I just need to count how many arrays are there in the values. I have searched but have not found any suitable solution.

        enterSelection
           .append("circle")
           .attr("r", 4);

EDIT: Need to update the 4 in the code below. If I am using tip given in comments, it gives me only the radius in the size of the array of the specific city (but I need different radius for each city) Tried to change attribute to

.attr("r", d=>(d.town.values.length))

but that gives me Uncaught TypeError: Cannot read property 'values' of undefined error

mrakoplas
  • 94
  • 8

1 Answers1

-2

This is the solution that worked.

enterSelection
                .append("circle")
                .attr("r", d => d.values.length)
mrakoplas
  • 94
  • 8