Source

brightway2-ui / bw2ui / web / app.py

Diff from to

bw2ui/web/app.py

 # -*- coding: utf-8 -*
-import base64
 from brightway2 import config, databases, methods, Database, Method
+from bw2analyzer import ContributionAnalysis
 from bw2calc import LCA
 from flask import Flask, url_for, render_template
+import base64
+import json
 
 app = Flask(__name__)
 
         lca = LCA(process, method)
         lca.lci()
         lca.lcia()
+        rt, rb = lca.reverse_dict()
+        context["treemap_data"] = json.dumps(ContributionAnalysis().d3_treemap(
+            lca.characterized_inventory.data, rb, rt))
         return render_template("lca.html", **context)
     else:
         return "No parameters"