gizak / termui

Golang terminal dashboard
MIT License
13.06k stars 783 forks source link

BarChart widget style inconsistencies #285

Open nuxy opened 3 years ago

nuxy commented 3 years ago

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 commented 10 months ago

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

nuxy commented 10 months ago

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 commented 10 months ago

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.