From 4765b541cd8a26ac584badbc5762e7f6758eac02 Mon Sep 17 00:00:00 2001 From: Brendan Smithyman Date: Wed, 6 May 2015 12:23:06 -0400 Subject: [PATCH] Change graph plotting style and enable doubleclick. Double-clicking on a graph node now inserts a new IPython Notebook cell and sets its text to the job listing for that node. --- SimPEG/Resources/Parallel/SystemGraph.html | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/SimPEG/Resources/Parallel/SystemGraph.html b/SimPEG/Resources/Parallel/SystemGraph.html index bccd10db..199d03b3 100644 --- a/SimPEG/Resources/Parallel/SystemGraph.html +++ b/SimPEG/Resources/Parallel/SystemGraph.html @@ -12,7 +12,7 @@ var graph = %(JSONData)s; require.config({paths: {d3: "http://d3js.org/d3.v3.min"}}); require(["d3"], function(d3) { - var width = 800, height = 450; + var width = 800, height = 450, radius = 8; var color = d3.scale.category10(); var domain = [0, 1, 2, 3]; @@ -28,7 +28,7 @@ require(["d3"], function(d3) { svg = d3.select("#%(uniqueID)s").append("svg") .attr("width", width) .attr("height", height); - }; + } force.nodes(graph.nodes) .links(graph.links) @@ -43,15 +43,24 @@ require(["d3"], function(d3) { .data(graph.nodes) .enter().append("circle") .attr("class", "node") - .attr("r", 5) + .attr("r", radius) .style("fill", function(d) { return color(d.status); }) + .call(force.drag); node.append("title") .text(function(d) { return d.id; }); + node.on("dblclick", function() { + n = d3.select(this); + name = n.text(); + graph = IPython.notebook.get_selected_cell().get_text(); + cell = IPython.notebook.insert_cell_below(); + cell.set_text(graph + ".node['" + name + "'].get('jobs', [])"); + }) + force.on("tick", function() { link.attr("x1", function(d) { return d.source.x; }) .attr("y1", function(d) { return d.source.y; })