From d2533da9cf54ec92c051e178b1c043c1b9c45381 Mon Sep 17 00:00:00 2001 From: Jakub Sobon Date: Sat, 16 Feb 2019 01:12:08 -0500 Subject: [PATCH] Make the Y axis adaptive when custom scale is provided. --- widgets/linechart/linechart_test.go | 1 - widgets/linechart/options.go | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/widgets/linechart/linechart_test.go b/widgets/linechart/linechart_test.go index 6d3e2781..305fbc2c 100644 --- a/widgets/linechart/linechart_test.go +++ b/widgets/linechart/linechart_test.go @@ -371,7 +371,6 @@ func TestLineChartDraws(t *testing.T) { desc: "custom Y scale, negative only, values fit", opts: []Option{ YAxisCustomScale(-200, -100), - YAxisAdaptive(), }, canvas: image.Rect(0, 0, 20, 10), writes: func(lc *LineChart) error { diff --git a/widgets/linechart/options.go b/widgets/linechart/options.go index 7f23c06b..f631bbe2 100644 --- a/widgets/linechart/options.go +++ b/widgets/linechart/options.go @@ -140,12 +140,15 @@ type customScale struct { // i.e. smaller than the minimum or larger than the maximum. // Both the minimum and the maximum must be valid numbers and the minimum must // be smaller than the maximum. +// +// Providing this option also sets YAxisAdaptive. func YAxisCustomScale(min, max float64) Option { return option(func(opts *options) { opts.yAxisCustomScale = &customScale{ min: min, max: max, } + opts.yAxisMode = axes.YScaleModeAdaptive }) }