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

Text search on canvas #2986

Closed
1 task
PoojaUppalapati opened this issue Nov 6, 2020 · 4 comments
Closed
1 task

Text search on canvas #2986

PoojaUppalapati opened this issue Nov 6, 2020 · 4 comments
Assignees
Labels

Comments

@PoojaUppalapati
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

When nodes and combos are drawn on canvas, there is no way to search for some text within those nodes

Environment Info
g2 4.0.15
System -
Browser -

When there is a large graph, it will be helpful to the user to search for something and find it rather than expand each node

@hustcc
Copy link
Member

hustcc commented Nov 7, 2020

很好的建议。

类似语雀的 canvas 文本搜索,基于 G 的栈,都能使用一套方案,我们最近试试,如果感兴趣的,也可以参入,我来指导你实现。

@hustcc hustcc self-assigned this Nov 7, 2020
@hustcc
Copy link
Member

hustcc commented Nov 7, 2020

nice suggestion.

Similar to the canvas text search of Yuque, based on the G stack, we can use one set of solutions on G2 G2Plot G6.

We recently tried it. If you are interested, you can also participate. I will guide you to implement it.

@PoojaUppalapati
Copy link
Author

Yes, please, I would like to try

@hustcc
Copy link
Member

hustcc commented Nov 12, 2020

How

G2 and G6 all based on antvis/g . G has a model layer which contains all the node information, and the data structure of no is TREE. Text is a node type in G. so:

  1. We should get the G instance from G2/G6 instance
  2. Recursive traversal the node tree of G
  3. Filter out the nodes with type = 'text'
  4. Get all the text information, include: x, y, width, height, text, font, as var named textInfoArray
  5. generate text dom node with html by textInfoArray, and set the style color: transparent
  6. done

Press ctrl+f to test.

API design

import GTS rom 'g-text-search';

// G2 instance
const chart = new Chart('container', { ... });

// new with G instance
const gts = new GTS(chart.canvas);

gts.generate('container');

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

No branches or pull requests

3 participants