|
|
@ -21,7 +21,7 @@ import pygal |
|
|
|
from pygal.config import Config |
|
|
|
from pygal.config import Config |
|
|
|
from pygal.util import cut |
|
|
|
from pygal.util import cut |
|
|
|
from pygal.graph import CHARTS_NAMES |
|
|
|
from pygal.graph import CHARTS_NAMES |
|
|
|
from pygal.style import styles |
|
|
|
from pygal.style import styles, parametric_styles |
|
|
|
from base64 import ( |
|
|
|
from base64 import ( |
|
|
|
urlsafe_b64encode as b64encode, |
|
|
|
urlsafe_b64encode as b64encode, |
|
|
|
urlsafe_b64decode as b64decode) |
|
|
|
urlsafe_b64decode as b64decode) |
|
|
@ -84,7 +84,9 @@ def create_app(): |
|
|
|
@app.route("/") |
|
|
|
@app.route("/") |
|
|
|
def index(): |
|
|
|
def index(): |
|
|
|
return render_template( |
|
|
|
return render_template( |
|
|
|
'index.jinja2', styles=styles, |
|
|
|
'index.jinja2', styles=styles, parametric_styles=parametric_styles, |
|
|
|
|
|
|
|
parametric_colors=( |
|
|
|
|
|
|
|
'#ff5995', '#b6e354', '#feed6c', '#8cedff', '#9e6ffe'), |
|
|
|
links=links, charts_name=CHARTS_NAMES) |
|
|
|
links=links, charts_name=CHARTS_NAMES) |
|
|
|
|
|
|
|
|
|
|
|
@app.route("/svg/<type>/<series>/<config>") |
|
|
|
@app.route("/svg/<type>/<series>/<config>") |
|
|
@ -95,19 +97,30 @@ def create_app(): |
|
|
|
return graph.render_response() |
|
|
|
return graph.render_response() |
|
|
|
|
|
|
|
|
|
|
|
@app.route("/sparkline/<style>") |
|
|
|
@app.route("/sparkline/<style>") |
|
|
|
def sparkline(style): |
|
|
|
@app.route("/sparkline/parameric/<style>/<color>") |
|
|
|
line = pygal.Line(style=styles[style], pretty_print=True) |
|
|
|
def sparkline(style, color=None): |
|
|
|
|
|
|
|
if color is None: |
|
|
|
|
|
|
|
style = styles[style] |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
style = parametric_styles[style](color) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
line = pygal.Line(style=style, pretty_print=True) |
|
|
|
line.add('_', [random.randrange(0, 10) for _ in range(25)]) |
|
|
|
line.add('_', [random.randrange(0, 10) for _ in range(25)]) |
|
|
|
return Response( |
|
|
|
return Response( |
|
|
|
line.render_sparkline(height=40), mimetype='image/svg+xml') |
|
|
|
line.render_sparkline(height=40), mimetype='image/svg+xml') |
|
|
|
|
|
|
|
|
|
|
|
@app.route("/all") |
|
|
|
@app.route("/all") |
|
|
|
@app.route("/all/style=<style>") |
|
|
|
@app.route("/all/<style>") |
|
|
|
|
|
|
|
@app.route("/all/<style>/<color>") |
|
|
|
@app.route("/all/interpolate=<interpolate>") |
|
|
|
@app.route("/all/interpolate=<interpolate>") |
|
|
|
def all(style='default', interpolate=None): |
|
|
|
def all(style='default', color=None, interpolate=None): |
|
|
|
width, height = 600, 400 |
|
|
|
width, height = 600, 400 |
|
|
|
data = random.randrange(1, 10) |
|
|
|
data = random.randrange(1, 10) |
|
|
|
order = random.randrange(1, 10) |
|
|
|
order = random.randrange(1, 10) |
|
|
|
|
|
|
|
if color is None: |
|
|
|
|
|
|
|
style = styles[style] |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
style = parametric_styles[style](color) |
|
|
|
xy_series = _random(data, order) |
|
|
|
xy_series = _random(data, order) |
|
|
|
other_series = [] |
|
|
|
other_series = [] |
|
|
|
for title, values in xy_series: |
|
|
|
for title, values in xy_series: |
|
|
@ -121,7 +134,7 @@ def create_app(): |
|
|
|
config.fill = bool(random.randrange(0, 2)) |
|
|
|
config.fill = bool(random.randrange(0, 2)) |
|
|
|
config.human_readable = True |
|
|
|
config.human_readable = True |
|
|
|
config.interpolate = interpolate |
|
|
|
config.interpolate = interpolate |
|
|
|
config.style = styles[style] |
|
|
|
config.style = style |
|
|
|
config.x_labels = [random_label() for i in range(data)] |
|
|
|
config.x_labels = [random_label() for i in range(data)] |
|
|
|
svgs = [] |
|
|
|
svgs = [] |
|
|
|
for chart in pygal.CHARTS: |
|
|
|
for chart in pygal.CHARTS: |
|
|
|