{
const chart = new G2.Chart({
width: 800,
height: 600
});
function isInfinity(v) {
return v === Infinity || v === -Infinity;
}
chart.data(DATA.filter((d) => !isInfinity(d.x) && !isInfinity(d.y)));
chart
.line()
.encode("x", "x")
.encode("y", "y")
.encode("shape", "smooth")
.style("stroke", "#" + Math.floor(Math.random() * 16777215).toString(16))
.style("lineWidth", 2)
.scale("x", { nice: true })
.scale("y", { nice: true })
.axis("x", { title: false })
.axis("y", { title: false })
.tooltip({
title: null,
items: [
{ name: "x", field: "x", valueFormatter: (y) => y.toFixed(2) },
{ name: "y", field: "y", valueFormatter: (y) => y.toFixed(2) }
]
});
chart
.lineY()
.data([0])
.style("stroke", "grey")
.style("lineDash", [3, 3])
.style("arrow", true);
chart
.lineX()
.data([0])
.style("stroke", "grey")
.style("lineDash", [3, 3])
.style("arrow", true);
await chart.render();
return chart.getContainer();
}