D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
aaizemberg
Full window
Github gist
probando parte del d3-jetpack de Gregor Aisch
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>probando parte del d3-jetpack de Gregor Aisch</title> <script src="//cdnjs.cloudflare.com/ajax/libs/d3/4.2.3/d3.min.js"></script> </head> <body> <h1>Probando parte del <a href="https://github.com/gka/d3-jetpack">d3-jetpack</a></h1> <script> // tomado de: https://github.com/gka/d3-jetpack // // Gregor Aisch // https://github.com/gka // https://twitter.com/driven_by_data // https://driven-by-data.net/ // // combines data().enter().append() d3.selection.prototype.appendMany = function(data, name){ return this.selectAll(name).data(data).enter().append(name); }; d3.round = d3.round || function(n, p) { d = Math.pow(10, p); return Math.round(n * d) / d; }; d3.wordwrap = function(line, maxCharactersPerLine) { var w = line.split(' '), lines = [], words = [], maxChars = maxCharactersPerLine || 40, l = 0; w.forEach(function(d) { if (l+d.length > maxChars) { lines.push(words.join(' ')); words.length = 0; l = 0; } l += d.length; words.push(d); }); if (words.length) { lines.push(words.join(' ')); } return lines; }; // // tomado de: https://github.com/gka/d3-jetpack var texto_word_wrapeado = d3.wordwrap("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum",50); d3.select("body").appendMany(texto_word_wrapeado,'div').text(function(d){return d;}) var numeros_a_redondear = [3.1111,2.222222,1.33333,0.44444444444]; d3.select("body").appendMany(numeros_a_redondear,'h2').text(function(d){return d3.round(d,1);}) </script> </body> </html>
https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.3/d3.min.js