import json

from pyecharts import Bar, Line, Scatter, EffectScatter, Grid, WordCloud, Graph, Page
with open('AuthorList.json') as json_file:
   AuthorList = json.load(json_file)
       
with open('FriendList.json') as json_file:
    FriendList = json.load(json_file)  #'{\"myself\":\"NLPR\",\"other\":\"Longyin Wen\"}'...

## 拥有论文篇数大于5的作者
pop = [
'Chen-Change Loy',
'Hang Su',
'Timothy Hospedales',
'Jianping Shi',
'Raquel Urtasun',
'Ming-Yu Liu',
'Oisin Mac Aodha',
'Kristen Grauman',
'Ming-Hsuan Yang',
'Jimmy Ren',
'Saarbrucken',
'Leonidas J. Guibas',
'Ali Farhadi',
'Jimei Yang',
'Sanja Fidler',
'Wenjie Luo',
'Lin Ma',
'Antonio Torralba',
'Tatsuya Harada',
'Song-Chun Zhu',
'Liang Lin',
'Marc Pollefeys',
'Lei Zhang',
'Andrea Vedaldi',
'Jinshan Pan',
'Pascal Fua',
'William Freeman',
'Tao Xiang',
'Yang Liu',
'Tomer Michaeli',
'Peng Wang',
'Hongsheng Li',
'Yoshitaka Ushiku',
'Wangmeng Zuo',
'Zhaowen Wang',
'Mathieu Salzmann',
'Torsten Sattler',
'Ross Girshick',
'Anton Van den Hengel',
'Junjie Yan',
'Dahua Lin',
'Silvio Savarese',
'Tomas Pajdla',
'Yaser Sheikh',
'Bernt Schiele',
'University of Michigan',
'Wei Liu',
'Gim Hee Lee',
'Yi Yang',
'Laurens van der Maaten',
'Qi Wu',
'Jiashi Feng',
'Cristian Sminchisescu',
'UCSD',
'Ali Borji',
'Fei-Fei Li',
'Abhinav Gupta',
'Bernard Ghanem',
'Bern University',
'Gang Wang',
'Ian Reid',
'Jiwen Lu',
'Yan Huang',
'Institute of Automation',
'Vladlen Koltun',
'California Institute of Technology',
'Linchao Bao',
'Hao Li',
'UC Berkeley',
'University of California',
'University of Bonn',
'Phil Torr',
'University of Maryland',
'Fisher Yu',
'Jan Kautz',
'Junsong Yuan',
'Huchuan Lu',
'Jiaya Jia',
'Yu-Kun Lai',
'Wanli Ouyang',
'Jitendra Malik',
'Cewu Lu',
'Luc Van Gool',
'Jun Zhu',
'Xiaogang Wang',
'Deqing Sun',
'Wei Wang',
'Chunhua Shen',
'Bingbing Ni',
'Christian Theobalt',
'Xiaoming Liu',
'Alan Yuille',
'Liang Wang',
'Dan Xu',
'Serge Belongie',
'Stephen Gould'
]
page = Page()
links = []
for i in FriendList:
	i = json.loads(i)
	if i.get("myself") != i.get("other") and i.get("myself") in pop:
		links.append({"source":i.get("myself"),"target":i.get("other")})

nodes = []
for i in AuthorList:
	i = json.loads(i)
	author = {"name": i.get("name"), "symbolSize": 10}
	if author not in nodes:
		nodes.append(author)

nodes_p = []
for i in AuthorList:
	i = json.loads(i)
	author = {"name": i.get("name"), "symbolSize": 10}
	if author not in nodes_p and author['name'] in pop:
		nodes_p.append(author)

name = ["neural networks","large-scale","convolutional neural network","deep neural networks","results show that","experiments show that","generative adversarial networks","visual question answering","neural networks cnns","deep convolutional neural","experimental results show","Learning Deep","Glimpse Clouds","Deep Q-Learning"]
value = [497,200,240,70,56,45,43,39,36,33,32,100,50,30]

wordcloud = WordCloud("CVPR热词高频词")
wordcloud.add("", name, value, word_size_range=[20, 100])





graph = Graph("CVPR全部作者图谱",width = 800,height=800)
graph.add("", 
	nodes,
	[], 
	is_label_show=True,
	graph_repulsion=50,
    is_legend_show=False,
   	graph_edge_length=100,
    label_text_color=None,
	)
