{
const width = 800;
const height = 100;
const svg = d3
.create("svg")
.attr("viewBox", [0, 0, width, height])
.attr("width", width)
.attr("height", height);
const exampleData = [1, 2, 3, 4, 5, 6, 7, 8, 9];
const pixelScale = d3.scaleLinear().domain([0, 10]).range([200, 600]);
const parameterScale = d3.scaleLinear().domain([0, 10]).range([0, 1]);
const scaleNames = ["viridis", "magma", "cividis"];
for (let i = 0.25; i <= 0.75; i = i + 0.25) {
svg
.append("line")
.attr("x1", 200)
.attr("y1", height * i)
.attr("x2", 600)
.attr("y2", height * i)
.attr("fill", "none")
.attr("stroke", "black")
.attr("stroke-width", "2");
svg
.append("text")
.attr("x", 190)
.attr("y", height * i)
.style("font-family", "courier")
.style("font-size", 10)
.style("text-anchor", "end")
.style("alignment-baseline", "middle")
.text(scaleNames[i * 4 - 1]);
}
for (let i = 0; i < exampleData.length; i = i + 1) {
const xPosition = pixelScale(exampleData[i]);
const parameterData = parameterScale(exampleData[i]);
svg
.append("circle")
.attr("cx", xPosition)
.attr("cy", height * 0.25)
.attr("r", 10)
.attr("fill", d3.interpolateViridis(parameterData))
.attr("stroke", "black")
.attr("stroke-width", "2");
svg
.append("circle")
.attr("cx", xPosition)
.attr("cy", height * 0.5)
.attr("r", 10)
.attr("fill", d3.interpolateMagma(parameterData))
.attr("stroke", "black")
.attr("stroke-width", "2");
svg
.append("circle")
.attr("cx", xPosition)
.attr("cy", height * 0.75)
.attr("r", 10)
.attr("fill", d3.interpolateCividis(parameterData))
.attr("stroke", "black")
.attr("stroke-width", "2");
}
return svg.node();
}