Built with blockbuilder.org
forked from anonymous's block: fresh block
forked from anonymous's block: fresh block
forked from anonymous's block: fresh block
forked from anonymous's block: fresh block
forked from anonymous's block: sin wave
xxxxxxxxxx
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="d3-scale-radial.js"></script>
<style>
body {
margin:0;
position:fixed;
top:0;
right:0;
bottom:0;
left:0;
}
#chart-1 {
margin: 40px;
}
.line {
fill: none;
}
</style>
</head>
<body>
<script>
var margin = {top: 40, right: 40, bottom: 40, left: 40},
width = window.innerWidth - margin.left - margin.right,
height = window.innerHeight - margin.top - margin.bottom,
fullwidth = window.innerWidth,
fullheight = window.innerHeight;
var x = d3.scaleLinear()
.range([0, width]);
var y = d3.scaleRadial()
.range([height, 0]);
var chart = d3.select("body")
.append("div")
.attr("class", "chart")
.style("background-color", "lightgrey")
var data = d3.range(40).map(function(i) {
return {x: i / 39, y: (Math.sin(i / 3) + 2) / 4};
});
var line = d3.line()
.defined(function(d) { return d; })
.x(function(d){ return x(d.x); })
.y(function(d){ return y(d.y); })
var svg = d3.select(".chart")
.append("svg")
.datum(data)
.attr("id", "chart-1")
.attr("width", fullwidth)
.attr("height", fullheight)
.append("g");
svg.append("path")
.attr("class", "line")
.attr("d", line);
svg.selectAll(".dot")
.data(data.filter(function(d) {return d;}))
.enter().append("circle")
.attr("class", "dot")
.attr("cx", line.x())
.attr("cy", line.y())
.attr("r", 2)
</script>
</body>
https://d3js.org/d3.v4.min.js