Implement Search Mechanism#98
Open
uvotguy wants to merge 1 commit into
Open
Conversation
|
Great job! Do you have any example how to addNode or delete Node in run time? Best regards, |
|
@uvotguy , @taniqsut , @T-Scott-Koch I ported treantjs to Typescript. You can try https://www.npmjs.com/package/pointlinejs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello,
I'm new at github, so forgive me if I'm doing things out of order. Also, I'm not an ace JavaScript programmer, so there may be a better way of doing some of these things.
I've implemented a search mechanism for Treant-js trees. It's not really functionality related to tree drawing, but more in the nature of useful utilities. So I added new file TreantUtil.js and TreantUtil.css.
The problem I'm trying to solve is this. You have a large organization with many subunits. You want to find "Joe Engineer", and you want to know who he works for. This is a very common use for an Org Chart.
Insert a couple of web controls in your index file, like those found in examples/search/index.html, and you'll be able to quickly find people. It starts by collapsing the tree (assuming branches are collapsible) and fading (lowering the opacity of) all nodes. The code searches all nodes for the search term, and make an array of them. For each matching node, it uncollapses the node's parent and unfades the node and its parent. Repeat till you get to the top of the tree.
When it's done, you'll see all nodes and their parents. It seems to work fine on all devices I've tried (though a limited number).
NOTE: the "Expand All", "Collapse All", and "Reset" functions are a biproduct of the search algorithm. I included the buttons in the example, but perhaps they could be separated out as stand-alone examples.
Please let me know what you think. If it's not something you're interested in, I'll delete my fork and use the code on my company's website. No worries!
Scott Koch