Skip to content

Commit e0aeedf

Browse files
committed
Revert change for axis.go
https://github.com/gonum/plot/pull/796/files#r2008341728 Signed-off-by: Eng Zer Jun <[email protected]>
1 parent 9158cf1 commit e0aeedf

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

axis.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -490,14 +490,14 @@ type DefaultTicks struct{}
490490
var _ Ticker = DefaultTicks{}
491491

492492
// Ticks returns Ticks in the specified range.
493-
func (DefaultTicks) Ticks(minTick, maxTick float64) []Tick {
494-
if maxTick <= minTick {
493+
func (DefaultTicks) Ticks(min, max float64) []Tick {
494+
if max <= min {
495495
panic("illegal range")
496496
}
497497

498498
const suggestedTicks = 3
499499

500-
labels, step, q, mag := talbotLinHanrahan(minTick, maxTick, suggestedTicks, withinData, nil, nil, nil)
500+
labels, step, q, mag := talbotLinHanrahan(min, max, suggestedTicks, withinData, nil, nil, nil)
501501
majorDelta := step * math.Pow10(mag)
502502
if q == 0 {
503503
// Simple fall back was chosen, so
@@ -516,7 +516,7 @@ func (DefaultTicks) Ticks(minTick, maxTick float64) []Tick {
516516
if math.Trunc(q) != q {
517517
off += 2
518518
}
519-
prec := min(6, max(off, -mag))
519+
prec := minInt(6, maxInt(off, -mag))
520520
ticks := make([]Tick, len(labels))
521521
for i, v := range labels {
522522
ticks[i] = Tick{Value: v, Label: strconv.FormatFloat(v, fc, prec, 64)}
@@ -539,15 +539,15 @@ func (DefaultTicks) Ticks(minTick, maxTick float64) []Tick {
539539
// Find the first minor tick not greater
540540
// than the lowest data value.
541541
var i float64
542-
for labels[0]+(i-1)*minorDelta > minTick {
542+
for labels[0]+(i-1)*minorDelta > min {
543543
i--
544544
}
545545
// Add ticks at minorDelta intervals when
546546
// they are not within minorDelta/2 of a
547547
// labelled tick.
548548
for {
549549
val := labels[0] + i*minorDelta
550-
if val > maxTick {
550+
if val > max {
551551
break
552552
}
553553
found := false
@@ -565,6 +565,14 @@ func (DefaultTicks) Ticks(minTick, maxTick float64) []Tick {
565565
return ticks
566566
}
567567

568+
func minInt(a, b int) int {
569+
return min(a, b)
570+
}
571+
572+
func maxInt(a, b int) int {
573+
return max(a, b)
574+
}
575+
568576
// LogTicks is suitable for the Tick.Marker field of an Axis,
569577
// it returns tick marks suitable for a log-scale axis.
570578
type LogTicks struct {

0 commit comments

Comments
 (0)