Skip to content

Instantly share code, notes, and snippets.

Last active Jan 2, 2016
What would you like to do?
Creating a basic app prototype using SVG and d3.js
<!DOCTYPE html>
<meta charset="utf-8">
body {
width: 960px;
padding-top: 40px;
margin: auto;
position: relative;
svg {
width: 100%;
max-height: 400px;
<script src="" charset="utf-8"></script>
<script type='text/javascript'>
window.addEventListener('load', function () {
d3.xml('iPhone.svg', 'image/svg+xml', function (error, data) {'body').node().appendChild(data.documentElement);
var svg ='svg');
var appScreen ='#ScreenBackground');
var screenWidth = +appScreen.attr('width'),
screenHeight = +appScreen.attr('height');
var appButton ='#AppButton')
.on('mouseenter', function () {'fill', '#AB69C6');
.on('mouseleave', function () {'fill', '#9B59B6')
.on('click', function () {
var x = Math.random() * screenWidth;
var y = Math.random() * screenHeight;
.attr('cx', x)
.attr('cy', y);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment