From 7fb8d1209a3926329638fc3ca5f0b4bc428029f6 Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 13 Jun 2014 08:54:26 -0400 Subject: Catch flotr2 exceptions, otherwise downstream AngularJS doesn't execute --- .../java/com/gitblit/wicket/charting/Flotr2Charts.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main/java/com/gitblit/wicket/charting/Flotr2Charts.java b/src/main/java/com/gitblit/wicket/charting/Flotr2Charts.java index dd723622..7a8adcf2 100644 --- a/src/main/java/com/gitblit/wicket/charting/Flotr2Charts.java +++ b/src/main/java/com/gitblit/wicket/charting/Flotr2Charts.java @@ -32,24 +32,30 @@ public class Flotr2Charts extends Charts { @Override public void renderHead(IHeaderResponse response) { - + // add Google Chart JS API reference ServletContext servletContext = WebApplication.get().getServletContext(); String contextPath = servletContext.getContextPath(); - + response.renderJavascriptReference(contextPath + "/bootstrap/js/jquery.js"); response.renderJavascriptReference(contextPath + "/flotr2/flotr2.min.js"); response.renderCSSReference(contextPath + "/flotr2/flotr2.custom.css"); - + // prepare draw chart function StringBuilder sb = new StringBuilder(); - + line(sb, "$( document ).ready(function() {"); + line(sb, "try {"); // add charts to header for (Chart chart : charts) { chart.appendChart(sb); } - + line(sb, "} catch (exception) {"); + line(sb, " if (window.console && window.console.log) {"); + line(sb, " window.console.log('flotr2 exception');"); + line(sb, " window.console.log(exception);"); + line(sb, " }"); + line(sb, "}"); // end draw chart function line(sb, "});"); response.renderJavascript(sb.toString(), null); @@ -72,5 +78,5 @@ public class Flotr2Charts extends Charts { String valueName) { return new Flotr2BarChart(tagId, title, keyName, valueName); } - + } -- cgit v1.2.3