Skip to content

Instantly share code, notes, and snippets.

@dpfrakes
Last active June 1, 2018 06:14
Show Gist options
  • Save dpfrakes/a26d45858f5bb7f8a48296be0eeaa884 to your computer and use it in GitHub Desktop.
Save dpfrakes/a26d45858f5bb7f8a48296be0eeaa884 to your computer and use it in GitHub Desktop.
testing html canvas gist embed
<svg></svg>
<script>
var height = 400;
var width = 800;
function fn(x) {
return (x * 0.1) * Math.sin(x / 8);
}
function F(x) {
return height / 2 + -(fn(x));
}
var domain = [...Array(width).keys()];
var lineFunction = d3.line()
.x(function(x) { return x; })
.y(function(x) { return F(x); })
.curve(d3.curveLinear);
//The SVG Container
var svgContainer = d3.select("svg")
.attr("width", width)
.attr("height", height);
//The line SVG Path we draw
var lineGraph = svgContainer.append("path")
.attr("d", lineFunction(domain))
.attr("stroke", "blue")
.attr("stroke-width", 1)
.attr("fill", "none");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment