[Feature Request] Display the number of sub-node in jmexpander when a node is not expanded
I would like to request a feature that the mindmap can display the number of sub-node in `jmexpander` when a node is not expanded.
https://github.com/hizzgdev/jsmind/blob/master/js/jsmind.js#L2698
I took a look at this code, we could add a parameter called view.display_child_count_in_expander in config. When it's enabled, expander_text is set to node.children.length.
By the way, I'm willing to submit a PR to make this happen, but I have two questions.
- Is there any idea to solve the problem that the fixed size of
jmexpandercauses numbers over 100 to be affected byoverflow: hiddenand cannot be displayed normally? - For
node_arrayorfreemindtype data, can we also directly usenode.children.lengthto get the number of sub-nodes?
Hi @NicodeSS , thanks for starting this discussion, and thanks for the following PR. Your idea is workable.
Let's look at the 2 questions:
About Q1
Is there any idea to solve the problem that the fixed size of jmexpander causes numbers over 100 to be affected by overflow: hidden and cannot be displayed normally?
There are 4 ways I can think of:
- use background images
- change the font size in the inline style when the number >
99 - use
9+when the number >9, or use99+when the number >99 - move the numbers to tooltip, show them when mouse over
About Q2
For node_array or freemind type data, can we also directly use node.children.length to get the number of sub-nodes?
Yes, we can.
Other ideas about the feature
TL;DR
I don't think it's a real requirement for general mind maps unless your project requires it. And you may need to deep dive the real requirement of your project.
Use Cases
- why do we want to know how many sub nodes there are?
- do we want to know the count of the 2-level nodes?
Feature Details
- do we still want to know the number of sub nodes when they are expanded?
- do we need to update the number when sub nodes changed?
- is
0required for a node without children? - how to indicate whether a node is expanded or collapsed?
Customization
- can the color of the numbers be customized?
- can the font-size be changed?
- how to enable this feature only for some nodes?
Q1
I prefer the way 2, but there is a question that different layout.pspace require different font sizes, how do we compute that?
I can't understand the way 1, can you explain it further?
It seems that the way 3 and 4 are unavailable, because the way 3 doesn't solve the lack of space and the way 4 is not obvious enough.
why do we want to know how many sub nodes there are?
I think that, on the contrary, it is common to need to find out how many child nodes a particular node has. This can help readers better manage their expectations about the amount of content that will be expanded, and sometimes even extract specific information. For example, if a node describes "the ways to succeed" and has 5 children, we can easily understand that the author intends to present it is five different ways to succeed that are described here.
do we want to know the count of the 2-level nodes?
Maybe, but I have no good idea to solve this.
do we still want to know the number of sub nodes when they are expanded?
In my opinion, we don't.
do we need to update the number when sub nodes changed?
Yes, however, we don't need to do anything special, as the map updates automatically every time a node is expanded or collapsed, based on my observations.
is 0 required for a node without children?
No, a node without children doesn't have a expander. The number only appears in the expander of a expandable node.
how to indicate whether a node is expanded or collapsed?
I think whether there's a wire next to expander is enough to tell you something about its state. No one would enable this feature on a map without lines, would they?
can the color of the numbers be customized? / can the font-size be changed?
Of course, just use css selector jmnodes jmexpander{ color: #fff; font-size: 10px, line-height: 16px } (assume that layout.pspace = 16)
how to enable this feature only for some nodes?
I prefer to have this feature enabled globally only. I can't imagine a scenario where we would need to enable it partially.
Thanks for the detailed explanation @NicodeSS
For the 1st solution about Q1, use a background image means using background images instead of the literal numbers 1,2,3...999... etc., In this way, 1 and 999 can be shown with pictures of the same size. The pictures would look like 1️⃣ 🔟 🔢 etc.
For the other questions, you gave the such detailed consideration, so I give you my best thanks, since i don't think it's an easy job.
Additionally, you may noticed that there is an ES6 version of jsMind, we would better to add the feature in that version.
BTW, is the feature requirement derived from your project? or just from your mind?
Q1 - 1
It sounds like solution 2, but more complex.
BTW, is the feature requirement derived from your project? or just from your mind?
It's derived from my project. I have to re-inject expander every time the view is updated. It's pretty painful.