-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats_generateimage.py
92 lines (81 loc) · 2.31 KB
/
stats_generateimage.py
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
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from colorutils import get_random_color_palette
import logging as lg
def generate_stats_image(langstats: dict, activitystats: dict):
lg.info("Starting to generate random colors!")
langstatscolorpalette = get_random_color_palette()
activitystatscolorpalette = langstatscolorpalette
languages = list(langstats.keys())
languageSizes = list(langstats.values())
fig = make_subplots(
rows=1,
cols=3,
column_widths=[0.475, 0.025, 0.5],
specs=[
[
{"type": "pie"},
None,
{"type": "bar"}
]
]
)
fig.add_trace(go.Pie(
labels=languages,
values=languageSizes,
hole=.5,
textinfo='label+percent',
textfont=dict(
color='white',
size=10),
marker=dict(
colors=langstatscolorpalette,
line=dict(
color='rgba(25,25,25,1)',
width=5)),
showlegend=False
), row=1, col=1)
dates = list(activitystats.keys())
commits = list(activitystats.values())
fig.add_trace(go.Bar(x=commits,
y=dates,
marker_color=activitystatscolorpalette,
orientation='h',
), row=1, col=3
)
fig.update_xaxes(zeroline=False,
tickfont=dict(
color='white',
size=10),
showgrid=False,
linecolor='rgba(25,25,25,1)',
linewidth=2)
fig.update_yaxes(zeroline=False,
tickfont=dict(
color='white',
size=10),
showgrid=False,
linecolor='rgba(25,25,25,1)',
linewidth=2)
fig.update_layout(
height=400,
width=800,
margin=go.layout.Margin(
l=25,
r=25,
b=35,
t=50,
pad = 4
),
title=dict(
text='Languages & Activity Log (Commits)',
font=dict(
color='white',
size=16),
x=.5,
y=.95),
paper_bgcolor='rgba(25,25,25,1)',
plot_bgcolor='rgba(25,25,25,1)',
showlegend=False)
fig.write_image("githubstatsimage.png")
lg.info("Generate Image Completed!")