Skip to content

[RFC] Add a search box#2

Open
alexjbest wants to merge 5 commits into
eric-wieser:masterfrom
alexjbest:master
Open

[RFC] Add a search box#2
alexjbest wants to merge 5 commits into
eric-wieser:masterfrom
alexjbest:master

Conversation

@alexjbest
Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
Owner

No, that's #1

Comment thread index.html

// Feed the datalist autocomplete values:

searchSuggestions.innerHTML = graph.nodes().map(node=>"<option value=\"".concat(graph.getNodeAttribute(node, "label"), "\"></option>")).join("\n");
Copy link
Copy Markdown
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

Comment thread index.html
// autocomplete:

if (suggestions.length === 1 && suggestions[0].label === query) {
state.selectedNode = suggestions[0].id;
Copy link
Copy Markdown
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.

Comment thread index.html
// we consider the user has selected a node through the datalist
// autocomplete:

if (suggestions.length === 1 && suggestions[0].label === query) {
Copy link
Copy Markdown
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.

2 participants