graph2 = Graph("CVPR活跃作者关系图",width = 800,height=800)

graph2.add("", 
	nodes_p, 
	links, 
	is_label_show=True,
	graph_repulsion=50,
    is_legend_show=False,
   	graph_edge_length=100,
    label_text_color=None,
	)
# Poster:979 Oral:68 Spotlight:224
attr = ["Poster", "Oral", "Spotlight"]
v1 = [979, 68, 224]

bar = Bar("CVPR不同类型论文统计表")
bar.add("", attr, v1, is_stack=True)

attr2 = ['Chen-Change Loy',
'Hang Su',
'Timothy Hospedales',
'Jianping Shi',
'Raquel Urtasun',
'Ming-Yu Liu',
'Oisin Mac Aodha',
'Kristen Grauman',
'Ming-Hsuan Yang',
'Jimmy Ren',
'Saarbrucken',
'Leonidas J. Guibas',
'Ali Farhadi',
'Jimei Yang',
'Sanja Fidler',
'Wenjie Luo',
'Lin Ma',
'Antonio Torralba',
'Tatsuya Harada',
'Song-Chun Zhu',
'Liang Lin',
'Marc Pollefeys',
'Lei Zhang',
'Andrea Vedaldi',
'Jinshan Pan',
'Pascal Fua',
'William Freeman',
'Tao Xiang',
'Yang Liu',
'Tomer Michaeli',
'Peng Wang',
'Hongsheng Li',
'Yoshitaka Ushiku',
'Wangmeng Zuo',
'Zhaowen Wang',
'Mathieu Salzmann',
'Torsten Sattler',
'Ross Girshick',
'Anton Van den Hengel',
'Junjie Yan',
'Dahua Lin',
'Silvio Savarese',
'Tomas Pajdla',
'Yaser Sheikh',
'Bernt Schiele',
'University of Michigan',
'Wei Liu',
'Gim Hee Lee',
'Yi Yang',
'Laurens van der Maaten',
'Qi Wu',
'Jiashi Feng',
'Cristian Sminchisescu',
'UCSD',
'Ali Borji',
'Fei-Fei Li',
'Abhinav Gupta',
'Bernard Ghanem',
'Bern University',
'Gang Wang',
'Ian Reid',
'Jiwen Lu',
'Yan Huang',
'Institute of Automation',
'Vladlen Koltun',
'California Institute of Technology',
'Linchao Bao',
'Hao Li',
'UC Berkeley',
'University of California',
'University of Bonn',
'Phil Torr',
'University of Maryland',
'Fisher Yu',
'Jan Kautz',
'Junsong Yuan',
'Huchuan Lu',
'Jiaya Jia',
'Yu-Kun Lai',
'Wanli Ouyang',
'Jitendra Malik',
'Cewu Lu',
'Luc Van Gool',
'Jun Zhu',
'Xiaogang Wang',
'Deqing Sun',
'Wei Wang',
'Chunhua Shen',
'Bingbing Ni',
'Christian Theobalt',
'Xiaoming Liu',
'Alan Yuille',
'Liang Wang',
'Dan Xu',
'Serge Belongie',
'Stephen Gould'
]
v2=[7,
6,
11,
8,
13,
6,
6,
11,
25,
7,
8,
6,
8,
6,
10,
6,
6,
7,
8,
9,
10,
10,
9,
8,
7,
10,
7,
11,
6,
9,
8,
8,
6,
8,
6,
6,
7,
8,
7,
10,
9,
10,
6,
7,
13,
6,
16,
7,
6,
6,
9,
12,
7,
7,
6,
10,
7,
7,
6,
11,
9,
7,
6,
18,
6,
8,
6,
6,
8,
16,
6,
6,
19,
6,
17,
8,
10,
8,
7,
11,
10,
7,
20,
7,
15,
8,
7,
13,
7,
10,
6,
6,
7,
6,
10,
6]
bar2 = Bar("CVPR不同地区论文发表数(大于5篇)")
bar2.add("", attr2, v2,label_color='#00BFFF', is_stack=True,is_datazoom_show=True,is_label_show=True)


page.add(graph2)
page.add(wordcloud)
page.add(bar)
page.add(bar2)
page.render()
