Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ export default {
},
mounted() {
this.renderer = createRenderer(appState.progress);
bus.on('query-change', q => {
if (appState.query !== q) {
appState.query = q;
this.onSubmit();
}
}, this);
bus.on('show-tooltip', this.showTooltip, this);
if (appState.graph) {
this.renderer.render(appState.graph);
Expand Down Expand Up @@ -121,6 +127,10 @@ export default {
color: highlight-color;
}

#nodes > * {
cursor: pointer;
}

rect, path, text {
transition: stroke 200ms, fill 200ms;
}
Expand Down
20 changes: 20 additions & 0 deletions src/lib/createRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,25 @@ export default function createRenderer(progress) {
}
}

function nodeClick(e) {
var target = e.target;
var textNode = null;
switch (target.nodeName) {
case 'g':
textNode = target.parentNode.querySelector('text');
break;
case 'text':
textNode = target;
break;
default:
break;
}
if (textNode != null) {
bus.fire('query-change', textNode.innerHTML);
console.log(textNode.innerHTML);
}
}

function addNode(node) {
const dRatio = (graph.maxDepth - node.data.depth)/graph.maxDepth;
let pos = getNodePosition(node.id);
Expand Down Expand Up @@ -173,6 +192,7 @@ export default function createRenderer(progress) {

nodeContainer.appendChild(ui);
nodes.set(node.id, ui);
nodes.forEach(node => node.addEventListener("click", nodeClick));
}


Expand Down