Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Add a search box #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

alexjbest
Copy link

@alexjbest alexjbest commented Dec 17, 2021

I wanted to be able to find stuff in the graph so I hacked together a search box from some sigma.js examples, what do you think?
It needs some tidying up but if you think its a nice addition we can definitely discuss what the best way to include it is.

See https://alexjbest.github.io/mathlib-import-graph/

@alexjbest
Copy link
Author

@eric-wieser Do you have any more principled way of editing the code for this graph, i.e. do you generate it from typescript like it seems the Sigma demos do?
I wanted to add drag and drop to move nodes but just hacking around on the javascript feels like its going to get out of hand soon enough

@eric-wieser
Copy link
Owner

No, that's #1

@@ -395,6 +404,60 @@
},
});

// Feed the datalist autocomplete values:

searchSuggestions.innerHTML = graph.nodes().map(node=>"<option value=\"".concat(graph.getNodeAttribute(node, "label"), "\"></option>")).join("\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should sort these alphabetically

// autocomplete:

if (suggestions.length === 1 && suggestions[0].label === query) {
state.selectedNode = suggestions[0].id;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you merge state.selectedNode and state.defaultNode? I think they achieve the same goal here.

// we consider the user has selected a node through the datalist
// autocomplete:

if (suggestions.length === 1 && suggestions[0].label === query) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic doesn't work for data.int.basic, which matches multiple nodes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants