Can you set path.pointRadius with a function in d3js v4?

Can you set path.pointRadius with a function in d3js v4?
0

#1

I am working on the Map Data Across The Globe project, but I am having trouble sizing the circles that represent where the meteorites have fallen.
Specifically, can you set the path.pointRadius with a function? If so, how. this is what I have tried:

var projection = d3.geoMercator()
  .center([8, 0 ])
  .scale(100)
  .rotate([0,0]);

var path = d3.geoPath().projection(projection);

  svg.append("path")
      .datum(meteoriteData)
      .attr("d", path)
      .attr('d', (d) => path.pointRadius(d.r));

Thanks


#2

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

That looks right to me. What errors are you getting?


#3

Thank you PortableStick,

When I set path.pointRadius explicitly like this:
.attr("d", path.pointRadius(30))
the circles are all displayed at the specified size, however, when I try to set it based on the selection’s data with a function, the circles are not displayed at all and I receive the following error:

<path> attribute d: Expected moveto path command ('M' or 'm'), "function e(t){re…".