fixing an issue with forcing the secondary y axis on when there were no series mapped to it.

This commit is contained in:
Will Charczuk 2016-07-17 13:06:07 -07:00
parent ae31a618df
commit 50233991ca
2 changed files with 34 additions and 1 deletions

View file

@ -137,6 +137,8 @@ func (c Chart) getRanges() (xrange, yrange, yrangeAlt Range) {
var miny, maxy float64 = math.MaxFloat64, 0
var minya, maxya float64 = math.MaxFloat64, 0
hasSecondaryAxis := false
// note: a possible future optimization is to not scan the series values if
// all axis are represented by either custom ticks or custom ranges.
for _, s := range c.Series {
@ -160,6 +162,7 @@ func (c Chart) getRanges() (xrange, yrange, yrangeAlt Range) {
minya = math.Min(minya, vy2)
maxya = math.Max(maxya, vy1)
maxya = math.Max(maxya, vy2)
hasSecondaryAxis = true
}
}
} else if vp, isValueProvider := s.(ValueProvider); isValueProvider {
@ -226,7 +229,7 @@ func (c Chart) getRanges() (xrange, yrange, yrangeAlt Range) {
} else if !c.YAxisSecondary.Range.IsZero() {
yrangeAlt.Min = c.YAxisSecondary.Range.Min
yrangeAlt.Max = c.YAxisSecondary.Range.Max
} else {
} else if hasSecondaryAxis {
yrangeAlt.Min = minya
yrangeAlt.Max = maxya
yrangeAlt.Min, yrangeAlt.Max = yrangeAlt.GetRoundedRangeBounds()