You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can confirm I am having the same issue. I am using bar charts to display switch positions (1 = on, 0 being off), and 5 switches in a bar chart. If all are 0, the whole ui crashes, my CPU usage goes through the roof, and its all rather unpleasant.
I just found the issue, and I've put in a pretty dodgy fix on my bar chart val
I added the following on line 48 of termui/v3/widgets/barchart.go
if maxVal == 0 {
maxVal = 1
}
So that section now looks like this
maxVal := self.MaxVal
if maxVal == 0 {
maxVal, _ = GetMaxFloat64FromSlice(self.Data)
}
if maxVal == 0 {
maxVal = 1
}
barXCoordinate := self.Inner.Min.X
for i, data := range self.Data {
Basically, if the maxVal is still 0 after the last check, then set it to 1 (because 0 / 0 did not go down so well on line 53)
I would submit this, but Git and Me just dont understand each other, and someone probably can come up with a more elegant solution. This is a bit of a hack to get it working, but it did the job for me.
Cheers
Activity
doatesy commentedon Sep 7, 2019
I can confirm I am having the same issue. I am using bar charts to display switch positions (1 = on, 0 being off), and 5 switches in a bar chart. If all are 0, the whole ui crashes, my CPU usage goes through the roof, and its all rather unpleasant.
doatesy commentedon Sep 7, 2019
I just found the issue, and I've put in a pretty dodgy fix on my bar chart val
I added the following on line 48 of termui/v3/widgets/barchart.go
So that section now looks like this
Basically, if the
maxValis still 0 after the last check, then set it to 1 (because 0 / 0 did not go down so well on line 53)I would submit this, but Git and Me just dont understand each other, and someone probably can come up with a more elegant solution. This is a bit of a hack to get it working, but it did the job for me.
Cheers
barryodev commentedon Apr 23, 2021
I've come across this same issue, I'm not rendering the barchart data if its all zeros but the bug still exists