diff --git a/demos/plot/main.go b/demos/plot/main.go index 15ac5c0..0358b17 100644 --- a/demos/plot/main.go +++ b/demos/plot/main.go @@ -18,8 +18,10 @@ func main() { data[0] = make([]float64, n) data[1] = make([]float64, n) for i := 0; i < n; i++ { - data[0][i] = 1 + math.Sin(float64(i)/5) - data[1][i] = 1 + math.Cos(float64(i)/5) + data[0][i] = 1 + math.Sin(float64(i+1)/5) + // Avoid taking Cos(0) because it creates a high point of 2 that + // will never be hit again and makes the graph look a little funny + data[1][i] = 1 + math.Cos(float64(i+1)/5) } return data }() diff --git a/plot.go b/plot.go index 8f9c9cc..8c174a4 100644 --- a/plot.go +++ b/plot.go @@ -255,25 +255,15 @@ func (plot *Plot) drawDotMarkerToScreen(screen tcell.Screen) { } func (plot *Plot) drawBrailleMarkerToScreen(screen tcell.Screen) { - var cellMaxY int - x, y, width, height := plot.getChartAreaRect() plot.calcBrailleLines() - for point := range plot.getBrailleCells() { - if point.Y > cellMaxY { - cellMaxY = point.Y - } - } - - diffMAxY := y + height - cellMaxY - 1 - // print to screen for point, cell := range plot.getBrailleCells() { style := tcell.StyleDefault.Background(plot.GetBackgroundColor()).Foreground(cell.color) - if point.X < x+width && point.Y+diffMAxY < y+height { - tview.PrintJoinedSemigraphics(screen, point.X, point.Y+diffMAxY, cell.cRune, style) + if point.X < x+width && point.Y < y+height { + tview.PrintJoinedSemigraphics(screen, point.X, point.Y, cell.cRune, style) } } } @@ -288,7 +278,7 @@ func (plot *Plot) calcBrailleLines() { continue } - previousHeight := int((line[1] / maxVal) * float64(height-1)) + previousHeight := int((line[0] / maxVal) * float64(height-1)) for j, val := range line[1:] { lheight := int((val / maxVal) * float64(height-1))