chart = {
const svg = d3
.create("svg")
.attr("width", width)
.attr("height", height);
const lg = svg
.append("defs")
.append("linearGradient")
.attr("id", `mygrad-${inputs.id}`)
.attr("x1", "0%")
.attr("x2", "0%")
.attr("y1", "0%")
.attr("y2", "100%");
lg.append("stop")
.attr("offset", "0%")
.style("stop-color", inputs.areaColor)
.style("stop-opacity", 0);
lg.append("stop")
.attr("offset", "100%")
.style("stop-color", inputs.areaColor)
.style("stop-opacity", 0);
svg
.append("path")
.datum(data)
.style("fill", `url(#mygrad-${inputs.id})`)
.attr("d", area);
svg
.append("path")
.datum(data)
.attr("fill", "none")
.attr("stroke", inputs.color)
.attr("stroke-width", 2)
.attr("stroke-linejoin", "round")
.attr("stroke-linecap", "round")
.attr("d", line);
if (inputs.mark) {
svg
.append('line')
.classed('y', true)
.attr('x1', x(d3.timeParse("%Y-%m-%d")(inputs.mark)))
.attr('x2', x(d3.timeParse("%Y-%m-%d")(inputs.mark)))
.attr('y1', margin.top)
.attr('y2', height - margin.bottom)
.attr("stroke", "rgba(255,0,0,0.25)")
.attr("stroke-width", "5px")
.style('fill', 'none');
if (inputs.markText) {
svg
.append('text')
.attr('x', x(d3.timeParse("%Y-%m-%d")(inputs.mark)) + 5)
.attr('y', margin.top)
.text(inputs.markText);
}
}
svg.append("g").call(xAxis);
svg.append("g").call(yAxis);
return svg.node();
}