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
Horizontal Barchart does not print labels #499
Comments
I can work on that. I'm wondering how should we handle something like this. let data = vec![
("January", 10),
("February", 20),
("March", 30),
("April", 40),
("May", 50),
("June", 60),
]; Bars should always be aligned so we have to have a max label length somehow. I'd suggest having an option to configure the |
this is not a bug, It is a feature to use the space more efficiently 😃 and force you to print what you need on the bar instead |
I'll wait to see what maintainers have to say. I understand your logic but then there is a useless setter when using horizonal bars. I'd say it's better to add the label as requested here, so users have the choice, and document the fact that this will use space and that could be avoided by using your technique. |
I don't quite understand the rationale / implementation in #518 of the length constraint. Looking at this test example: BarChart::default()
.direction(Direction::Horizontal)
.bar_gap(0)
.data(&[("January", 10), ("February", 20), ("March", 5)])
.label_max_len(1); Which renders as:
|
I just thought it would be useful.
I was thinking of some API (whether it be web, system, or from crate) that may return labels of different length. In that case it would be annoying to truncate the labels.
Both way are perfectly fine, just giving the possibility to the user. Overall, if you think this is too much, let's just remove it and only merge the fix. |
+1 Let's take this bit out for now like you said.
Its this bit I'm confused about - if you're getting the data from somewhere else, the likelyhood it's exactly in the shape of |
Fair enough. Kept only the fix. |
Labels were missed in the initial implementation of the horizontal mode for the BarChart widget. This adds them. Fixes #499
Description
Horizontal Barcharts were added recently (0.23.0), but labels were not implemented.
Barcharts have two label types: label and text_value (a formatted version of the value), only the latter is rendered.
To Reproduce
Expected behavior
Screenshots
Environment
version 0.23-alpha (main branch as of today)
Additional context
The text was updated successfully, but these errors were encountered: