D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
biovisualize
Full window
Github gist
Générateur de noms de villages français
<html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script> </head> <body> <div id="display"></div> <script> var start = ['peu', 'prou', 'fil', 'né', 'che', 'mir', 'tré', 'cor', 'fèri', 'mol', 'fente', 'chon', 'plume', 'mériè', 'mis', 'motte', 'saint-', 'bi', 'glu']; var middle = ['an', 'fouin', 'fu', 'mer', 'tran', 'chon', 'né', 'nal', 'pan', '-en-', ' de ', 'mu', '-sur-', ' ', '-', 'os', 'flu', 'sou', 'poin', 'ral', 'cli', 'moule']; var end = ['net', 'pou', 'fru', 'patte', 'potte', 'tru', 'dié', 'pel', 'let', 'bru', 'tulle', 'mine', 'ac', 'oy', 'foute', 'puy', 'bran', 'ière', '-les-bains', 'gnolles', 'diou', 'ouet', 'erie', 'flet', 'tandre', 'dieu', 'ouille', 'onde', 'el', 'aille']; function rnd(d){ return d[~~(Math.random()*d.length)]; } function rndRepeat(d){ var n = ~~(Math.random()*3); console.log(n); return d3.range(n).map(function(){ return d[~~(Math.random()*d.length)];}).join(''); } var display = d3.select('#display'); var button = display.append('button') button.text('generate') .style({ position: 'relative', top: '10px' }); button.on('click', generate); var wordContainer = display.append('div') wordContainer.style({ position: 'relative', left: '10px', top: '10px', 'text-transform': 'capitalize' }); generate(); function generate(){ var word = rnd(start)+''+rndRepeat(middle)+''+rnd(end); wordContainer.html(word); } </script> </body> </html>
https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js