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

BarChart widget style inconsistencies #285

Open
nuxy opened this issue Dec 8, 2020 · 3 comments
Open

BarChart widget style inconsistencies #285

nuxy opened this issue Dec 8, 2020 · 3 comments

Comments

@nuxy
Copy link

nuxy commented Dec 8, 2020

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

After

After

I have created a PR 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 source.

@justmeandopensource
Copy link

Has this not been merged into upstream yet? I am facing these exact inconsistencies three years later. Thanks.

@nuxy
Copy link
Author

nuxy commented Aug 23, 2023

Has this not been merged into upstream yet? I am facing these exact inconsistencies three years later. Thanks.

I would consider this library unsupported considering no major activity has occurred in the last 4 years.

It's a shame considering the amount of people who use it.

The author should reassign rights to the Github project if they are not going to maintain it in the long term.

@justmeandopensource
Copy link

Yeah. Anyways, thanks for your fix and I am using your version in my project. Looks a lot better now.
I am dealing with currencies as data in the bar chart. The Data field is []float64 type. If I just use the Data field as it is with float64, then your fix works fine. However, if I use the NumFormatter to format my numbers to have currency symbol as prefix, then the alignment goes weird.

barChart.NumFormatter = func(value float64) string {
		return fmt.Sprintf("£%0.2f", value)
	}

So i am just falling back to using just the numbers to be displayed within the bar. It would be nice to show the symbol as well, but i will have to look into fixing it.

Thanks for your fix.

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

No branches or pull requests

2 participants