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

Display current value in chart. #342

Open
MrCasCode opened this issue Jan 17, 2022 · 3 comments
Open

Display current value in chart. #342

MrCasCode opened this issue Jan 17, 2022 · 3 comments

Comments

@MrCasCode
Copy link

Is your feature request related to a problem? Please describe.
I'm trying to display in a label on a bar chart for the current rendered value.

Describe the solution you'd like
A method to display the currently displayed value

Describe alternatives you've considered
I've tried to use the label but it is not updating on each re render.

@peterbrittain
Copy link
Owner

I can see this is a common thing for charts, so probably a useful thing to add at some point. Not sure when I'll have the time to do it, but I could give you some pointers if you want to try adding the feature yourself.

If not, I'm slightly confused by your attempted workaround and we might be able to do something quick there... When you said that you tried using the label, did you mean changing the keys (which are used to name each bar)? If so, they should be redrawn every single update. How did you try to change them?

@MrCasCode
Copy link
Author

MrCasCode commented Jan 19, 2022

Exactly, I was using the keys. But you're right, after reading your comment I read my code again and I was not really changing them on redraw.

Right now I'm a bit busy and this feature is not a real priority. I'll give a try on properly using the keys as a workaround and post my results here.

Nonetheless, how many hours do you estimate it could take me to implement this feature following your guidelines?

@peterbrittain
Copy link
Owner

Thanks.

Work required depends on many factors... Assuming you know your way around Python, it's mainly a question of aesthetics and consistency. Do you want to:

  • be able to blend the value into the colour scheme used for the bar (or just use a fixed colour)?
  • handle edge cases nicely - e.g. truncate when the displayed value is longer than the bar?
  • handle this for both vertical and horizontal charts?
  • write the new tests for this feature?

A simple implementation (fixed colour, ignoring edge cases, just for horizontal bars with a single unit test) is pretty easy. Call it a few hours work, plus whatever you need to learn about internals of asciimatics. Adding matching colours will be trickier. Also the logic to draw vertical bars is a little harder. Probably the same effort again to do either of those individually, so doing it all would be a day or two (depending on how many bugs you hit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants