-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathvisualize.py
More file actions
34 lines (22 loc) · 942 Bytes
/
Copy pathvisualize.py
File metadata and controls
34 lines (22 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
import jinja2 as jin
import json
from IPython.core.display import display, HTML
from . import __path__
def plot_circle(data, id=1):
path = os.path.join(os.path.dirname(__file__), '.')
template_env = jin.Environment(loader=jin.FileSystemLoader(path))
index = template_env.get_template('circle.tpl')
d3_src = '/nbextensions/d3.v3.min.js'
output = index.render( { 'nodes': json.dumps(data),
'id': id,
'd3_url': d3_src })
return display(HTML(output.decode('utf-8')))
def plot_chords(id=1):
path = os.path.join(os.path.dirname(__file__), '.')
template_env = jin.Environment(loader=jin.FileSystemLoader(path))
index = template_env.get_template('chord.tpl')
d3_src = '/nbextensions/d3.v3.min.js'
output = index.render( {'id': id,
'd3_url': d3_src })
return display(HTML(output.decode('utf-8')))