• 顶会热词统计


    顶会热词统计

    代码:

    <script>

            var chart = echarts.init(document.getElementById('main'));

            var postURL = "/Diploma/getData";

            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].keyword;

                    d['value'] = dataList[i].value;

                    mydata.push(d);

                }

            });

            $.ajaxSettings.async = true;

            var option = {

                tooltip : {},

                series : [ {

                    type : 'wordCloud',

                    gridSize : 2,

                    sizeRange : [ 20, 50 ],

                    rotationRange : [ -90, 90 ],

                    shape : 'pentagon',

                    width : 800,

                    height : 600,

                    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 = "getDiplomaLink?keyword=" + params.keyword;

                window.location.href = url;

            });

    </script>

    package com.me.servlet;

    import java.io.IOException;

    import java.sql.SQLException;

    import java.util.ArrayList;

    import java.util.List;

    import javax.servlet.ServletException;

    import javax.servlet.annotation.WebServlet;

    import javax.servlet.http.HttpServlet;

    import javax.servlet.http.HttpServletRequest;

    import javax.servlet.http.HttpServletResponse;

    import com.google.gson.Gson;

    import com.me.dao.LWDao;

    import com.me.domain.LunWen;

    import com.me.domain.Tu;

    @WebServlet("/PaperServlet_")

    public class PaperServlet_ extends HttpServlet {

        private static final long serialVersionUID = 1L;

          

        public PaperServlet_() {

            super();

        }

        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

            response.setHeader("content-type", "text/html;charset=UTF-8");

            response.setCharacterEncoding("UTF-8");

            LWDao dao = new LWDao();

            List<LunWen> list = new ArrayList<LunWen>();

            List<Tu> list_tu = new ArrayList<Tu>();

            String [] str = new String[10000];

            String [] str_ = new String[10000];

            int [] b = new int[10000];

            int num = 0;

            int length1 = 0;

            try {

                list = dao.search_();

            } catch (SQLException e) {

                e.printStackTrace();

            }

            for(int i=0;i<list.size();i++) {

                if(list.get(i).getLianjie()!=null) {

                    String ss = list.get(i).getLianjie().substring(6,list.get(i).getLianjie().length());

                    list.get(i).setLianjie("http://openaccess.thecvf.com/"+ss);

                }

                String[] split = list.get(i).getGuanjian().split(" ");

                for(int j=0;j<split.length;j++) {

                    str[num++] = split[j];

                }

            }

            for(int k=0;k<num;k++) {

                b[k]=0;

            }

            str_[0]=str[0];

            int tt=1;

            Boolean rt=true;

            for(int i=1;i<num;i++) {

                rt=false;

                for(int j=0;j<tt;j++) {

                    if(str[i].equals(str_[j])) {

                        rt=true;

                        break;

                    }

                }

                if(!rt) {

                    str_[tt]=str[i];

                    tt++;

                }

            }

            length1=tt;

            for(int i=0;i<length1;i++) {

                for(int j=0;j<num;j++) {

                    if(str_[i].equals(str[j])) {

                        b[i]++;

                    }

                }

            }

            int t3=0;

            int t2=0;

            String sr="";

            for(int i=0;i<length1-1;i++) {

                t3=i;

                for(int j=i+1;j<length1;j++) {

                    if(b[t3]<b[j]) {

                        t3=j;

                    }

                }

               if(t3!=i) {

                   t2=b[i];

                   b[i]=b[t3];

                   b[t3]=t2;

                   sr=str_[i];

                   str_[i]=str_[t3];

                   str_[t3]=sr;

               }

            }

            for(int i=0;i<100;i++) {

                Tu tu = new Tu();

                tu.name=str_[i];

                tu.value= b[i];

                list_tu.add(tu);

            }

           

            Gson gson = new Gson();

            String json = gson.toJson(list_tu);

            response.getWriter().write(json);

        }

       

        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

            // TODO Auto-generated method stub

            doGet(request, response);

        }

    }

    <%@ page language="java" contentType="text/html; charset=UTF-8"

        pageEncoding="UTF-8"%>

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

    <!DOCTYPE html>

    <html>

    <head>

    <meta charset="UTF-8">

    <title>Insert title here</title>

    <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />

    <script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>

    <script type="text/javascript" src="js/echarts.min.js"></script>

    <script type="text/javascript" src="js/china.js"></script>

    <script src="js/bootstrap.min.js" type="text/javascript"></script>

    <script src='https://cdn.bootcss.com/echarts/3.7.0/echarts.simple.js'></script>

    <script src='js/echarts-wordcloud.js'></script>

    </head>

    <body>

    <div id="main" style=" 100%;height: 400px"></div>

    <div>

      <table class="table" style=" 100%;align-content: center;" >

        <tr>

          <th align="center">论文连接</th>

        </tr>

        <c:forEach var="item" items="${list}">

          <tr>

            <td><a href="${item.lianjie }">${item.title}</a></td>

          </tr>

        </c:forEach>

      </table>

    </div>

    <script>

      var chart = echarts.init(document.getElementById('main'));

      var dt;

      $.ajax({

        url : "PaperServlet_",

        async : false,

        type : "POST",

        success : function(data) {

          dt = data;

         // alert(dt[0].title);

        },

        error : function() {

          alert("请求失败");

        },

        dataType : "json"

      });

      var mydata = new Array(0);

      for (var i = 0; i < dt.length; i++) {

          var d = {};

         

          d["name"] = dt[i].name;

          //alert(dt[i].name);

          d["value"] = dt[i].value;

          mydata.push(d);

      }

      var option = {

        tooltip: {},

        series: [ {

          type: 'wordCloud',

          gridSize: 2,

          sizeRange: [20, 50],

          rotationRange: [-90, 90],

          shape: 'pentagon',

          600,

          height: 300,

          drawOutOfBound: true,

          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?geunjian=" + params.name;

          window.location.href = url;

        });

      window.onresize = chart.resize;

    </script>

    </body>

    </html>

    截图:

  • 相关阅读:
    GTK+ 3.6.2 发布,小的 bug 修复版本
    RunJS 新增 Echo Ajax 测试功能
    Mozilla 发布 Popcorn Maker,在线创作视频
    Sina微博OAuth2框架解密
    Mina状态机State Machine
    Mozilla 发布 Shumway —— 纯JS的SWF解析器
    Code Browser 4.5 发布,代码浏览器
    ROSA 2012 "Enterprise Linux Server" 发布
    ltrace 0.7.0 发布,程序调试工具
    Artifactory 2.6.5 发布,Maven 扩展工具
  • 原文地址:https://www.cnblogs.com/--lzx1--/p/13237870.html
Copyright © 2020-2023  润新知