JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://nvd3.org/assets/js/nv.d3.js"></script>
<link rel="stylesheet" href="http://nvd3.org/assets/css/nv.d3.css">
<svg id="test1" class="mypiechart"></svg>
CSS
.mypiechart {
width: 500px;
border: 2px;
}
JavaScript
var testdata = [
{
key: "eight two%",
y: 82
},
{
key: "eighteen%",
y: 18
}
];
nv.addGraph(function() {
var width = 500,
height = 500;
var chart = nv.models.pieChart()
.x(function(d) { return d.key })
.y(function(d) { return d.y })
.color(['red','green'])
.width(width)
.height(height);
d3.select("#test1")
.datum(testdata)
.transition().duration(1200)
.attr('width', width)
.attr('height', height)
.call(chart);
var svg = d3.select("#test1");
svg
.append('defs')
.append('pattern')
.attr('id', 'diagonalHatch')
.attr('patternUnits', 'userSpaceOnUse')
.attr('width', 4)
.attr('height', 4)
.append('path')
.attr('d', 'M-1,1 l2,-2 M0,4 l4,-4 M3,5 l2,-2')
.attr('stroke', '#000000')
.attr('stroke-width', 1);
return chart;
});
var svg2 = d3.select("#test1");
var node = svg2.select(".nv-slice path").attr('d');
console.log(node);