Add some output buffering to the getModuleTreeData action so that PHP notices and errors don't break the JSON.
Add configs to the chart types so we can pass through, for example legend settings.
Add legend to the page.
Add a call to SUGAR.util.doWhen before setting up the field tree. Otherwise the sugar ajax ui could cause the setup code to run before jqtree was loaded.
Small cleanup - moving functions to appropriate files.
Fix issues caused by the change in how a join alias is chosen. Notably fix broken links and broken where clauses.