Create an exportable table of results from a dice roll.
Last active
December 13, 2016 12:01
-
-
Save chooban/34a007f1b7d474e88a254720d444e7ce to your computer and use it in GitHub Desktop.
Dice result table generator
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> | |
<meta charset="utf-8"> | |
<style> | |
</style> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js"></script> | |
<script> | |
var dice = [ | |
"d4", | |
"d6", | |
"d10", | |
"d12", | |
"d20", | |
"d100" | |
]; | |
var root = d3.select('body').append('div').classed('roller', true); | |
var controlsContainer = root.append('div').classed('controls', true), | |
controlsFieldSet = controlsContainer.append('fieldset'); | |
controlsFieldSet.append('label').attr('for', 'diceselect').text('Dice'); | |
var diceSelect = controlsFieldSet.append('select').attr('id', 'diceselect'); | |
var options = diceSelect.selectAll('option').data(dice); | |
options.enter() | |
.append('option') | |
.attr('value', function(d) { return d; }) | |
.text(function(d) { return d;} ); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment