Skip to content

Commit

Permalink
ignore math.NaN() values when drawing plots
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Ressel <[email protected]>
  • Loading branch information
markusressel committed Oct 10, 2024
1 parent ddfd015 commit 2993b79
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions plot.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tvxwidgets
import (
"fmt"
"image"
"math"
"strconv"
"sync"

Expand Down Expand Up @@ -292,6 +293,10 @@ func (plot *Plot) drawDotMarkerToScreen(screen tcell.Screen) {

for j := 0; j < len(line) && j*plotHorizontalScale < width; j++ {
val := line[j]
if math.IsNaN(val) {
continue
}

lheight := int((val / plot.maxVal) * float64(height-1))

if (x+(j*plotHorizontalScale) < x+width) && (y+height-1-lheight < y+height) {
Expand All @@ -305,6 +310,10 @@ func (plot *Plot) drawDotMarkerToScreen(screen tcell.Screen) {
style := tcell.StyleDefault.Background(plot.GetBackgroundColor()).Foreground(plot.lineColors[i])

for j, val := range line {
if math.IsNaN(val) {
continue
}

lheight := int((val / plot.maxVal) * float64(height-1))

if (x+(j*plotHorizontalScale) < x+width) && (y+height-1-lheight < y+height) {
Expand Down Expand Up @@ -341,6 +350,10 @@ func (plot *Plot) calcBrailleLines() {
previousHeight := int((line[0] / plot.maxVal) * float64(height-1))

for j, val := range line[1:] {
if math.IsNaN(val) {
continue
}

lheight := int((val / plot.maxVal) * float64(height-1))

plot.setBrailleLine(
Expand Down

0 comments on commit 2993b79

Please sign in to comment.