score:1

Accepted answer
  1. You need to use commas , when you're setting attributes between the attribute and value just like you did when you declared the width and height of your svg.

  2. For fill, you need to put red inside quotation marks.

This snippet below should work.

var canvas = d3.select("body")
  .append("svg")
  .attr("width", 500)
  .attr("height", 500);

var circle = canvas.append("circle")
  .attr("cx", 250)
  .attr("cy", 250)
  .attr("r", 50)
  .attr("fill", 'red');

JSFIddle - https://jsfiddle.net/3vhudt35/


Related Query