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

Allow text truncation in the middle of the text or at the beginning #1925

Open
1 task
Tracked by #2320
markov00 opened this issue Jan 5, 2023 · 2 comments
Open
1 task
Tracked by #2320
Labels
enhancement New feature or request good first issue Good for newcomers :utils Related to utility functions like math, text, etc

Comments

@markov00
Copy link
Member

markov00 commented Jan 5, 2023

When text truncation is essential (too long label, no possibility to wrap) we use it to truncate labels.
Today, this truncation happens only at the end of the line, but there are cases where the truncation is better suited at the beginning or at the middle of the line.
The reason for this is to provide truncation support for text where the most relevant part of the text is at the end of the line or at both at the beginning and end.

This should be part of the truncation options we have in the wrapText function.

To discuss:

  • should we allow such middle/beginning truncation for multi-line wrappings? There are similar examples in the literature where a [...] is added in the middle of the text to "skip" part of a quoted discussion. Sometimes is used at the beginning of the quite, some other at the end of it. I'm not fully sure we need to introduce such complexity in a data visualization.
@markov00 markov00 added enhancement New feature or request :utils Related to utility functions like math, text, etc good first issue Good for newcomers labels Jan 5, 2023
@nickofthyme
Copy link
Collaborator

I thought about this being automatic such that we take all labels and truncate-out the largest common substring.

# Original
https://elastic-elastic-elastic.org/people/type:astronauts/name:aleksandr-laveykin/profile
https://elastic-elastic-elastic.org/people/type:astronauts/name:aleksei-yeliseyev/profile
https://elastic-elastic-elastic.org/people/type:astronauts/name:andrei-borisenko/profile
https://elastic-elastic-elastic.org/people/type:astronauts/name:arnaldo-tamayo-m-ndez/profile
https://elastic-elastic-elastic.org/people/type:astronauts/name:catherine-coleman/profile
https://elastic-elastic-elastic.org/people/type:astronauts/name:david-griggs/profile
https://elastic-elastic-elastic.org/people/type:astronauts/name:david-m-walker/profile
https://elastic-elastic-elastic.org/people/type:astronauts/name:david-saint-jacques/profile

# Truncated
https...name:aleksandr-laveykin/profile
https...name:aleksei-yeliseyev/profile
https...name:andrei-borisenko/profile
https...name:arnaldo-tamayo-m-ndez/profile
https...name:catherine-coleman/profile
https...name:david-griggs/profile
https...name:david-m-walker/profile
https...name:david-saint-jacques/profile

I'm not sure exactly how we handle the truncation of common data, here I just took the first and last words of the common substring.

Secondary truncation

Also not exactly sure how we would truncate the text after this, could just be a secondary truncation option. Such as truncate the common parts then truncate the end.

# End
https...name:aleksandr-lavey...
https...name:arnaldo-tamayo-...
                      limit 👉🏼 |

# Center - starts after common substring
https...name:...aveykin/profile
https...name:...-m-ndez/profile
                      limit 👉🏼 |

# Merged - could be a better name but merges truncation with the common substring truncation
https...ksandr-laveykin/profile
https...o-tamayo-m-ndez/profile
                      limit 👉🏼 |

Character vs width limit

Not sure how we differentiate between these two. I really don't like char limits so maybe we could use the textMeasure to perform a close width limit

@markov00
Copy link
Member Author

markov00 commented Jan 9, 2023

Interesting concepts @nickofthyme I definitely like the automated version. But I have doubts this is a common scenario. I hope for good field mapping of such keyword fields that consider those situations and for example, splits the host from the path of the URL.

With IDs, sequential ID, name/surname, etc we can't infer very well what is the good part to show and what to truncate unfortunately and most of the work done to "infer" could be wasted. But still a very nice improvement over the manual one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers :utils Related to utility functions like math, text, etc
Projects
None yet
Development

No branches or pull requests

2 participants