<html>
<head>
<meta name="description" content="SVG Shape Demo">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://d3js.org/d3.v4.min.js"></script>
<title>CS 424 - D3 examples</title>
</head>
<body>
</body>
</html>
console.log("hello cs24! - SVG Shape Demo");
var body = d3.select("body");
var svg = body.append("svg");
svg.attr("width", "500")
svg.attr("height", "500")
//svg.style("background-color", "rgb(220,220,255)")
svg.append("circle")
.attr("cx", 100)
.attr("cy",100)
.attr("r",50)
.style("fill","red");
svg.append("rect")
.attr("x",30)
.attr("y",30)
.attr("rx",7)
.attr("ry",7)
.attr("width",50)
.attr("height",50)
.attr("stroke","green")
.attr("stroke-width",6)
.attr("opacity",0.5)
.attr("fill","blue");
svg.append("text")
.text("hello")
.attr("x",80)
.attr("y",80)
.attr("font-family", "helvetica")
.attr("font-size", "60px")
.attr("fill", "black")
.attr("transform","rotate(300 80,80)");
svg.append("path")
.attr("d", "M 100 100 q 50 180 100 0")
.attr("stroke-width", 5)
.attr("stroke", "green")
.attr("fill", "orange")
.attr("opacity",0.5)
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |