Move graph generation logic into seperate file
This commit is contained in:
24
graph.py
Normal file
24
graph.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import pygal
|
||||
from pygal.style import Style
|
||||
|
||||
custom_style = Style(
|
||||
background='transparent',
|
||||
plot_background='transparent',
|
||||
foreground='#53E89B',
|
||||
foreground_strong='#53A0E8',
|
||||
foreground_subtle='#630C0D',
|
||||
opacity='.6',
|
||||
opacity_hover='.9',
|
||||
transition='400ms ease-in',
|
||||
colors=('#E853A0', '#E8537A', '#E95355', '#E87653', '#E89B53'))
|
||||
|
||||
|
||||
def generate_graph(x_labels, data, style=custom_style):
|
||||
graph = pygal.Line(show_y_guides=False,
|
||||
show_legend=False, style=style)
|
||||
graph.x_labels = x_labels
|
||||
|
||||
for title, values in data:
|
||||
graph.add(title, values)
|
||||
graph_data = graph.render_data_uri()
|
||||
return graph_data
|
||||
Reference in New Issue
Block a user