Built with blockbuilder.org
Last active
September 30, 2019 20:47
-
-
Save jwilber/5c09b5fa19f862855e3a52a939a5c011 to your computer and use it in GitHub Desktop.
wired-slider
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
license: mit |
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
<html> | |
<head> | |
<script src="https://unpkg.com/wired-elements@latest/dist/wired-elements.bundled.js"></script> | |
<script src="https://unpkg.com/iamjared@1.0.3"></script> | |
<style> | |
body { | |
margin: 0; | |
padding: 10px; | |
font-family: sans-serif; | |
line-height: 1.5; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="vis0"></div> | |
<wired-slider id="slider"></wired-slider> | |
<div id="label"></div> | |
<p> | |
<wired-button id="btn">Reset</wired-button> | |
</p> | |
<script> | |
const slider = document.getElementById('slider'); | |
const label = document.getElementById('label'); | |
const bar = new roughViz.Bar( | |
{ | |
element: '#vis0', | |
data: 'https://gist.githubusercontent.com/mbostock/3310560/raw/98311dc46685ed02588afdcb69e5fa296febc1eb/letter-frequency.tsv', | |
labels: 'letter', | |
values: 'frequency', | |
height:window.innerHeight * 0.7, | |
width: window.innerWidth * 0.8, | |
roughness: slider.value, | |
color: 'pink', | |
fillWeight: 1, | |
strokeWidth: 0.5, | |
fillStyle: 'cross-hatch', | |
stroke: 'black', | |
} | |
); | |
slider.addEventListener('change', () => { | |
label.textContent = slider.value; | |
console.log('gr', bar.roughness); | |
bar.roughness = slider.value; | |
}); | |
document.getElementById('btn').addEventListener('click', () => { | |
slider.value = 0; | |
label.textContent = slider.value; | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment