JSFiddle - React, Tailwind, and code Playground

by IPWright83

HTML

<svg width="200" height="200">
  <circle></circle>
</svg>

JavaScript

function A() {
	const local = d3.local();
  
  d3.select("circle")
    .attr("r", 50)
    .attr("cx", 50)
    .attr("cy", 50)
    .style("fill", "red")
    .each(function(d) {
    	local.set(this, "foo");
    })
    
    console.log(local.toString());
}

function B() {
	const local = d3.local();
  
  console.log(local.toString());
  
  d3.select("circle")
    .transition()
    .duration(500)
    .attr("r", 20)
    .attr("cx", 150)
    .attr("cy", 150)
    .style("fill", "blue")
    .each(function(d) {
    	console.log(this["@1"]);
    	console.log(local.get(this));
    })
}

A();
B();