def display_index(): """Display index template.""" characters = Character.all() series = Series.all() return render_template("index.html", characters=characters, series=series)
def get_data_for_d3(): json = {"nodes":[], "links":[]} characters = Character.all() relationships = Relationship.query.all() characters = sorted(characters, key=lambda c:c.char_id) for c in characters: node = {} node["name"] = c.name node["group"] = c.group json["nodes"].append(node) for r in relationships: link = {} link["source"] = r.char1_id - 1 link["target"] = r.char2_id - 1 link["value"] = r.threshold json["links"].append(link) return jsonify(json)