Skip to content

Commit 23d489c

Browse files
minor fixes
1 parent 0f884be commit 23d489c

5 files changed

+96
-98
lines changed

d3_lib.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def set_styles(css_file_names):
1818
return "<style>" + style + "</style>"
1919

2020

21-
def draw_graph(type, data):
21+
def draw_graph(type, data_dict):
2222

2323
JS_text = Template('''
2424
@@ -31,8 +31,8 @@ def draw_graph(type, data):
3131
''')
3232

3333
divnum = int(random.uniform(0,9999999999))
34-
34+
data_dict['divnum'] = divnum
3535
main_text_template = Template( open(this_dir() + '/js/' + type + '.js','r').read() )
36-
37-
main_text = main_text_template.safe_substitute({'divnum': divnum, 'data': str(data)})
36+
main_text = main_text_template.safe_substitute(data_dict)
37+
3838
return JS_text.safe_substitute({'divnum': divnum, 'main_text': main_text})

hello_dom.ipynb

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"metadata": {},
66
"source": [
77
"# Hello DOM!\n",
8-
"## A one-step at a time introduction to using D3 in Jupyter"
8+
"\n",
9+
"A one-step at a time introduction to using D3 in Jupyter"
910
]
1011
},
1112
{

js/force_directed_graph.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ var width = 960,
77
var color = d3.scale.category20();
88

99
var force = d3.layout.force()
10-
.charge(-120)
11-
.linkDistance(300)
10+
.charge(-300)
11+
.linkDistance(50)
1212
.size([width, height]);
1313

1414
d3.select("#maindiv${divnum}").selectAll("svg").remove();
@@ -18,7 +18,7 @@ var svg = d3.select("#maindiv${divnum}").append("svg")
1818

1919
//d3.json("miserables.json", function(error, graph) {
2020
// if (error) throw error;
21-
var graph = $data;
21+
var graph = $data ;
2222

2323
force
2424
.nodes(graph.nodes)
@@ -35,7 +35,7 @@ var graph = $data;
3535
.data(graph.nodes)
3636
.enter().append("circle")
3737
.attr("class", "node")
38-
.attr("r", 5)
38+
.attr("r", 8)
3939
.style("fill", function(d) { return color(d.group); })
4040
.call(force.drag);
4141

0 commit comments

Comments
 (0)