Built with blockbuilder.org
xxxxxxxxxx
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
var width = 600, height = 400, opacity = 0.5;
var cubicPath = "M20,20 C300,200 100,500 400,100";
var quadPath = "M200,20 Q100,300 500,100";
var cValues = "M20,20 C300,200 100,500 400,100";
var qValues = "M200,20 Q100,300 500,100";
var fontSizeC = "24";
var fontSizeQ = "18";
var textC = "follows the curve from one side";
var textQ = "follows the curve from the other side";
var fillColors = ["red", "blue", "green", "yellow"];
//svg container
var svgContainer = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var defs = svgContainer.append("svg:defs");
var patternC = defs.append("svg:path")
.attr("id", "pathInfoC")
.attr("d", cValues);
var patternQ = defs.append("svg:path")
.attr("id", "pathInfoQ")
.attr("d", qValues);
//now add the 'g' element
var g1 = svgContainer.append("svg:g");
//create the cubic curve
var bezierC = g1.append("path")
.attr("d", cubicPath)
.attr("fill", fillColors[0])
.attr("stroke", "blue")
.attr("stroke-width", 2);
//text for the cubic
var textC = g1.append("text")
.attr("id", "textStyleC")
.attr("stroke", "blue")
.attr("fill", fillColors[1])
.attr("stroke-width", 2)
.append("textPath")
.attr("font-size", fontSizeC)
.attr("xlink:href", "#pathInfoC")
.text(textC);
//create the quadratic curve
var bezierQ = g1.append("path")
.attr("d", quadPath)
.attr("fill", fillColors[1])
.attr("opacity", opacity)
.attr("stroke", "blue")
.attr("stroke-width", 2);
//text for the quad curve
var textQ = g1.append("text")
.attr("id", "textStyleQ")
.attr("stroke", fillColors[3])
.attr("stroke-width", 2)
.append("textPath")
.attr("font-size", fontSizeQ)
.attr("xlink:href", "#pathInfoQ")
.text(textQ);
</script>
</body>
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js