score:1

If you really need to you can use d3 in node but because node does not have DOM you need jsdom. An example can be found here.

const jsdom = require('jsdom');
const d3 = require("d3");

const setEnv = () =>
  new Promise(
    (resolve,reject)=>
      jsdom.env({
        html:'',
        features:{ QuerySelector:true }, //you need query selector for D3 to work
        done:(errors, window)=>
          errors
            ? reject(errors)
            : resolve(window)
      })
  );

function render(graph) {
  return setEnv()
  .then(
    window=>{
      window.d3 = d3.select(window.document); //get d3 into the dom
      const svg = window.d3.select("svg");

      graph.vertices.forEach(function (v) {
        svg.append("circle")
          .attr("id", v.index)
          .attr("cx", v.x)
          .attr("cy", v.y)
          .attr("radius", v.radius)
          .attr("title", "Fill info in with callback")
      });
      return window.d3.select('svg').html();    
    }
  )
}

Related Query