Browse files

fixed a bug

  • Loading branch information...
1 parent 579f567 commit 8f184ae5636c44db2566c0e630eb2e451b6c4422 @rhblind committed Oct 10, 2012
Showing with 21 additions and 10 deletions.
  1. +13 −7 gcharts/templates/gcharts/gcharts.html
  2. +8 −3 gcharts/templatetags/gcharts.py
View
20 gcharts/templates/gcharts/gcharts.html
@@ -28,13 +28,19 @@
})();
function googlecharts_main() {
- if (typeof googlecharts == "undefined") return;
- for (var i = 0; i < googlecharts.length; ++i) {
- var c = googlecharts[i];
- var datatable = new google.visualization.DataTable(c.data);
- c.container = document.getElementById(c.container);
- var chart = new google.visualization[c.kind](c.container);
- chart.draw(datatable, c.options);
+ try {
+ if (typeof googlecharts == "undefined") return;
+ for (var i = 0; i < googlecharts.length; ++i) {
+ var c = googlecharts[i];
+ var datatable = new google.visualization.DataTable(c.data);
+ c.container = document.getElementById(c.container);
+ var chart = new google.visualization[c.kind](c.container);
+ chart.draw(datatable, c.options);
+ }
+ }
+ catch(err) {
+ err_msg = "Oops, something went wrong!\n" + err
+ alert(err_msg);
}
}
View
11 gcharts/templatetags/gcharts.py
@@ -41,8 +41,10 @@ def render(self, context):
js = self._nodelist.render(context)
pkg = context.get("pkg", None)
packages = [p for p in _packages]
- if (pkg is not None and pkg not in packages):
- packages.append(pkg)
+ if pkg is not None:
+ for p in pkg.split(","):
+ if p not in packages:
+ packages.append(p)
return self.render_template("gcharts/gcharts.html", googlecharts_js=js,
api=_api, packages=packages)
@@ -99,7 +101,10 @@ def render(self, context):
"""
if self.pkg is not "default":
if self.pkg in GOOGLECHARTS_PACKAGES:
- context["pkg"] = self.pkg
+ if context.get("pkg", None) is not None:
+ context["pkg"] = ", ".join((context["pkg"], self.pkg))
+ else:
+ context["pkg"] = self.pkg
else:
raise TemplateSyntaxError("%s is not a valid package. Valid packages are %s" \
% (self.pkg, ", ".join(GOOGLECHARTS_PACKAGES)))

0 comments on commit 8f184ae

Please sign in to comment.