Skip to content

Commit

Permalink
running golangci-lint
Browse files Browse the repository at this point in the history
Signed-off-by: Navid Yaghoobi <[email protected]>
  • Loading branch information
navidys committed Oct 13, 2024
1 parent 7189140 commit 3cfbbb4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions plot.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,12 @@ func (plot *Plot) SetYAxisLabelDataType(dataType PlotYAxisLabelDataType) {
plot.yAxisLabelDataType = dataType
}

// SetYAxisAutoScaleMin enables YAxis min value autoscale.
func (plot *Plot) SetYAxisAutoScaleMin(autoScale bool) {
plot.yAxisAutoScaleMin = autoScale
}

// SetYAxisAutoScaleMax enables YAxix max value autoscale.
func (plot *Plot) SetYAxisAutoScaleMax(autoScale bool) {
plot.yAxisAutoScaleMax = autoScale
}
Expand Down Expand Up @@ -172,9 +174,11 @@ func (plot *Plot) SetData(data [][]float64) {

plot.brailleCellMap = make(map[image.Point]brailleCell)
plot.data = data

if plot.yAxisAutoScaleMax {
plot.maxVal = getMaxFloat64From2dSlice(data)
}

if plot.yAxisAutoScaleMin {
plot.minVal = getMinFloat64From2dSlice(data)
}
Expand Down Expand Up @@ -315,7 +319,7 @@ func (plot *Plot) drawYAxisLabelToScreen(screen tcell.Screen, plotYAxisLabelsWid
}
}

//nolint:cyclop
//nolint:cyclop,gocognit
func (plot *Plot) drawDotMarkerToScreen(screen tcell.Screen) {
x, y, width, height := plot.GetPlotRect()
chartData := plot.getData()
Expand Down Expand Up @@ -387,10 +391,12 @@ func calcDataPointHeightIfInBounds(val float64, maxVal float64, minVal float64,
if math.IsNaN(val) {
return 0, false
}

result := calcDataPointHeight(val, maxVal, minVal, height)
if (val > maxVal) || (val < minVal) || (result > height) {
return result, false
}

return result, true
}

Expand All @@ -405,13 +411,16 @@ func (plot *Plot) calcBrailleLines() {

previousHeight := 0
lastValWasOk := false

for j, val := range line {
lheight, currentValIsOk := calcDataPointHeightIfInBounds(val, plot.maxVal, plot.minVal, height)

if !lastValWasOk && !currentValIsOk {
// nothing valid to draw, skip to next data point
continue
} else if !lastValWasOk {
}

if !lastValWasOk { //nolint:gocritic
// current data point is single valid data point, draw it individually
plot.setBraillePoint(
calcBraillePoint(x, j+1, y, height, lheight),
Expand Down Expand Up @@ -449,6 +458,7 @@ func (plot *Plot) setBraillePoint(p image.Point, color tcell.Color) {
if p.X < 0 || p.Y < 0 {
return
}

point := image.Pt(p.X/2, p.Y/4) //nolint:gomnd
plot.brailleCellMap[point] = brailleCell{
plot.brailleCellMap[point].cRune | brailleRune[p.Y%4][p.X%2],
Expand Down

0 comments on commit 3cfbbb4

Please sign in to comment.