Cabaret - Online pygal graph generator
-
-
+
+
diff --git a/pygal/config.py b/pygal/config.py
index bde5b79..6b5cbf3 100644
--- a/pygal/config.py
+++ b/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)
diff --git a/pygal/ghost.py b/pygal/ghost.py
index 7e1dab6..db9e4fd 100644
--- a/pygal/ghost.py
+++ b/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"""
diff --git a/pygal/graph/line.py b/pygal/graph/line.py
index 8226f1e..65e92f2 100644
--- a/pygal/graph/line.py
+++ b/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 +