Skip to content

Commit

Permalink
Fixed data overflow issue. Closes #16
Browse files Browse the repository at this point in the history
  • Loading branch information
ericm committed Oct 31, 2020
1 parent 94591ee commit e629f34
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion graph/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ func GenerateGraph(chart *api.Chart, width int, height int, chartTheme ChartThem
if chart.Length < width/5 {
chart.Length = width / 3
}
if chart.Length > width {
mod := 2 * (chart.Length / width)
chartTemp := make([]*api.Bar, 0)
for i, bar := range chart.Bars {
if (i+1)%mod == 0 {
chartTemp = append(chartTemp, bar)
}
}
chart.Bars = chartTemp
chart.Length = len(chartTemp)
}
if chart.Change.IsNegative() {
colour = 91
}
Expand Down Expand Up @@ -110,7 +121,8 @@ check:
}
newX := x * spacing
if newX >= width {
newX--
newX = width - 1
last = nil
}
matrix[y][newX] = bar
bar.Y = y
Expand Down

0 comments on commit e629f34

Please sign in to comment.