gizak / gizak/termui

BarChart widget style inconsistencies

Open
#285 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
13.6k
Forks
819
PR merge metrics
No merged PRs in 30d

Description

There are a couple `BarChart` UI inconsistencies I found when using this library.

**Issue 1**
The percent text value _always starts_ from the bar center position.

While this looks great when working with one character `Data` values (as pictured in the [termui example](https://raw.githubusercontent.com/nuxy/termui/master/_assets/demo.gif)) it looks awkward when dealing with long values since items greater than `BarWidth / 2` end up bleeding into the next bar. The position should be calculated based on the character length and `BarWidth` size available.

**Issue 2**
The bar is not completely rendered when `Data` values `< 2%` exist. I'm not sure this is intentional but the chart should maintain consistent sizing in regard to the bar width even if the value is `1%` or less.

### Before

![Before](https://user-images.githubusercontent.com/1234102/101308364-8c4cdb00-37fe-11eb-9ef4-f32dd993a821.png)

### After

![After](https://user-images.githubusercontent.com/1234102/101308383-9373e900-37fe-11eb-908c-c3cb5df4e465.png)

I have [created a PR](https://github.com/gizak/termui/pull/284) that contains changes to resolve the issues above. The overall goal is to have these items fixed upstream so I don't have to include a modified version of the `barchart.go` file in [my project](https://github.com/nuxy/go-crypto-market-ui/blob/master/lib/widgets/holdings.go) source.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with barchart.go and compare the existing BarChart behavior with the changes proposed in PR #284. Verify that percent labels are positioned within each bar for long values and that values below 2% still render consistent bar widths.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.