Creating visualizations like this one but using canvas is possible.
Since the Canvas element hasn't got the getTotalLength() method as it exists in SVG, I'm using the point-at-length library, that calculates exactly this.
The library is designed to be used only from nodejs, but using browserify (as in this post), this is not a ptoblem:
browserify index.js --standalone Points > point-at-length.js
In a previous version of the block, I created an SVG element to use the getTotalLength() method, which is much less elegant and can't be used in a nodejs environment.
The library doesn't give an exact value, I'll have to investigate more...
The path is the Trans Mongolian train route taken from here but redrawn, since the original is a multi line.
Modified http://d3js.org/d3.v3.min.js to a secure url
Modified http://d3js.org/topojson.v1.min.js to a secure url
https://d3js.org/d3.v3.min.js
https://d3js.org/topojson.v1.min.js