Last active
February 6, 2017 04:44
-
-
Save SergProduction/3873207455b0ce488472ed702ed314af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//добавляем svg тег в body | |
var svg = d3.select("body").append("svg"); | |
svg.attr("height", 600) | |
.attr("width", 600) | |
.style('border','1px solid') | |
var data = [ | |
{x: 80, y: 100},{x: 120, y: 100}, | |
{x: 240, y: 200},{x: 280, y: 200} | |
]; | |
// функция, создающая по массиву точек линии | |
var line = d3.line() | |
.x( d => d.x ) | |
.y( d => d.y ) | |
.curve(d3.curveCatmullRom.alpha(1)) | |
// объединяем все линии в путь | |
var path = svg.append("path") | |
.attr("d", line(data)) | |
//ставим кружочки на точках, для наглядности | |
svg.selectAll("circle") | |
.data(data) | |
.enter().append("circle") | |
.attr("r", 3.5) | |
.attr("cx", d => d.x ) | |
.attr("cy", d => d.y ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment