大数据框架--数据可视化代码--2020.5.31

index.jsp


<%@ page  pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>  
    <meta charset="utf-8" />  
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />  
    <title>用户行为分析</title>  
    <style>  
       
        #left{  
            width: 15%;  
            height: 700px;  
            float: left;  
            border-right:1px solid gray;
        }  
        #right{  
            width: 84%;  
            height: 700px;  
            border:0;
        }  
        li{
           line-height:1.8;
        }
    </style>  
<body>  

    <h2>用户行为分析结果</h2><hr>
   
    <div id="left">
     <ul>
      
       <li><a href="zonghe-1.jsp" target="right">每天成交量</a></li>     
       <li><a href="zonghe-2.jsp" target="right">访问量前10的商品种类</a></li>    
       <li><a href="zonghe-3.jsp" target="right">购买量前10的用户</a></li>
     </ul>
    </div>  
    <iframe id="right" name="right"  src=""></iframe>  
 
</body>  
</html>  

zonghe-1.jsp

<%@page pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="utf-8">
<title>柱状图显示数值</title>
</head>
<body style="height:600px; margin: 0">

	<div id="main" style="width: 2000px;height:80%;"></div>
	<script type="text/javascript" src="js/echarts.min.js"></script>
	<script>
	function show(title,value){
		var myChart = echarts.init(document.getElementById('main'));

		// 指定图表的配置项和数据
		var option = {
		    // 标题
		    title: {
		        text: '每天的成交量'
		    },
		    // 工具箱
		    toolbox: {
		    	show: true,
		        feature: {
		            dataZoom: {
		                yAxisIndex: 'none'
		            },
		            dataView: {readOnly: false},
		            magicType: {type: ['line', 'bar']},
		            restore: {},
		            saveAsImage: {}
		        }
		    },
		    // 图例
		    legend: {
		        data: ['销量']
		    },
		    // x轴
		    xAxis: {
		        data: title
		    	
		    },
		    yAxis: {
		    	 type: 'value'
		    },
		    // 数据
		    series: [{
		        name: '销量',
		        type: 'bar',
		        data: value,
		        itemStyle: {
					normal: {
						label: {
							show: true, //开启显示
							position: 'top', //在上方显示
							textStyle: { //数值样式
								color: 'black',
								fontSize: 16
							}
						}
					}
				},
		    }]
		};

		// 使用刚指定的配置项和数据显示图表。
		myChart.setOption(option);
	}	
	</script>
	<%
	Class.forName("com.mysql.jdbc.Driver");
	String url="jdbc:mysql://192.168.159.128:3306/test";
	Connection con=DriverManager.getConnection(url,"guest","guest");
	String sql="select time,count(item_id) c from province where behavior_type='4' and time<'2020-1-1'and time>'2013-1-1' group by  day(time) order by  c DESC;";
	
	PreparedStatement pst=con.prepareCall(sql);
	ResultSet rs=pst.executeQuery();
	
	%>
	<script type="text/javascript">
	title=new Array();
	value=new Array();
	<%
	  while(rs.next()){
	%>
	title.push("<%=rs.getString(1)%>");value.push(<%=rs.getInt(2)%>);
	<%
	  }
	  rs.close();
	  pst.close();
	  con.close();
	%>
	show(title,value);
	</script>
</body>
</html>

zonghe-1.jsp

<%@page pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="utf-8">
<title>柱状图显示数值</title>
</head>
<body style="height:600px; margin: 0">

	<div id="main" style="width: 2000px;height:80%;"></div>
	<script type="text/javascript" src="js/echarts.min.js"></script>
	<script>
	function show(title,value){
		var myChart = echarts.init(document.getElementById('main'));

		// 指定图表的配置项和数据
		var option = {
		    // 标题
		    title: {
		        text: '访问量前10名的商品种类'
		    },
		    // 工具箱
		    toolbox: {
		    	show: true,
		        feature: {
		            dataZoom: {
		                yAxisIndex: 'none'
		            },
		            dataView: {readOnly: false},
		            magicType: {type: ['line', 'bar']},
		            restore: {},
		            saveAsImage: {}
		        }
		    },
		    // 图例
		    legend: {
		        data: ['销量']
		    },
		    // x轴
		    xAxis: {
		        data: title
		    	
		    },
		    yAxis: {
		    	 type: 'value'
		    },
		    // 数据
		    series: [{
		        name: '销量',
		        type: 'bar',
		        data: value,
		        itemStyle: {
					normal: {
						label: {
							show: true, //开启显示
							position: 'top', //在上方显示
							textStyle: { //数值样式
								color: 'black',
								fontSize: 16
							}
						}
					}
				},
		    }]
		};

		// 使用刚指定的配置项和数据显示图表。
		myChart.setOption(option);
	}	
	</script>
	<%
	Class.forName("com.mysql.jdbc.Driver");
	String url="jdbc:mysql://192.168.159.128:3306/test";
	Connection con=DriverManager.getConnection(url,"guest","guest");
	String sql="select  item_category,count(item_category) c from province where behavior_type='1' group by item_category order by  c DESC limit 10;";
	
	PreparedStatement pst=con.prepareCall(sql);
	ResultSet rs=pst.executeQuery();
	
	%>
	<script type="text/javascript">
	title=new Array();
	value=new Array();
	<%
	  while(rs.next()){
	%>
	title.push("<%=rs.getString(1)%>");value.push(<%=rs.getInt(2)%>);
	<%
	  }
	  rs.close();
	  pst.close();
	  con.close();
	%>
	show(title,value);
	</script>
</body>
</html>

zhonghe-3

<%@page pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="utf-8">
<title>柱状图显示数值</title>
</head>
<body style="height:600px; margin: 0">

	<div id="main" style="width: 2000px;height:80%;"></div>
	<script type="text/javascript" src="js/echarts.min.js"></script>
	<script>
	function show(title,value){
		var myChart = echarts.init(document.getElementById('main'));

		// 指定图表的配置项和数据
		var option = {
		    // 标题
		    title: {
		        text: '购买量前10名的用户'
		    },
		    // 工具箱
		    toolbox: {
		    	show: true,
		        feature: {
		            dataZoom: {
		                yAxisIndex: 'none'
		            },
		            dataView: {readOnly: false},
		            magicType: {type: ['line', 'bar']},
		            restore: {},
		            saveAsImage: {}
		        }
		    },
		    // 图例
		    legend: {
		        data: ['销量']
		    },
		    // x轴
		    xAxis: {
		        data: title
		    	
		    },
		    yAxis: {
		    	 type: 'value'
		    },
		    // 数据
		    series: [{
		        name: '销量',
		        type: 'bar',
		        data: value,
		        itemStyle: {
					normal: {
						label: {
							show: true, //开启显示
							position: 'top', //在上方显示
							textStyle: { //数值样式
								color: 'black',
								fontSize: 16
							}
						}
					}
				},
		    }]
		};

		// 使用刚指定的配置项和数据显示图表。
		myChart.setOption(option);
	}	
	</script>
	<%
	Class.forName("com.mysql.jdbc.Driver");
	String url="jdbc:mysql://192.168.159.128:3306/test";
	Connection con=DriverManager.getConnection(url,"guest","guest");
	String sql="select user_id ,count(item_id) from province where  behavior_type='4' group by user_id having count(item_id) order by count(item_id)  desc limit 10 ;";
	
	PreparedStatement pst=con.prepareCall(sql);
	ResultSet rs=pst.executeQuery();
	
	%>
	<script type="text/javascript">
	title=new Array();
	value=new Array();
	<%
	  while(rs.next()){
	%>
	title.push("<%=rs.getString(1)%>");value.push(<%=rs.getInt(2)%>);
	<%
	  }
	  rs.close();
	  pst.close();
	  con.close();
	%>
	show(title,value);
	</script>
</body>
</html>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值