D3: svg, path, d3.selectAll, .style: Sketch and Fill Triangle

nick3499
nick3499
Feb 25, 2017 · 1 min read
path_triangle.html

<svg width="720" height="120"> sets canvas size. <path d="M 10 10 L 310 10 L 160 110 Z"/> in path mini-language, means: M 10 10 moves starting point to (x=10, y=10). L 310 10 draws line from (10,10) to (310,10). L 160 10 draws line from (310,10) to (160,110). Z closes path to complete triangular shape. Finally, d3.selectAll('path').style('fill', 'darkkhaki'); fills the triangle with the HTML color darkkhaki.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade