热词云,经过查资料后写出
<script> var chart = echarts.init(document.getElementById('main')); var postURL = "/lunwen/ShowServlet"; var mydata = new Array(); $.ajaxSettings.async = false; $.post(postURL, {}, function(rs) { var dataList = JSON.parse(rs); for (var i = 0; i < dataList.length; i++) { var d = {}; d['name'] = dataList[i].name; d['value'] = dataList[i].value; mydata.push(d); } }); $.ajaxSettings.async = true; var option = { tooltip : {}, series : [ { type : 'wordCloud', gridSize : 5, sizeRange : [ 20, 40 ], rotationRange : [ -90, 90 ], shape : 'pentagon', width : 20000, height : 12000, drawOutOfBound : false, textStyle : { normal : { color : function() { return 'rgb(' + [ Math.round(Math.random() * 160), Math.round(Math.random() * 160), Math.round(Math.random() * 160) ] .join(',') + ')'; } }, emphasis : { shadowBlur : 10, shadowColor : '#333' } }, data : mydata } ] }; chart.setOption(option); chart.on('click', function(params) { var url = "ClickServlet?name=" + params.name; window.location.href = url; }); </script>