Skip to content

Commit

Permalink
line_chart: fix BounaryGap bug from last commit
Browse files Browse the repository at this point in the history
Last commit disabled the boundary gap when it was small, but it did it at a later point that resulted in just the right side being corrected.
We need to decide if we are disabling the boundary gap for the line before we do the autoDivide action.
  • Loading branch information
jentfoo committed Feb 15, 2024
1 parent f8cb042 commit c8d9d00
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions line_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,19 @@ type LineChartOption struct {
func (l *lineChart) render(result *defaultRenderResult, seriesList SeriesList) (Box, error) {
p := l.p
opt := l.opt
boundaryGap := !isFalse(opt.XAxis.BoundaryGap)

seriesPainter := result.seriesPainter

boundaryGap := !isFalse(opt.XAxis.BoundaryGap)
xDivideCount := len(opt.XAxis.Data)
if !boundaryGap {
xDivideCount--
}
xDivideValues := autoDivide(seriesPainter.Width(), xDivideCount)
if boundaryGap && xDivideCount > 1 && xDivideValues[1]-xDivideValues[0] <= 10 {
if boundaryGap && xDivideCount > 1 && seriesPainter.Width()/xDivideCount <= 10 {
// boundary gap would be so small it's visually better to disable the line spacing adjustment and just keep
// the label changes only
boundaryGap = false
}
if !boundaryGap {
xDivideCount--
}
xDivideValues := autoDivide(seriesPainter.Width(), xDivideCount)
xValues := make([]int, len(xDivideValues)-1)
if boundaryGap {
for i := 0; i < len(xDivideValues)-1; i++ {
Expand Down

0 comments on commit c8d9d00

Please sign in to comment.