zoukankan      html  css  js  c++  java
  • 课堂练习之可视化的强化版

    本次任务的主要内容是在之前可以画图的基础上实现疫情数据的爬取和画图。

    效果图:

    源代码:

    1.user.java

     1 package com.yiqin.user;
     2 
     3 
     4 
     5 public class User {
     6 //国家
     7     private String province;
     8     //时间
     9     private String date;
    10     //
    11     private String continents;
    12     //城市
    13     private String city;
    14     //现有人数
    15     private String current;
    16     //累计人数
    17     private String confirmed_num;
    18     //死亡人数
    19     private String dead_num;
    20     //治愈人数
    21     private String cured_num;
    22     //疑似人数
    23     private String suspectnum;
    24     public String getProvince() {
    25         return province;
    26     }
    27     public User(String continents,String province ,String date,String confirmed_num,String dead_num,String cured_num) {
    28         this.province=province;
    29         
    30         this.date=date;
    31         this.cured_num=cured_num;
    32         this.continents=continents;
    33         this.confirmed_num=confirmed_num;
    34         this.dead_num=dead_num;
    35         
    36     }
    37 
    38     public void setProvince(String province) {
    39         this.province = province;
    40     }
    41     public String getDate() {
    42         return date;
    43     }
    44     public void setDate(String date) {
    45         this.date = date;
    46     }
    47     public String getCity() {
    48         return city;
    49     }
    50     public void setCity(String city) {
    51         this.city = city;
    52     }
    53     public String getCurrent() {
    54         return current;
    55     }
    56     public void setCurrent(String current) {
    57         this.current = current;
    58     }
    59     public String getConfirmed_num() {
    60         return confirmed_num;
    61     }
    62     public void setConfirmed_num(String confirmed_num) {
    63         this.confirmed_num = confirmed_num;
    64     }
    65     public String getDead_num() {
    66         return dead_num;
    67     }
    68     public void setDead_num(String dead_num) {
    69         this.dead_num = dead_num;
    70     }
    71     public String getCured_num() {
    72         return cured_num;
    73     }
    74     public void setCured_num(String cured_num) {
    75         this.cured_num = cured_num;
    76     }
    77     public String getSuspectnum() {
    78         return suspectnum;
    79     }
    80     public void setSuspectnum(String suspectnum) {
    81         this.suspectnum = suspectnum;
    82     }
    83     public String getContinents() {
    84         return continents;
    85     }
    86     public void setContinents(String continents) {
    87         this.continents = continents;
    88     }
    89     
    90 }
    View Code

    2.paqu.java

      1 package com.yiqin.paqu;
      2 
      3 
      4 import java.io.BufferedReader;
      5 import java.io.IOException;
      6 import java.io.InputStream;
      7 import java.io.InputStreamReader;
      8 import java.net.MalformedURLException;
      9 import java.net.URL;
     10 import java.security.Timestamp;
     11 import java.sql.Connection;
     12 import java.sql.DriverManager;
     13 import java.sql.SQLException;
     14 import java.sql.Statement;
     15 import java.util.regex.Matcher;
     16 import java.util.regex.Pattern;
     17 
     18 import java.text.SimpleDateFormat;
     19 import java.util.Date;
     20 import java.util.HashMap;
     21 import java.util.Map;
     22 
     23 import javax.net.ssl.HttpsURLConnection;
     24 import javax.xml.crypto.Data;
     25 
     26 import com.alibaba.fastjson.JSONArray;
     27 import com.alibaba.fastjson.JSONObject;
     28 import com.yiqin.connect.BaseConnection;
     29 public class Paqu {
     30     
     31     public static void main(String[] args) throws IOException {
     32                 getListByCountryTypeService2(); 
     33         }
     34     // 鏍筓RL
     35     private static String httpRequset(String requesturl) throws IOException {
     36         StringBuffer buffer = null;
     37         BufferedReader bufferedReader = null;
     38         InputStreamReader inputStreamReader = null;
     39         InputStream inputStream = null;
     40         HttpsURLConnection httpsURLConnection = null;
     41         try {
     42             URL url = new URL(requesturl);
     43             httpsURLConnection = (HttpsURLConnection) url.openConnection();
     44             httpsURLConnection.setDoInput(true);
     45             httpsURLConnection.setRequestMethod("GET");
     46             inputStream = httpsURLConnection.getInputStream();
     47             inputStreamReader = new InputStreamReader(inputStream, "utf-8");
     48             bufferedReader = new BufferedReader(inputStreamReader);
     49             buffer = new StringBuffer();
     50             String str = null;
     51             while ((str = bufferedReader.readLine()) != null) {
     52                 buffer.append(str);
     53             }
     54         } catch (MalformedURLException e) {
     55             // TODO Auto-generated catch block
     56             e.printStackTrace();
     57         }
     58 
     59         return buffer.toString();
     60     }
     61 
     62     /**
     63      * 鑾峰彇鍏ㄥ浗鍚勪釜鐪佸競鐨勭‘璇娿�佹�浜″拰娌绘剤浜烘暟
     64      * 
     65      * @return
     66      */
     67     
     68     public static String getAreaStat() {
     69         String url = "https://ncov.dxy.cn/ncovh5/view/pneumonia";
     70         String htmlResult = "";
     71         try {
     72             htmlResult = httpRequset(url);
     73         } catch (IOException e) {
     74             // TODO Auto-generated catch block
     75             e.printStackTrace();
     76         }
     77         // System.out.println(htmlResult);
     78 
     79         // 姝e垯鑾峰彇鏁版嵁
     80         // 鍥犱负html鐨勬暟鎹�牸寮忕湅鐫�灏卞儚json鏍煎紡锛屾墍浠ユ垜浠��鍒欒幏鍙杍son
     81         String reg = "window.getAreaStat = (.*?)\}(?=catch)";
     82         Pattern totalPattern = Pattern.compile(reg);
     83         Matcher totalMatcher = totalPattern.matcher(htmlResult);
     84 
     85         String result = "";
     86         if (totalMatcher.find()) {
     87             result = totalMatcher.group(1);
     88             System.out.println(result);
     89             // 鍚勪釜鐪佸競鐨勬槸涓�涓�垪琛↙ist锛屽�鏋滄兂淇濆瓨鍒版暟鎹�簱涓�紝瑕侀亶鍘嗙粨鏋滐紝涓嬮潰鏄痙emo
     90             JSONArray array = JSONArray.parseArray(result);
     91             try {
     92                 Connection conn =BaseConnection.getConn();
     93                 Statement stmt = conn.createStatement();
     94 
     95                 Date date = new Date();//鑾峰緱绯荤粺鏃堕棿.
     96                 SimpleDateFormat sdf =   new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss" );
     97                 String nowTime = sdf.format(date);
     98 
     99                 for (int i = 0; i <= 30; i++) {
    100 
    101                     com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject
    102                             .parseObject(array.getString(i));
    103 
    104                 
    105                         String provinceName = jsonObject.getString("provinceName");
    106                         String cityname1 = " ";
    107                         String currentnum = jsonObject.getString("currentConfirmedCount");
    108                         String confirmed = jsonObject.getString("confirmedCount");
    109                         String cured = jsonObject.getString("curedCount");
    110                         String dead = jsonObject.getString("deadCount");
    111                         String suspect = jsonObject.getString("suspectedCount");
    112                         stmt.executeUpdate("insert into info2(Date,Province,City,currentnum,Confirmed_num,Yisi_num,Cured_num,Dead_num) values('"+ nowTime + "','"+ provinceName + "','"+ cityname1+ "','"+currentnum + "','" + confirmed + "','" + suspect +"','" + cured +"','" + dead +"')");
    113                         
    114                         JSONArray array2 = jsonObject.getJSONArray("cities");
    115                         for (int j = 0; j < array2.size(); j++) {
    116                             com.alibaba.fastjson.JSONObject jsonObject2 = com.alibaba.fastjson.JSONObject
    117                                     .parseObject(array2.getString(j));
    118                             String provinceName2 = jsonObject.getString("provinceName");
    119                             String cityname = jsonObject2.getString("cityName");
    120                             String confirmed2 = jsonObject2.getString("confirmedCount");
    121                              String currentnum2 = jsonObject.getString("currentConfirmedCount");
    122                             String cured2 = jsonObject2.getString("curedCount");
    123                             String dead2 = jsonObject2.getString("deadCount");
    124                             String suspect2 = jsonObject2.getString("suspectedCount");
    125                             stmt.executeUpdate("insert into info3(Date,Province,City,Confirmed_num,Yisi_num,Cured_num,Dead_num) values('"+ nowTime + "','"+ provinceName2 + "','"+ cityname + "','"+currentnum2+ "','" + confirmed2 + "','" + suspect2 +"','" + cured2 +"','" + dead2 +"')");
    126                 }
    127             }
    128                 stmt.close();
    129                 conn.close();
    130             } catch (SQLException e) {
    131                 // TODO Auto-generated catch block
    132                 e.printStackTrace();
    133             }
    134         }
    135         return result;
    136     }
    137     /**
    138      * 鑾峰彇鍏ㄧ悆鍚勪釜鍥藉�鐨勭‘璇娿�佹�浜″拰娌绘剤浜烘暟
    139      * @return
    140      */
    141     public static String getListByCountryTypeService2() {
    142         String url = "https://ncov.dxy.cn/ncovh5/view/pneumonia";
    143         String htmlResult = "";
    144         try {
    145             htmlResult = httpRequset(url);
    146         } catch (IOException e) {
    147             // TODO Auto-generated catch block
    148             e.printStackTrace();
    149         }
    150         // System.out.println(htmlResult);
    151 
    152         // 姝e垯鑾峰彇鏁版嵁
    153         // 鍥犱负html鐨勬暟鎹�牸寮忕湅鐫�灏卞儚json鏍煎紡锛屾墍浠ユ垜浠��鍒欒幏鍙杍son
    154         String reg = "window.getListByCountryTypeService2true = (.*?)\}(?=catch)";
    155         Pattern totalPattern = Pattern.compile(reg);
    156         Matcher totalMatcher = totalPattern.matcher(htmlResult);
    157 
    158         String result = "";
    159         if (totalMatcher.find()) {
    160             result = totalMatcher.group(1);
    161             System.out.println(result);
    162             // 鍚勪釜鐪佸競鐨勬槸涓�涓�垪琛↙ist锛屽�鏋滄兂淇濆瓨鍒版暟鎹�簱涓�紝瑕侀亶鍘嗙粨鏋滐紝涓嬮潰鏄痙emo
    163             JSONArray array = JSONArray.parseArray(result);
    164             
    165             try {
    166                 Connection conn = BaseConnection.getConn();
    167                 Statement stmt = conn.createStatement();
    168 
    169                 Date date = new Date();//鑾峰緱绯荤粺鏃堕棿.
    170                 SimpleDateFormat sdf =   new SimpleDateFormat( "yyyy-MM-dd hh:mm:ss" );
    171                 String nowTime = sdf.format(date);
    172 
    173                 for (int i = 0; i <array.size(); i++) {
    174             com.alibaba.fastjson.JSONObject jsonObject = com.alibaba.fastjson.JSONObject
    175                     .parseObject(array.getString(i));    
    176                 String continents =jsonObject.getString("continents");
    177                 String provinceName = jsonObject.getString("provinceName");
    178                 String confirmed = jsonObject.getString("confirmedCount");
    179                 String cured = jsonObject.getString("curedCount");
    180                 String dead = jsonObject.getString("deadCount");
    181                 
    182                 String suspect = jsonObject.getString("suspectedCount");
    183                 stmt.executeUpdate("insert into info4(Date,Continents,Province,Confirmed_num,Yisi_num,Cured_num,Dead_num) values('"+ nowTime + "','"+ continents + "','"+ provinceName + "','" + confirmed + "','" + suspect +"','" + cured +"','" + dead +"')");
    184                     
    185                 }
    186                 stmt.close();
    187                 conn.close();
    188             } catch (SQLException e) {
    189                 // TODO Auto-generated catch block
    190                 e.printStackTrace();
    191             }
    192     }
    193         return result;
    194     }
    195 
    196 }
    View Code

    3.baseconnection.java

     1 package com.yiqin.connect;
     2 
     3 import java.sql.Connection;
     4 import java.sql.DriverManager;
     5 import java.sql.ResultSet;
     6 import java.sql.SQLException;
     7 import java.sql.Statement;
     8 
     9 public class BaseConnection {
    10     public static String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
    11     public static String  dbURL="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=db_platform";//127.0.0.1:1433
    12     public static  String userName="sa";
    13     public static String userPwd="w669399221";
    14     
    15     public static Connection getConn () {
    16         Connection conn =  null ;
    17         
    18         try {
    19             Class.forName(driverName);//加载驱动
    20             conn = DriverManager.getConnection(dbURL, userName, userPwd);
    21             
    22         } catch (Exception e) {
    23             System.out.println("数据库连接失败!!");
    24             e.printStackTrace();
    25         }
    26         
    27         return conn;
    28     }
    29     
    30     /**
    31      * 关闭连接
    32      * @param state
    33      * @param conn
    34      */
    35     public static void close (Statement state, Connection conn) {
    36         if (state != null) {
    37             try {
    38                 state.close();
    39             } catch (SQLException e) {
    40                 e.printStackTrace();
    41             }
    42         }
    43         
    44         if (conn != null) {
    45             try {
    46                 conn.close();
    47             } catch (SQLException e) {
    48                 e.printStackTrace();
    49             }
    50         }
    51     }
    52     
    53     public static void close (ResultSet rs, Statement state, Connection conn) {
    54         if (rs != null) {
    55             try {
    56                 rs.close();
    57             } catch (SQLException e) {
    58                 e.printStackTrace();
    59             }
    60         }
    61         
    62         if (state != null) {
    63             try {
    64                 state.close();
    65             } catch (SQLException e) {
    66                 e.printStackTrace();
    67             }
    68         }
    69         
    70         if (conn != null) {
    71             try {
    72                 conn.close();
    73             } catch (SQLException e) {
    74                 e.printStackTrace();
    75             }
    76         }
    77     }
    78 
    79 }
    View Code

    4.servlet.java

      1 package com.yiqin.servlet;
      2 import java.sql.PreparedStatement;
      3 import java.sql.ResultSet;
      4 import java.sql.SQLException;
      5 import java.sql.Statement;
      6 import java.util.ArrayList;
      7 import java.io.IOException;
      8 import java.sql.Connection;
      9 import java.sql.DriverManager;
     10 
     11 import javax.servlet.ServletException;
     12 import javax.servlet.annotation.WebServlet;
     13 import javax.servlet.http.HttpServlet;
     14 import javax.servlet.http.HttpServletRequest;
     15 import javax.servlet.http.HttpServletResponse;
     16 import javax.servlet.http.HttpSession;
     17 import com.yiqin.user.*;
     18 
     19 import com.yiqin.connect.*;;
     20 /**
     21  * Servlet implementation class YiQinServlet
     22  */
     23 @WebServlet("/YiQinServlet")
     24 public class YiQinServlet extends HttpServlet {
     25     private static final long serialVersionUID = 1L;
     26        
     27     /**
     28      * @see HttpServlet#HttpServlet()
     29      */
     30     public YiQinServlet() {
     31         super();
     32         // TODO Auto-generated constructor stub
     33     }
     34 
     35     /**
     36      * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
     37      */
     38     protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
     39         // TODO Auto-generated method stub
     40     request.setCharacterEncoding("utf-8");
     41     response.setContentType("text/html;charset=UTF-8");
     42     ArrayList<User> list = new ArrayList();
     43     ArrayList<User> list2 = new ArrayList();
     44     //澹版槑缂撳啿鍖�
     45     HttpSession session = request.getSession();
     46     Connection conn = BaseConnection.getConn();
     47     PreparedStatement ps = null;
     48 
     49     
     50     String start=request.getParameter("start"); 
     51     String end=request.getParameter("end"); 
     52     
     53     int as=0;
     54     String name[] =new String [330];
     55     String num[]=new String[330];
     56     for(int i=0;i<330;i++)
     57     {
     58         name[i]="";
     59         num[i]="0";
     60     }
     61     //*************************************
     62     //鍦ㄨ繖閲屽啓!!!!
     63     
     64     /*try {
     65         Statement stmt = conn.createStatement();
     66         //1.鏀箂ql璇�彞        
     67             ResultSet rs = stmt.executeQuery("select * from info4");
     68         while (rs.next()) {
     69     
     70             
     71             String date=new String(rs.getString("Date"));
     72             if(date.compareTo(start)>=0&& date.compareTo(end)<=0)
     73             {
     74                 String province=new String(rs.getString("Province"));
     75                 String city=new String(rs.getString("City"));
     76                 String quezhen=new String(rs.getString("Confirmed_num"));
     77                 String zhiyu=new String(rs.getString("Cured_num"));
     78                 String dead=new String(rs.getString("Dead_num"));
     79                 System.out.println(date+" "+province+" "+city+" "+quezhen);
     80                 User use=new User(province,date,,quezhen,dead,zhiyu);
     81                 list.add(use);                    
     82                     
     83             }
     84             
     85         }
     86 
     87         
     88 }catch (SQLException e) {
     89         response.getWriter().print("鏌ユ壘澶辫触");
     90     }    
     91 */
     92     /*try {
     93         Statement stmt = conn.createStatement();
     94         //1.鏀箂ql璇�彞        
     95             ResultSet rs = stmt.executeQuery("select * from info3");
     96         while (rs.next()) {            
     97             String date=new String(rs.getString("Date"));
     98             if(date.compareTo(start)>=0&& date.compareTo(end)<=0)
     99             {
    100                 String province=new String(rs.getString("Province"));
    101                 String city=new String(rs.getString("City"));
    102                 String quezhen=new String(rs.getString("Confirmed_num"));
    103                 String zhiyu=new String(rs.getString("Cured_num"));
    104                 String dead=new String(rs.getString("Dead_num"));
    105                 System.out.println(date+" "+province+" "+city+" "+quezhen);
    106                 user use=new user(date,province,city,quezhen,zhiyu,dead);
    107                 list.add(use);
    108             }
    109             
    110         }
    111 
    112         
    113 }catch (SQLException e) {
    114         response.getWriter().print("鏌ユ壘澶辫触");
    115     }*/
    116     try {
    117         Statement stmt = conn.createStatement();
    118         //1.鏀箂ql璇�彞        
    119             ResultSet rs = stmt.executeQuery("select * from info4");
    120         while (rs.next()) {            
    121             String date=new String(rs.getString("Date"));
    122             if(date.compareTo(start)>=0&& date.compareTo(end)<=0)
    123             {
    124                 String continents=new String(rs.getString("Continents"));
    125                 String province=new String(rs.getString("Province"));
    126                 String quezhen=new String(rs.getString("Confirmed_num"));
    127                 String zhiyu=new String(rs.getString("Cured_num"));
    128                 String dead=new String(rs.getString("Dead_num"));
    129                 
    130                 User use=new User(continents,province,date,quezhen,dead,zhiyu);
    131                 list2.add(use);
    132                 name[as]=province;
    133                 num[as]= quezhen;
    134                 as++;
    135             }
    136             
    137         }
    138 
    139         
    140 }catch (SQLException e) {
    141         response.getWriter().print("鏌ユ壘澶辫触");
    142     }    
    143     request.setAttribute("list",list);
    144     request.setAttribute("list2",list2);   
    145     session.setAttribute("name",name);      
    146     session.setAttribute("num",num);      
    147     request.getRequestDispatcher( "echarts.jsp").forward(request,response);
    148     //***************************************
    149 
    150     
    151     }
    152 
    153     /**
    154      * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    155      */
    156     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    157         // TODO Auto-generated method stub
    158         doGet(request, response);
    159     }
    160 
    161 }
    View Code

    5.find.jsp

     1 <%@ page language="java" contentType="text/html; charset=UTF-8"
     2     pageEncoding="UTF-8"%>
     3 <!DOCTYPE html>
     4 <html>
     5 <head>
     6 <meta charset="UTF-8">
     7 <title>Insert title here</title>
     8 <!--
     9 <style>
    10 
    11 *{margin:0;padding:0;}
    12 body{};
    13 .content
    14 {
    15  
    16             
    17             left:0;
    18              100%;
    19              height:400px;
    20              margin-top:0px;
    21          
    22 
    23 }
    24 .main
    25 {
    26  background-color:#ffff00;
    27 text-align:center;
    28 height:400px;
    29 padding: 0 auto;
    30 padding:100px 0px;
    31 
    32 
    33 }
    34 .main h1
    35 {
    36 margin:0px 150px;
    37 font-family:"楷体";
    38 font-size:50px;
    39 font-weight:2px;
    40 color:#226DDD;
    41 padding:0px 50px;
    42  border-radius:30px;
    43  background-color:#ffcccc;
    44 
    45 }
    46 
    47   
    48          form{
    49              padding:20px 0;
    50          }
    51           input{
    52              border:1px solid black;
    53              display:block;
    54              margin:0px auto 10px auto;/*上 右  下 左*/
    55              padding:10px;
    56              220px;
    57              border-radius:30px;/*H5设置圆角边框*/
    58              font-size:18px;
    59              font-weight:300;
    60              text-align:center;
    61          }
    62           input:hover{
    63              background-color:pink;
    64         }
    65           button{
    66              background-color:white;
    67              border-radius:10px;
    68            
    69              border:1px solid black;
    70             
    71              height:30px;
    72              50px;
    73              padding:5px 10px;
    74              font-family:"楷体";
    75         }
    76           button:hover{
    77              background-color:red;
    78          }
    79 -->
    80 </style>
    81 </head>
    82 <body>
    83 <div class="content">
    84 <div class="main">
    85 <h1>疫情统计</h1>
    86 <form action="YiQinServlet"  method="post">
    87 <input type="datetime" id="start" name="start"  placeholder="起始时间">
    88 <input type="datetime" id="end" name="end"  placeholder="终止时间">
    89 <button type="submit" id="search" name="search">查找</button>
    90 </form>
    91 </div>
    92 </div>
    93 </body>
    94 </html>
    View Code

    6.echart.jsp

      1 <%//开头%>
      2 <%@ page language="java" contentType="text/html; charset=utf-8"
      3     pageEncoding="utf-8"%>    
      4  <%@page import="java.text.SimpleDateFormat"%>
      5         <%@page import="java.util.*"%>
      6         <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
      7  <link rel="stylesheet" type="text/css" href="a.css"> 
      8 <!DOCTYPE html>
      9 <html>
     10 <head>
     11 
     12   <!-- 引入 ECharts 文件 -->
     13     <script src="js/echarts.min.js"></script>
     14 <title>疫情数据统计</title>
     15 </head>
     16 <style type="text/css">
     17  #main{
     18      position:relative;
     19   left: 100px;
     20  }
     21  .cha{
     22      position:relative;
     23   left: 50px;
     24  }
     25  td{
     26  text-align:center;vertical-align:middle;
     27  
     28  }
     29 #cont 
     30  {
     31      width: 1200px;
     32 
     33  }
     34  #test1 {
     35      width: 400px; 
     36      position:relative;
     37      margin: 10px 30px;
     38      float: left;
     39  }
     40  #test2 {
     41      width: 400px;
     42      position:relative;
     43      float: right;
     44  }
     45  </style>
     46 <body>
     47  
     48   <%String pname[] =(String[]) session.getAttribute("name");%>
     49   <%String cnum[] =(String[]) session.getAttribute("num");%>
     50    
     51   
     52     <div id="main" style=" 600px;height:400px;"></div>
     53     
     54     <div id="cont"> 
     55     <div id="test2">
     56    <!--  <table>
     57     <tr>
     58     <th>日期</th><th>省份</th><th>城市</th><th>确诊人数</th><th>治愈人数</th><th>死亡人数</th>
     59     </tr>
     60     
     61     <c:forEach items="${list}" var="use" >
     62         <tr>
     63         <td>${use.date}</td><td>${use.province}</td><td>${use.city}</td><td>${use.quezhen}</td><td>${use.zhiyu}</td><td>${use.dead}</td>
     64         </tr>
     65         </c:forEach>
     66     </table>-->
     67     </div>
     68     <div id="test1">
     69     <table>
     70     <tr>
     71     <th>日期</th><th></th><th>国家</th><th>确诊人数</th><th>治愈人数</th><th>死亡人数</th>
     72     </tr>
     73     
     74     <c:forEach items="${list2}" var="use2" >
     75         <tr>
     76         <td>${use2.date}</td><td>${use2.continents}</td><td>${use2.province}</td><td>${use2.confirmed_num}</td><td>${use2.cured_num}</td><td>${use2.dead_num}</td>
     77         </tr>
     78         </c:forEach>
     79     </table>
     80     </div>
     81     </div>
     82 </body>
     83  <script type="text/javascript">
     84         // 基于准备好的dom,初始化echarts实例
     85         var myChart = echarts.init(document.getElementById('main'));
     86         var option = {
     87                 title: {
     88                     text: '疫情确诊人数统计'
     89                 },
     90                 tooltip: {},
     91                 legend: {
     92                     data:['确诊人数']
     93                 },
     94                 xAxis: {
     95                     type: 'category',
     96                     axisLabel: {  
     97                         interval:0,  
     98                         rotate:40  
     99                      }  ,
    100                  data: ["<%=pname[0]%>","<%=pname[1]%>","<%=pname[2]%>","<%=pname[3]%>","<%=pname[4]%>","<%=pname[5]%>"
    101                      ,"<%=pname[6]%>","<%=pname[7]%>","<%=pname[8]%>","<%=pname[9]%>","<%=pname[10]%>","<%=pname[11]%>","<%=pname[12]%>"
    102                      ,"<%=pname[13]%>","<%=pname[14]%>","<%=pname[15]%>","<%=pname[16]%>","<%=pname[17]%>","<%=pname[18]%>","<%=pname[19]%>"
    103                      ,"<%=pname[20]%>","<%=pname[21]%>","<%=pname[22]%>","<%=pname[23]%>","<%=pname[24]%>","<%=pname[25]%>","<%=pname[26]%>"
    104                      ,"<%=pname[27]%>","<%=pname[28]%>","<%=pname[29]%>","<%=pname[30]%>","<%=pname[31]%>"]
    105                 },
    106                 yAxis: {
    107                     type:'value'
    108                 },
    109                 series: [{
    110                     name: '确诊人数',
    111                     data: [<%=cnum[0]%>,<%=cnum[1]%>,<%=cnum[2]%>, <%=cnum[3]%>,<%=cnum[4]%> ,<%=cnum[5]%>
    112                     ,<%=cnum[6]%> ,<%=cnum[7]%> ,<%=cnum[8]%> ,<%=cnum[9]%> ,<%=cnum[10]%> ,<%=cnum[11]%> ,<%=cnum[12]%>
    113                     ,<%=cnum[13]%> ,<%=cnum[14]%> ,<%=cnum[15]%> ,<%=cnum[16]%> ,<%=cnum[17]%> ,<%=cnum[18]%> ,<%=cnum[19]%>
    114                     ,<%=cnum[20]%> ,<%=cnum[21]%> ,<%=cnum[22]%> ,<%=cnum[23]%> ,<%=cnum[24]%> ,<%=cnum[25]%> ,<%=cnum[26]%>
    115                     ,<%=cnum[27]%> ,<%=cnum[28]%> ,<%=cnum[29]%> ,<%=cnum[30]%>,<%=cnum[31]%>],
    116                     type: 'line',
    117                     smooth: true
    118                 }]
    119             };
    120         // 指定图表的配置项和数据    
    121         // 使用刚指定的配置项和数据显示图表。
    122         myChart.setOption(option);
    123     </script>
    124 </html>
    View Code
  • 相关阅读:
    【SSO单点系列】(1):CAS4.0 环境的搭建
    Docker学习总结之Run命令介绍
    使用 RMI + ZooKeeper 实现远程调用框架
    JAVA CAS单点登录(SSO)
    web应用中Spring ApplicationContext的动态更新
    Java 中 String、StringBuffer、StringBuilder 三者之间的区别
    static final 、static 、final 区别
    static Java 关键字 简单理解
    final Java 关键字 深入浅出,简单理解
    进程 线程 简单理解说明
  • 原文地址:https://www.cnblogs.com/w669399221/p/13083538.html
Copyright © 2011-2022 走看看