names, plot_dicts = [], []
for repo_dict in repo_dicts:
names.append(repo_dict['name'])
plot_dict = {
'value': repo_dict['stargazers_count'],
'label': repo_dict['description'],
'xlink': repo_dict['owner']['html_url'],
}
plot_dicts.append(plot_dict)
my_style = LS('#333366', base_style=LCS)
chart = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False)
chart.title = 'Most-Stared Python Project On Github'
chart.x_labels = names
chart.add('', plot_dicts)
chart.render_to_file('new_repos.svg')
Run Code Online (Sandbox Code Playgroud)
*如果运行此命令,将出现错误。
Traceback (most recent call last):
File "new_repos.py", line 54, in <module>
chart.render_to_file('new_repos.svg')
File "C:\Users\Cao Kangkang\AppData\Roaming\Python\Python36\site-packages\pygal\graph\public.py", line 114, in render_to_file
f.write(self.render(is_unicode=True, **kwargs))
File "C:\Users\Cao Kangkang\AppData\Roaming\Python\Python36\site-packages\pygal\graph\public.py", line 52, in render
self.setup(**kwargs)
File "C:\Users\Cao Kangkang\AppData\Roaming\Python\Python36\site-packages\pygal\graph\base.py", line 217, in setup …Run Code Online (Sandbox Code Playgroud)