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
The BarChart widget in termui appears to fail to render correctly when the Data slice provided to it contains negative float values. When negative values are present in the Data, the entire termui application either displays a black screen or reverts to text-only output, and the graphical UI is not rendered.
Steps to Reproduce:
Create a termui application that includes a BarChart widget.
Populate the BarChart widget's Data slice with float values that include negative numbers.
Render the termui UI.
Code Example to Reproduce:
package main
import (
"log""time"
ui "github.com/gizak/termui/v3""github.com/gizak/termui/v3/widgets"
)
funcmain() {
iferr:=ui.Init(); err!=nil {
log.Fatalf("failed to initialize termui: %v", err)
}
deferui.Close()
bc:=widgets.NewBarChart()
bc.Title="Bar Chart with Negative Data"bc.SetRect(0, 0, 50, 10)
bc.BorderStyle.Fg=ui.ColorWhitebc.BarColors= []ui.Color{ui.ColorGreen}
bc.Data= []float64{-5, -8, -6, -9, -7} // Negative Data Valuesbc.Labels= []string{"A", "B", "C", "D", "E"}
ui.Render(bc)
uiEvents:=ui.PollEvents()
ticker:=time.NewTicker(1*time.Second).Cfor {
select {
casee:=<-uiEvents:
switche.ID {
case"q", "<C-c>":
return
}
case<-ticker:
// No data update needed for this example, just keep renderingui.Render(bc)
}
}
}
Expected Behavior:
The BarChart widget should render graphically even when the Data slice contains negative values. Ideally, the chart would visually represent both positive and negative bars relative to a zero baseline. Even if negative value visualization is not fully supported, the application should still render the UI without crashing or reverting to text-only mode.
Observed Behavior:
When the Data slice of the BarChart contains negative values (as in the example code above), the termui application fails to render the graphical UI. The terminal window either becomes completely black or only displays text output (like log messages), and the BarChart widget is not visible.
If the Data is changed to contain only positive values (e.g., bc.Data = []float64{5, 8, 6, 9, 7}), the BarChart renders correctly and the graphical UI works as expected.
Similarly, if the BarChart widget is removed from the UI, and only other widgets like Paragraph or Gauge are rendered, the application works graphically even with the original weather data (including negative temperatures in the forecast data, although they are not used for the removed BarChart).
Environment:
macos latest
go 1.23
Additional Information:
This issue was discovered while developing a weather TUI application that displays forecast temperatures using a BarChart. When fetching weather data for locations with sub-zero temperatures (resulting in negative values in the forecast data), the graphical UI failed to load. Through debugging, it was isolated to the presence of negative values in the BarChart's Data.
Suggestion:
Investigate the rendering logic of the BarChart widget, specifically how it handles negative data values.
Ideally, implement proper visualization of negative values in the BarChart.
As a minimum, ensure that negative values in BarChart.Data do not cause the entire termui application to fail to render graphically.
Please let me know if you need any further information or clarification to investigate this issue.
The text was updated successfully, but these errors were encountered:
The
BarChart
widget intermui
appears to fail to render correctly when theData
slice provided to it contains negative float values. When negative values are present in theData
, the entiretermui
application either displays a black screen or reverts to text-only output, and the graphical UI is not rendered.Steps to Reproduce:
termui
application that includes aBarChart
widget.BarChart
widget'sData
slice with float values that include negative numbers.termui
UI.Code Example to Reproduce:
Expected Behavior:
The
BarChart
widget should render graphically even when theData
slice contains negative values. Ideally, the chart would visually represent both positive and negative bars relative to a zero baseline. Even if negative value visualization is not fully supported, the application should still render the UI without crashing or reverting to text-only mode.Observed Behavior:
When the
Data
slice of theBarChart
contains negative values (as in the example code above), thetermui
application fails to render the graphical UI. The terminal window either becomes completely black or only displays text output (like log messages), and theBarChart
widget is not visible.If the
Data
is changed to contain only positive values (e.g.,bc.Data = []float64{5, 8, 6, 9, 7}
), theBarChart
renders correctly and the graphical UI works as expected.Similarly, if the
BarChart
widget is removed from the UI, and only other widgets likeParagraph
orGauge
are rendered, the application works graphically even with the original weather data (including negative temperatures in the forecast data, although they are not used for the removedBarChart
).Environment:
Additional Information:
This issue was discovered while developing a weather TUI application that displays forecast temperatures using a
BarChart
. When fetching weather data for locations with sub-zero temperatures (resulting in negative values in the forecast data), the graphical UI failed to load. Through debugging, it was isolated to the presence of negative values in theBarChart
'sData
.Suggestion:
BarChart
widget, specifically how it handles negative data values.BarChart
.BarChart.Data
do not cause the entiretermui
application to fail to render graphically.Please let me know if you need any further information or clarification to investigate this issue.
The text was updated successfully, but these errors were encountered: