function LineChart(data, {
title,
defined,
curve = d3.curveLinear,
marginTop = 20,
marginRight = 30,
marginBottom = 30,
marginLeft = 40,
width = 640,
height = 400,
xType = d3.scaleUtc,
xDomain,
xRange = [marginLeft, width - marginRight],
yType = d3.scaleLinear,
yDomain,
yRange = [height - marginBottom, marginTop],
yFormat,
yLabel,
zDomain,
color = "currentColor",
strokeLinecap,
strokeLinejoin,
strokeWidth = 1.5,
strokeOpacity,
mixBlendMode = "multiply",
voronoi
} = {}) {
xDomain = [-1, 4]
yDomain = [0, 1];
// Construct scales and axes.
const xScale = xType(xDomain, xRange);
const yScale = yType(yDomain, yRange);
const xAxis = d3.axisBottom(xScale).ticks(width / 80).tickSizeOuter(0);
const yAxis = d3.axisLeft(yScale).ticks(height / 60, yFormat);
// Compute titles.
const T = title === undefined ? "untitled" : title === null ? null : d3.map(data, title);
// Construct a line generator.
const line = d3.line()
.curve(curve)
.x(d => xScale(d[0]))
.y(d => yScale(d[1]));
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height)
.attr("viewBox", [0, 0, width, height])
.attr("style", "max-width: 100%; height: auto; height: intrinsic;")
svg.append("g")
.attr("transform", `translate(0,${height - marginBottom})`)
.call(xAxis);
svg.append("g")
.attr("transform", `translate(${marginLeft},0)`)
.call(yAxis)
.call(g => g.select(".domain").remove())
.call(g => g.append("text")
.attr("x", -marginLeft)
.attr("y", 10)
.attr("fill", "currentColor")
.attr("text-anchor", "start")
.text(yLabel));
const path = svg.append("g")
.attr("fill", "none")
.attr("stroke", typeof color === "string" ? color : null)
.attr("stroke-linecap", strokeLinecap)
.attr("stroke-linejoin", strokeLinejoin)
.attr("stroke-width", strokeWidth)
.attr("stroke-opacity", strokeOpacity)
.selectAll("path")
.data(data)
.join("path")
.style("mix-blend-mode", mixBlendMode)
.attr("d", d => line([[0, 0], [d.value - .2, 0], [d.value, d.weight], [d.value + .2, 0], [4, 0]]))
.attr("title", title)
return Object.assign(svg.node(), {value: null});
}