Skip to content

Commit 6f14a7c

Browse files
committed
right click on hook nodes, save style tweaks...
1 parent d5953d4 commit 6f14a7c

File tree

3 files changed

+38
-19
lines changed

3 files changed

+38
-19
lines changed

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@
7070
//var linkObjs = createTestLinks(3,3,3);
7171
//var linkObjs = createTestLinks(1,0,0);
7272
var linkObjs = createTestMultiLinks(1);
73-
73+
/*
7474
drawWords(wordObjs);
7575
drawLinks(linkObjs);
7676
7777
changeSizeOfSVGPanel(window.innerWidth - 16, (rows[rows.length - 1].lineBottom.y() ) + 1);
78-
78+
*/
7979
window.onload = function() {
8080

8181
const panel = new Panel('graph', 'drawing');
@@ -242,7 +242,7 @@
242242
};
243243
window.onresize = _.debounce(resize, 300);
244244

245-
changeDataset();
245+
changeDataset(2);
246246
};
247247

248248
</script>

js/GraphLayout.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,12 @@ class GraphLayout {
212212
drawNodes(root, i, el) {
213213
function handleNodeClick(d) {
214214
unhoverNode(d);
215-
let newArray = this.words.slice();
216-
let word = newArray.splice(i, 1, d.node)[0];
217-
if (newArray.indexOf(word) < 0) {
215+
let word = this.words.splice(i, 1, d.node)[0];
216+
if (this.words.indexOf(word) < 0) {
218217
word.toggleHighlight(false);
219218
}
220219
d.node.toggleHighlight(true);
221-
this.graph(newArray);
220+
this.graph(this.words);
222221
}
223222

224223
function hoverNode(d) {
@@ -316,7 +315,15 @@ class GraphLayout {
316315
.attr('transform', (d, i) => 'translate(-30,' + (-20 * i - 20) + ')')
317316
.on('mouseover', (d) => hoverNode.bind(this)(d))
318317
.on('mouseout', (d) => unhoverNode.bind(this)(d))
319-
.on('click', (d) => handleNodeClick.bind(this)(d));
318+
.on('click', (d) => handleNodeClick.bind(this)(d))
319+
.on('contextmenu', (d) => {
320+
d3.event.preventDefault();
321+
console.log('hey', d);
322+
let word = this.words.splice(i + 1, 0, d.node)[0];
323+
d.node.unhover();
324+
d.node.toggleHighlight(true);
325+
this.graph(this.words);
326+
});
320327

321328
inMerge.select('path')
322329
.attr('d', (d, i) => {

js/render.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ function drawAllLinkLabels() {
673673
lo.labelRectSVGs[ii] = label.rect( lo.labels[ii].rect.w, lo.labels[ii].rect.h )
674674
.x( lo.labels[ii].rect.x )
675675
.y( lo.labels[ii].rect.y )
676-
.addClass('link--label');
676+
.addClass(lo.isSelected ? 'link--label selected' : 'link--label');
677677

678678
lo.labelTextSVGs[ii] = label.text( lo.labels[ii].text.text )
679679
.x( lo.labels[ii].text.x )
@@ -1008,11 +1008,15 @@ function calculateOnlyRow(rowNum, link, percentagePadding, xPositions, linkStyle
10081008
var xL = arrowPos[0].x ; //xPositions[0];
10091009
var xR = arrowPos[arrowPos.length-1].x; //xPositions[link.words.length - 1];
10101010

1011+
var pathline = 'M' + [xL, arrowPos[0].y] +
1012+
'C' + [xL, yPos, xL,yPos, xL + 5, yPos] +
1013+
'L' + [xR - 5, yPos] +
1014+
'C' + [xR, yPos, xR, yPos, xR, arrowPos[arrowPos.length - 1].y];
10111015

1012-
var pathline = 'M '+ xL + ' ' + arrowPos[0].y +
1013-
' L ' + xL + ' ' + yPos +
1014-
' L ' + xR + ' ' + yPos +
1015-
' L ' + xR + ' ' + arrowPos[arrowPos.length - 1].y;
1016+
// var pathline = 'M '+ xL + ' ' + arrowPos[0].y +
1017+
// ' L ' + xL + ' ' + yPos +
1018+
// ' L ' + xR + ' ' + yPos +
1019+
// ' L ' + xR + ' ' + arrowPos[arrowPos.length - 1].y;
10161020

10171021
for (var p = 1; p < arrowPos.length - 1; p++) {
10181022
pathline +=
@@ -1075,9 +1079,13 @@ function calculateStartRow(idx, rowNum, link, percentagePadding, xPositions, lin
10751079

10761080

10771081
//can there be a start row with NO arrows??
1078-
var pathline = 'M '+ xL + ' ' + arrowPos[0].y +
1079-
' L ' + xL + ' ' + yPos +
1080-
' L ' + xR + ' ' + yPos;
1082+
var pathline = 'M' + [xL, arrowPos[0].y] +
1083+
'C' + [xL, yPos, xL,yPos, xL + 5, yPos] +
1084+
'L' + [xR, yPos];
1085+
1086+
// var pathline = 'M '+ xL + ' ' + arrowPos[0].y +
1087+
// ' L ' + xL + ' ' + yPos +
1088+
// ' L ' + xR + ' ' + yPos;
10811089

10821090
for (var p = 1; p < arrowPos.length; p++) {
10831091
pathline +=
@@ -1201,10 +1209,14 @@ function calculateEndRow(idx, rowNum, link, percentagePadding, xPositions, linkS
12011209
console.log("in calculateEndRow, xL = " + xL + ", xR = " + xR);
12021210

12031211

1212+
var pathline = 'M' + [xL, yPos] +
1213+
'L' + [xR - 5, yPos] +
1214+
'C' + [xR, yPos, xR, yPos, xR, arrowPos[arrowPos.length - 1].y];
1215+
12041216

1205-
var pathline = 'M ' + xL + ' ' + yPos +
1206-
' L ' + xR + ' ' + yPos +
1207-
' L ' + xR + ' ' + arrowPos[arrowPos.length-1].y;
1217+
// var pathline = 'M ' + xL + ' ' + yPos +
1218+
// ' L ' + xR + ' ' + yPos +
1219+
// ' L ' + xR + ' ' + arrowPos[arrowPos.length-1].y;
12081220

12091221
console.log("PATHLINE = " + pathline);
12101222

0 commit comments

Comments
 (0)