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

badges' bahaviour differ from doc's description #301

Open
ZhongYic00 opened this issue Sep 21, 2021 · 5 comments
Open

badges' bahaviour differ from doc's description #301

ZhongYic00 opened this issue Sep 21, 2021 · 5 comments

Comments

@ZhongYic00
Copy link

Describe the bug
Badges cannot be removed once set.

To Reproduce

Expected behavior

  • Could toggle visibility by setting visible:true|false as described in graphin documentation .
  • Or could be removed by updateItem or setting statusStyle .

Desktop (please complete the following information):

  • OS: Linux
  • Browser: any
  • Version: any
@ZhongYic00 ZhongYic00 changed the title badges badges' bahaviour differ from doc's description Sep 21, 2021
@cliffordfajardo
Copy link

Hi @ZhongYic00 - can you create a small reproducible code sample?

I'm hoping it only takes a few minutes 😄 , but it will help save other reviewers / community members with the code
This will make it easier to debug the issue and revisit the code as well

I've used stackblitz to create several code samples in the past using Graphin like this one:

  • stackblitz.com/edit/react-ts-ma2vpb
  • react-ts-ma2vpb.stackblitz.io

@ZhongYic00
Copy link
Author

@cliffordfajardo
I just forked your demo project and implemented BadgeSetting in example6, here it is

  • https://react-ts-cyayxs.stackblitz.io/example6
    So using this feature again draws me back to my confusing point:
  • In graphin's documentation I've learned that multiple badges can be set so it uses a list to store styles separately.
  • If I set one badge at 'LT', then how can I update its style?
    • I've tried only write the changed part like {badges:[position:'LR']}, then it seems to replace whole list with the new one internally.
    • Or if I write the entire style like {badges:[value:..., size: ...,file: ..., visible: ... , position: ... ]}, then position is right but still attribute visible doesn't seem to work
      All these can be easily tested modifying my (possibly wrong) fork.

@cliffordfajardo
Copy link

To be honest it won't be for another few days until I understand more about the API's to style the nodes; I'm still very new to the library.

What I've done to help me progress is:

  • download this repository git clone https://github.com/antvis/Graphin.git
  • look at the code inside the docs folder https://github.com/antvis/Graphin/tree/master/packages/graphin/docs

They have lots of examples (not all relevant) but some of them are for updating the appearance of nodes

Sorry I wasn't too helpful at this time of posting this comment

@ZhongYic00
Copy link
Author

Thanks for your sincere advice, to view their source code inside is burdensome yet helpful.

I believe I've found the inner implementation at https://github.com/antvis/G6/blob/master/packages/core/src/graph/controller/item.ts where the updated value of type Array directly replace the old rather than merge together. The callstack I guess is graphin.updateItem => graphin.setItemState => g6.graph.controller.updateItem. Maybe here's the bug.

Btw, there doesn't seem to be many examples concerning the badges feature, which might not be widely used.

@Caterpillarcc
Copy link

it seems I've met the question as you too。
when i change the text in Badges, it cannot be updated.

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

No branches or pull requests

3 participants