From 21516d658a867aedfc0fed9989cafbe3e7283616 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Mon, 2 Mar 2015 16:40:28 +0100 Subject: [PATCH 01/23] update graph and data * change graph node IDs to "node_"+ID * update getJSON url --- src/topicMapViz.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/topicMapViz.js b/src/topicMapViz.js index 1a7e170..cfb575d 100644 --- a/src/topicMapViz.js +++ b/src/topicMapViz.js @@ -158,7 +158,7 @@ function drawGraph(localLinks){ .data(force.nodes()) .enter().append("g") .attr("class", "node") - .attr("id", function(d) { return d.name.substring(1); }) + .attr("id", function(d) {return "node_" + d.name.substring(d.name.indexOf('#')+1); }) .on("mouseover", mouseover) .on("mouseout", mouseout) .on("click", onclick) @@ -212,6 +212,12 @@ clearFilters(); appendFilters($('#graph svg')); } +// helper functions + +/* + * filter jquery association objects by contained player + */ + function filterByMember (object, value) { // The real meat of the solution, you can use this directly if you want. @@ -230,6 +236,10 @@ function filterByMember (object, value) { return num } +/* + * filter json topic objects by id + */ + function filterById (object, value) { console.log('filter by id:'); @@ -260,6 +270,10 @@ function renderTopicDetail(detail){ } +/* + * render topic details to detail area + */ + function getTopicDetails(topic, i){ var newTopic = d3.select('#meta') @@ -310,6 +324,10 @@ function getTopicDetails(topic, i){ } +/* + * clear Detail area + */ + function clearTopicDetail(){ $('#meta').empty(); $('#graph').empty(); From 443186d8ee932cbfb82ecddd9f70cdea50dfb006 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Mon, 2 Mar 2015 17:26:35 +0100 Subject: [PATCH 02/23] add highlight for graph nodes --- index.html | 4 ++++ src/topicMapViz.js | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 551aa90..bd1893d 100644 --- a/index.html +++ b/index.html @@ -57,6 +57,10 @@ stroke-width: 1.5px; } +.node.highlight circle { + fill: #900; +} + text { font: 10px sans-serif; pointer-events: none; diff --git a/src/topicMapViz.js b/src/topicMapViz.js index cfb575d..3ba9708 100644 --- a/src/topicMapViz.js +++ b/src/topicMapViz.js @@ -67,9 +67,10 @@ function appendFilters(data){ $.each(data_nodes, function(i, item){ var name = item.textContent; + var id = item.id; console.log(name); if($.inArray(name, nodeNames == -1)){ - nodeNames.push(name); + nodeNames.push({"name": name, "id": id}); } } ); @@ -83,7 +84,7 @@ function appendFilters(data){ newEntry.append('span').classed('filterLabel', true).text(item.substring(item.indexOf('#')+1)); - newEntry.append('a').attr('onclick',"mapHighlight('"+item.substring(item.indexOf('#')+1)+"')").classed('filter_highlight', true).text('highlight'); + newEntry.append('a').attr('onclick',"mapHighlight('."+item.substring(item.indexOf('#')+1)+"')").classed('filter_highlight', true).text('highlight'); }); } @@ -92,8 +93,13 @@ function appendFilters(data){ .append('h4').text('Topics'); nodeNames.forEach(function(item, i){ - d3.select('#filters-nodes').append('div') - .text(item); + var newEntry = d3.select('#filters-nodes').append('div').classed('filter', true); + + newEntry.append('span').classed('filterLabel', true).text(item.name); + + newEntry.append('a').attr('onclick',"mapHighlight('#"+item.id+"')").classed('filter_highlight', true).text('highlight'); + + }); } @@ -109,7 +115,7 @@ function clearFilters(){ */ function mapHighlight(identifier){ //TODO impement toggle - var obj = $($('#graph .'+identifier)); + var obj = $($('#graph '+identifier)); var highlight_status = obj.attr('class').indexOf('highlight') > -1; console.log(highlight_status); if(highlight_status){ From 0fe9043fc9f669e60275d9caded3614cdbcfbb49 Mon Sep 17 00:00:00 2001 From: bwbohl Date: Mon, 2 Mar 2015 17:41:14 +0100 Subject: [PATCH 03/23] some CSS --- index.html | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index bd1893d..4ddc38e 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,9 @@