{
const width = 1280;
const height = 720;
const root = htl.html`<svg viewBox="0 0 ${width} ${height}"></svg>`;
const svg = d3.select(root);
const rect = svg
.append("rect")
.attr("x", "0")
.attr("y", "0")
.attr("width", `${width}`)
.attr("height", `${height}`)
.attr("fill", `#EFEFEF`);
const dataHorizontal = [
{ x: 0, y: 0 },
{ x: 1280, y: 0 }
];
const pathVal = d3
.line()
.x((d) => d.x)
.y((d) => d.y)(dataHorizontal);
const index1 = [1, 2, 3];
const index2 = [4, 5, 6, 7, 8, 9, 10, 11];
const multiplier = 60;
svg
.selectAll("path.index1")
.data(index1)
.join("path")
.classed("index1", true)
.attr("class", (d) => `ln${d}`)
.attr("d", pathVal)
.attr("stroke", () => {
return `hsla(${Math.random() * 360} , ${(
(Math.random() + Math.random() / 2) *
100
).toFixed(2)}%, 50%, 1)`;
})
.style("transform", (d, i) => {
return `translateY(${d * multiplier}px)`;
})
.attr("stroke-width", "2");
svg
.selectAll("path.index2")
.data(index2)
.join("path")
.classed("index2", true)
.attr("class", (d) => `ln${d}`)
.attr("d", pathVal)
.attr("stroke", () => {
return `hsla(${Math.random() * 360} , ${(
(Math.random() + Math.random() / 2) *
100
).toFixed(2)}%, 50%, 1)`;
})
.style("transform", (d, i) => {
return `translateY(${d * multiplier}px)`;
})
.attr("stroke-width", "2");
return root;
}