Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

如何单独为每个节点设置线条颜色呢 #505

Closed
13994853095 opened this issue Oct 7, 2023 · 7 comments
Closed

如何单独为每个节点设置线条颜色呢 #505

13994853095 opened this issue Oct 7, 2023 · 7 comments

Comments

@13994853095
Copy link

请教一下,我正在实现一个有固定六个分类的思维导图,每个分类下面有2或3级的子节点。现在有6种固定的颜色用于每个分类的节点颜色和线条颜色,我通过jm.set_node_color给6个一级节点分别设置了颜色,那线条颜色有没有什么方法单独设置,我貌似只看到一个data.leading-line-color,这个怎么用呢,它会同时生效于每个分类子节点的线条颜色吗?

@hizzgdev
Copy link
Owner

hizzgdev commented Oct 7, 2023

leading-line-color 设置的是这个node指向其父节点的线条的颜色,仅作用于设置的那个节点(线条)

@13994853095
Copy link
Author

好的谢谢,所以按照这个逻辑,假设我的节点id是1,2,3,4,5,6,其下的子节点是1-1,1-2,2-1,2-1-1这种形式的话,我需要对每一个节点进行处理,给id以1开头的节点线条一个颜色,以2开头的一个颜色,然后以此类推,给这6类及其子节点分别设置6种线条颜色对吗

@hizzgdev
Copy link
Owner

hizzgdev commented Oct 7, 2023

https://hizzgdev.github.io/jsmind/docs/zh/1.usage.html

在这个文档的1.4 样式里提到了用法,感觉用这个还挺符合你的需求的。你可以在设置节点颜色的同时设置引导线的颜色。

@13994853095
Copy link
Author

好的明白了,我去尝试一下,谢谢

@hizzgdev
Copy link
Owner

hizzgdev commented Oct 7, 2023

好的谢谢,所以按照这个逻辑,假设我的节点id是1,2,3,4,5,6,其下的子节点是1-1,1-2,2-1,2-1-1这种形式的话,我需要对每一个节点进行处理,给id以1开头的节点线条一个颜色,以2开头的一个颜色,然后以此类推,给这6类及其子节点分别设置6种线条颜色对吗

逻辑上符合你的需求。至于如何标识是六类中的哪一类,你可以从数据上看怎么方便。如果数据在db里的话,不用id来标识也问题不大。还是看你方便。

@13994853095
Copy link
Author

哈喽哈喽,再叨扰一句,如果我的6类分支想实现:前三个默认展开至3级,后三个默认展开至2级,这个只能通过遍历设置每个节点的expanded来实现嘛

@hizzgdev
Copy link
Owner

hizzgdev commented Oct 9, 2023

应该不需要遍历所有节点,最好是在数据层面把前三个的所有二级节点id找出来并记下来,这样的话就可以用 jm.expand_to_depth(depth) 展开到2级,然后再遍历上面记下来的节点,给它展开就好了。

不过如果你能在 show 之前对脑图数据进行修改的话,其实就会更容易实现。

node 的数据结构大概是这样的:

{
    "id": "xxxx",
    "topic": "topic-xxx",
    "expanded": true
}

你只要把上面的 expanded 改成 false,它就默认会把子节点给收起来了。

Repository owner locked and limited conversation to collaborators Oct 19, 2023
@hizzgdev hizzgdev converted this issue into discussion #519 Oct 19, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants