peterbrittain / asciimatics

A cross platform package to do curses-like operations, plus higher level APIs and widgets to create text UIs and ASCII art animations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Display current value in chart.

MrCasCode opened this issue · comments

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.

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?

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?

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).