-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresult2.php
More file actions
256 lines (239 loc) · 7.94 KB
/
result2.php
File metadata and controls
256 lines (239 loc) · 7.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<?php
/**
*
* @author qiangjian@staff.sina.com.cn sunsky303@gmail.com
* Date: 15/4/17
* Time: 20:36
* @version $Id: $
* @since 1.0
* @copyright Sina Corp.
*/
//$result = [
// 'total'=>99,
// 'users'=>[
// 'zhang'=> 11,
// 'li'=>12,
// 'san'=>33,
// ]
//];
function curl_get($url){
$hdl = curl_init($url);
curl_setopt_array($hdl, array(
CURLOPT_RETURNTRANSFER => 1,
));
$rt = curl_exec($hdl);
curl_close($hdl);
return $rt;
}
$filename = $_GET['file'];
$userAPI = curl_get('http://hackathon2015.sinaapp.com/qq.php?file=' . $filename);
$result = json_decode($userAPI, 1);
$users = (array)$result['users'];
$users2 = array();
foreach ($users as $k => $v) {
$users2[] = array(
'name' => ($k),
'value' => $v
);
}
$userLabels = array_keys($users);
$userTimes = array_values($users);
$keywordCountsAPI = 'http://hackathon2015.sinaapp.com/qq3.php?file=' . $filename;
$keywordCounts = curl_get($keywordCountsAPI);
$keywordCounts = json_decode($keywordCounts, 1);
$keywordCounts2 = array();
foreach ($keywordCounts as $k => $v) {
$keywordCounts2[] = array(
'name' => $k,
'value' => $v
);
}
?><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>QQ Record:QQ群聊热点分析</title>
<link href="echarts/doc/asset/css/font-awesome.min.css" rel="stylesheet">
<link href="echarts/doc/asset/css/bootstrap.css" rel="stylesheet">
<link href="echarts/doc/asset/css/carousel.css" rel="stylesheet">
<link href="echarts/doc/asset/css/echartsHome.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script src="echarts/doc/example/www/js/echarts.js"></script>
<script src="echarts/doc/asset/js/codemirror.js"></script>
<script src="echarts/doc/asset/js/javascript.js"></script>
<link href="echarts/doc/asset/css/codemirror.css" rel="stylesheet">
<link href="echarts/doc/asset/css/monokai.css" rel="stylesheet">
<style>
html {
background-color: #fff;
}
body{
padding-top: 0;
}
h1{
font-size: 36px;
margin: auto;
padding: 20px;
text-align: center;
}
</style>
</head>
<body>
<h1>QQ Record <span style="text-align: right;
font-size: 16px;
color: gray;
margin: 0;">QQ群聊热点分析</span></h1>
<div id="graphic">
<!--Step:1 Prepare a dom for ECharts which (must) has size (width & hight)-->
<!--Step:1 为ECharts准备一个具备大小(宽高)的Dom-->
<div id="top" class="chart" style="height:500px;border:1px solid #ccc;padding:10px;"></div>
<div id="word_top" class="chart" style="height:500px;border:1px solid #ccc;padding:10px;"></div>
</div>
<!--Step:2 Import echarts.js-->
<!--Step:2 引入echarts.js-->
<script src="echarts/doc/asset/js/jquery.min.js"></script>
<!--<script src="echarts/src/echarts.js"></script>-->
<!--<script src="echarts/doc/asset/js/echartsTheme.js"></script>-->
<script type="text/javascript">
// Step:3 conifg ECharts's path, link to echarts.js from current page.
// Step:3 为模块加载器配置echarts的路径,从当前页面链接到echarts.js,定义所需图表路径
require.config({
paths: {
echarts: 'echarts/build/source/'
}
});
// Step:4 require echarts and use it in the callback.
// Step:4 动态加载echarts然后在回调函数中开始使用,注意保持按需加载结构定义图表路径
require(
[
'echarts',
'echarts/chart/bar',
'echarts/chart/pie',
'echarts/chart/line',
'echarts/chart/map'
],
function (ec, defaultTheme) {
var myChart2 = ec.init(document.getElementById('top'));
myChart2.setOption({
title: {
text: '发言最多用户TOP15',
subtext: '总发言数:<?= $result['total'] ?>',
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
// legend: {
// x: 'center',
// y: 'bottom',
// data: <?//= json_encode($userLabels) ?>
// },
toolbox: {
show: true,
feature: {
mark: {show: true},
dataView: {show: true, readOnly: false},
magicType: {
show: true,
type: ['pie', 'funnel']
},
restore: {show: true},
saveAsImage: {show: true}
}
},
calculable: true,
series: [
{
name: '面积模式',
type: 'pie',
radius: [30, 110],
// center : ['75%', 200],
roseType: 'area',
x: '50%', // for funnel
max: 40, // for funnel
sort: 'ascending', // for funnel
data: <?= json_encode($users2) ?>
}
]
});
//--- 2 ---
var myChart2 = ec.init(document.getElementById('word_top'));
myChart2.setOption({
title: {
text: '关键词TOP15',
subtext: '',
x: 'center'
},
tooltip: {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
// legend: {
// x: 'center',
// y: 'bottom',
// data:<?//= json_encode(array_keys($keywordCounts)) ?>
// },
toolbox: {
show: true,
feature: {
mark: {show: true},
dataView: {show: true, readOnly: false},
magicType: {
show: true,
type: ['pie', 'funnel']
},
restore: {show: true},
saveAsImage: {show: true}
}
},
calculable: true,
series: [
{
name: '面积模式',
type: 'pie',
radius: [30, 110],
// center : ['75%', 200],
roseType: 'area',
x: '50%', // for funnel
max: 40, // for funnel
sort: 'ascending', // for funnel
data:<?= json_encode($keywordCounts2) ?>
}
]
});
}///env init
);
</script>
<?php
require_once('fans.php');
?>
<div style="height:50px; width:100%;clear: both;"></div>
<div style="background-image: url('2weima.png') ;background-repeat:no-repeat;background-position: center;clear: both;width:280px;height:280px;padding:100px;margin: 10px auto;"></div>
<div style="height:50px; width:100%;clear: both;"></div>
<!-- JiaThis Button BEGIN -->
<div class="jiathis_style_32x32" style="width: 280px;
text-align: center;
height: 40px;
margin: 0 auto;">
<a class="jiathis_button_qzone"></a>
<a class="jiathis_button_tsina"></a>
<a class="jiathis_button_tqq"></a>
<a class="jiathis_button_renren"></a>
<a class="jiathis_button_kaixin001"></a>
<a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a>
<a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" >
var jiathis_config={
hideMore:false
}
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END -->
</body>
</html>