Browse Source

Merge branch 'master' of github.com:Kozea/pygal

pull/185/head
Florian Mounier 10 years ago
parent
commit
0830ee0f69
  1. 3
      demo/cabaret.py
  2. 4
      demo/cabaret/templates/_layout.jinja2
  3. 8
      pygal/config.py
  4. 5
      pygal/ghost.py
  5. 20
      pygal/graph/line.py

3
demo/cabaret.py

@ -58,4 +58,5 @@ else:
add_w_builtin()
app.wsgi_app = WdbMiddleware(app.wsgi_app, start_disabled=True)
app.run(debug=True, threaded=True, host='0.0.0.0', port=12221)
if __name__ == '__main__':
app.run(debug=True, threaded=True, host='0.0.0.0', port=12221)

4
demo/cabaret/templates/_layout.jinja2

@ -4,8 +4,8 @@
<title>Cabaret - Online pygal graph generator</title>
<script type="text/javascript" src="{{ url_for('static', filename='components/jquery/jquery.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='components/bootstrap/docs/assets/js/bootstrap.min.js') }}"></script>
<script type="text/javascript" src="http://kozea.github.com/pygal.js/javascripts/svg.jquery.js"></script>
<script type="text/javascript" src="http://kozea.github.com/pygal.js/javascripts/pygal-tooltips.js"></script>
<script type="text/javascript" src="http://kozea.github.io/pygal.js/javascripts/svg.jquery.js"></script>
<script type="text/javascript" src="http://kozea.github.io/pygal.js/javascripts/pygal-tooltips.js"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js.js') }}"></script>
<link rel="stylesheet" href="{{ url_for('static', filename='components/bootstrap/docs/assets/css/bootstrap.css') }}" type="text/css" />
<link rel="stylesheet" href="{{ url_for('static', filename='css.css') }}" type="text/css" />

8
pygal/config.py

@ -303,6 +303,10 @@ class Config(CommonConfig):
"%Y-%m-%d %H:%M:%S.%f", str, "Label",
"Date format for strftime to display the DateY X labels")
missing_value_fill_truncation = Key(
"x", str, "Look",
"Filled series with missing x and/or y values at the end of a series are closed at the first value with a missing 'x' (default), 'y' or 'either'")
# Value #
human_readable = Key(
False, bool, "Value", "Display values in human readable format",
@ -382,8 +386,8 @@ class Config(CommonConfig):
# Misc #
js = Key(
('http://kozea.github.com/pygal.js/javascripts/svg.jquery.js',
'http://kozea.github.com/pygal.js/javascripts/pygal-tooltips.js'),
('http://kozea.github.io/pygal.js/javascripts/svg.jquery.js',
'http://kozea.github.io/pygal.js/javascripts/pygal-tooltips.js'),
list, "Misc", "List of js file",
"It can be a filepath or an external link",
str)

5
pygal/ghost.py

@ -142,6 +142,11 @@ class Ghost(object):
"""Render the graph, and return a Flask response"""
from flask import Response
return Response(self.render(**kwargs), mimetype='image/svg+xml')
def render_django_response(self, **kwargs):
"""Render the graph, and return a Django response"""
from django.http import HttpResponse
return HttpResponse(self.render(**kwargs), mimetype='image/svg+xml')
def render_to_file(self, filename, **kwargs):
"""Render the graph, and write it to filename"""

20
pygal/graph/line.py

@ -56,11 +56,21 @@ class Line(Graph):
# Check to see if the data has been padded with "none's"
# Fill doesn't work correctly otherwise
end = -1
for i, (x, y) in enumerate(reversed(values)):
if x is not None:
end = -1 - i
break
end = len(values)-1
while end > 0:
x, y = values[end]
if self.missing_value_fill_truncation == "either":
if x is not None and y is not None:
break
elif self.missing_value_fill_truncation == "x":
if x is not None:
break
elif self.missing_value_fill_truncation == "y":
if y is not None:
break
else:
raise ValueError("Invalid value ({}) for config key 'missing_value_fill_truncation'; Use 'x', 'y' or 'either'".format(self.missing_value_fill_truncation))
end -= 1
return ([(values[0][0], zero)] +
values +

Loading…
Cancel
Save