-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava_repo.py
More file actions
55 lines (48 loc) · 1.57 KB
/
java_repo.py
File metadata and controls
55 lines (48 loc) · 1.57 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
'''
@Author: your name
@Date: 2020-08-01 20:29:24
@LastEditTime: 2020-08-01 20:30:15
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \learn_matplotlib\java_repo.py
'''
import pygal
import requests
from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS
url = 'https://api.github.com/search/repositories?q=language:java&sort=stars'
r = requests.get(url)
# print('status code:', r.status_code)
response_dict = r.json()
# print("total repositories:", response_dict['total_count'])
# 探索有关仓库的信息
repo_dicts = response_dict['items']
# print('Repositories returned:', len(repo_dicts))
names, plot_dicts = [], []
for repo_dict in repo_dicts:
names.append(repo_dict['name'])
plot_dict = {
'value': repo_dict['stargazers_count'],
'label': str(repo_dict['description']),
'xlink':repo_dict['html_url']
}
plot_dicts.append(plot_dict)
name_list = [
'Name: ', 'Owner: ', 'Stars: ', 'Repository: ', 'Created: ', 'Updated: ',
'Description: '
]
my_style = LS('#333366', base_style=LCS)
# 设置pygal样式
my_config = pygal.Config()
my_config.x_label_rotation = 45
my_config.show_legend = False
my_config.title_font_size = 24
my_config.label_font_size = 14
my_config.major_label_font_size = 18
my_config.truncate_label = 15
my_config.show_y_guides = False
my_config.width = 1000
line_chart = pygal.Bar(my_config, style=my_style)
line_chart.title = 'Most-Starred Java Projects On Github'
line_chart.x_labels = map(str, names)
line_chart.add('', plot_dicts)
line_chart.render_to_file('Java_repo.svg')