function randomColor() { var cores = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728', '#9467bd', '#8c564b', '#e377c2', '#7f7f7f', '#bcbd22', '#17becf']; return cores[Math.floor(Math.random()*cores.length)]; } document.addEventListener("DOMContentLoaded", function() { var keywords = [{"text":"Bolivia","size":8},{"text":"Independencia judicial","size":3},{"text":"pluralismo jur\u00eddico","size":2},{"text":"filosof\u00eda del derecho","size":2},{"text":"constituci\u00f3n","size":2},{"text":"Kafka","size":2},{"text":"derecho civil","size":2},{"text":"derecho","size":2},{"text":"Tribunal Constitucional","size":2},{"text":"Elecciones judiciales","size":2},{"text":"literatura","size":2},{"text":"arbitraje de inversiones","size":2},{"text":"principio del inter\u00e9s superior del ni\u00f1o","size":2},{"text":"interpretaci\u00f3n","size":2},{"text":"positivismo jur\u00eddico","size":2},{"text":"Derecho al aborto","size":2},{"text":"justicia","size":2},{"text":"cultura de paz","size":1},{"text":"Arbitrabilidad objetiva","size":1},{"text":"condiciones de compatibiliad","size":1},{"text":"justicia restaurativa","size":1},{"text":"persecuci\u00f3n penal p\u00fablica","size":1},{"text":"principios esenciales del arbitraje","size":1},{"text":"arbitraje boliviano","size":1},{"text":"arbitraje comercial","size":1},{"text":"principio de ultima ratio","size":1},{"text":"contratos administrativos","size":1},{"text":"Procedimiento arbitral","size":1},{"text":"principio de oportunidad","size":1},{"text":"Presidencialismo","size":1},{"text":"Medios Alternativos de Soluci\u00f3n de Conflictos","size":1},{"text":"mora","size":1},{"text":"valle","size":1},{"text":"parajurisdicci\u00f3n","size":1},{"text":"resarcimiento","size":1},{"text":"perjuicios","size":1},{"text":"acreedor","size":1},{"text":"lucro cesante","size":1},{"text":"da\u00f1o emergente","size":1},{"text":"intereses","size":1},{"text":"MASC","size":1},{"text":"principio nominalista","size":1},{"text":"dinero","size":1},{"text":"cumplimiento obligaciones pecuniarias","size":1},{"text":"retraso","size":1},{"text":"actos propios","size":1},{"text":"responsabilidad","size":1},{"text":"C\u00f3digo Civil","size":1},{"text":"deudor","size":1},{"text":"sede del arbitraje","size":1}]; var totalWeight = 0; var width = 300; var height = 200; var transitionDuration = 200; var length_keywords = keywords.length; var layout = d3.layout.cloud(); layout.size([width, height]) .words(keywords) .fontSize(function(d) { return fontSize(+d.size); }) .on('end', draw); var svg = d3.select("#wordcloud").append("svg") .attr("viewBox", "0 0 " + width + " " + height) .attr("width", '100%'); function update() { var words = layout.words(); fontSize = d3.scaleLinear().range([16, 34]); if (words.length) { fontSize.domain([+words[words.length - 1].size || 1, +words[0].size]); } } keywords.forEach(function(item,index){totalWeight += item.size;}); update(); function draw(words, bounds) { var w = layout.size()[0], h = layout.size()[1]; scaling = bounds ? Math.min( w / Math.abs(bounds[1].x - w / 2), w / Math.abs(bounds[0].x - w / 2), h / Math.abs(bounds[1].y - h / 2), h / Math.abs(bounds[0].y - h / 2), ) / 2 : 1; svg .append("g") .attr( "transform", "translate(" + [w >> 1, h >> 1] + ")scale(" + scaling + ")", ) .selectAll("text") .data(words) .enter().append("text") .style("font-size", function(d) { return d.size + "px"; }) .style("font-family", 'serif') .style("fill", randomColor) .style('cursor', 'pointer') .style('opacity', 0.7) .attr('class', 'keyword') .attr("text-anchor", "middle") .attr("transform", function(d) { return "translate(" + [d.x, d.y] + ")rotate(" + d.rotate + ")"; }) .text(function(d) { return d.text; }) .on("click", function(d, i){ window.location = "https://lawreview.ucb.edu.bo/a/search?query=QUERY_SLUG".replace(/QUERY_SLUG/, encodeURIComponent(''+d.text+'')); }) .on("mouseover", function(d, i) { d3.select(this).transition() .duration(transitionDuration) .style('font-size',function(d) { return (d.size + 3) + "px"; }) .style('opacity', 1); }) .on("mouseout", function(d, i) { d3.select(this).transition() .duration(transitionDuration) .style('font-size',function(d) { return d.size + "px"; }) .style('opacity', 0.7); }) .on('resize', function() { update() }); } layout.start(); });