Last active
September 18, 2015 01:43
-
-
Save Nastasi7/7140a159734c2c0e2ea1 to your computer and use it in GitHub Desktop.
fresh block
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
<!DOCTYPE html> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
svg { width: 100%; height: 100%} | |
</style> | |
</head> | |
<body> | |
<svg> | |
<rect | |
x=100 | |
y=133 | |
width=100 | |
height=100 | |
fill=red | |
stroke=black | |
></rect> | |
<circle | |
cx=400 | |
cy=133 | |
r=100 | |
width=100 | |
height=100 | |
fill=orange | |
stroke=black | |
></circle> | |
</svg> | |
<script> | |
var MyData= [ | |
50, | |
100, | |
423, | |
250, | |
175] | |
var svg=d3.select("svg") | |
svg.append("rect") | |
.attr({ | |
x: 100, | |
y: 300, | |
width: 100, | |
height: 100, | |
fill: "blue", }) | |
var rects= svg.selectAll("rect") | |
.data(MyData) | |
rects.enter() | |
.append("rect") | |
.attr({fill: "green",}) | |
rects.attr({ | |
x: function(d, i) { return i * 200; }, | |
y: function(d) { return 500 - d; }, | |
width: 100, | |
height: function(d, i) { return i; }, | |
fill: "Blue" | |
}); | |
</script> | |
</body> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment