Skip to content

Instantly share code, notes, and snippets.

@brandenbyers
Last active August 29, 2015 14:14
Show Gist options
  • Save brandenbyers/01f33ee4a181a53cf707 to your computer and use it in GitHub Desktop.
Save brandenbyers/01f33ee4a181a53cf707 to your computer and use it in GitHub Desktop.
Dapper D3
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
width: 960px;
padding-top: 40px;
margin: auto;
position: relative;
}
svg {
width: 100%;
max-height: 400px;
}
</style>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script type='text/javascript'>
window.addEventListener('load', function () {
d3.xml('dapperFace.svg', 'image/svg+xml', function (error, data) {
d3.select('body').node().appendChild(data.documentElement);
var svg = d3.select('svg');
var face = svg.select('#dapperFace');
var mustache = svg.select('#mustache')
.on('mouseenter', function () {
mustache.style('fill', '#AB69C6');
})
.on('mouseleave', function () {
mustache.style('fill', '#000000')
})
// .on('click', function () {
// mustache
// .transition()
// .duration(1000)
// .ease('bounce')
// });
// var eyebrowR = svg.select('#eyebrowR')
// .on('click', function() {
// eyebrowR
// .
// })
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment