From 6c0ed0782af51ec3ba151e2a980e8144ad8dffb0 Mon Sep 17 00:00:00 2001 From: Mike Jensen Date: Wed, 22 Jan 2025 21:07:45 -0700 Subject: [PATCH] chartdraw: Removed unused parameters from `GetTicks` function --- chartdraw/chart.go | 4 ++-- chartdraw/logarithmic_range.go | 2 +- chartdraw/logarithmic_range_test.go | 4 ++-- chartdraw/tick.go | 2 +- chartdraw/xaxis.go | 2 +- chartdraw/yaxis.go | 2 +- examples/line_chart-4/main.go | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/chartdraw/chart.go b/chartdraw/chart.go index 54ef913..37e86c7 100644 --- a/chartdraw/chart.go +++ b/chartdraw/chart.go @@ -108,7 +108,7 @@ func (c Chart) Render(rp RendererProvider, w io.Writer) error { } if c.hasAnnotationSeries() { - canvasBox = c.getAnnotationAdjustedCanvasBox(r, canvasBox, xr, yr, yra, xf, yf, yfa) + canvasBox = c.getAnnotationAdjustedCanvasBox(r, canvasBox, xr, yr, yra) xr, yr, yra = c.setRangeDomains(canvasBox, xr, yr, yra) xt, yt, yta = c.getAxesTicks(r, xr, yr, yra, xf, yf, yfa) } @@ -403,7 +403,7 @@ func (c Chart) hasSecondarySeries() bool { return false } -func (c Chart) getAnnotationAdjustedCanvasBox(r Renderer, canvasBox Box, xr, yr, yra Range, xf, yf, yfa ValueFormatter) Box { +func (c Chart) getAnnotationAdjustedCanvasBox(r Renderer, canvasBox Box, xr, yr, yra Range) Box { annotationSeriesBox := canvasBox.Clone() for seriesIndex, s := range c.Series { if as, isAnnotationSeries := s.(AnnotationSeries); isAnnotationSeries { diff --git a/chartdraw/logarithmic_range.go b/chartdraw/logarithmic_range.go index 162e226..7a16583 100644 --- a/chartdraw/logarithmic_range.go +++ b/chartdraw/logarithmic_range.go @@ -81,7 +81,7 @@ func (r *LogarithmicRange) Translate(value float64) int { } // GetTicks calculates the needed ticks for the axis, in log scale. Only supports Y values > 0. -func (r *LogarithmicRange) GetTicks(render Renderer, defaults Style, vf ValueFormatter) []Tick { +func (r *LogarithmicRange) GetTicks(vf ValueFormatter) []Tick { exponentStart := int64(math.Max(0, math.Floor(math.Log10(r.Min)))) // one below min exponentEnd := int64(math.Max(0, math.Ceil(math.Log10(r.Max)))) // one above max ticks := make([]Tick, 0, exponentEnd-exponentStart+1) diff --git a/chartdraw/logarithmic_range_test.go b/chartdraw/logarithmic_range_test.go index 363b84e..2a3d2be 100644 --- a/chartdraw/logarithmic_range_test.go +++ b/chartdraw/logarithmic_range_test.go @@ -28,7 +28,7 @@ func TestGetTicks(t *testing.T) { r := LogarithmicRange{Domain: 1000} r.Min, r.Max = MinMax(values...) - ticks := r.GetTicks(nil, Style{}, FloatValueFormatter) + ticks := r.GetTicks(FloatValueFormatter) require.Len(t, ticks, 7) assert.InDelta(t, float64(10), ticks[0].Value, 0) assert.InDelta(t, float64(100), ticks[1].Value, 0) @@ -42,7 +42,7 @@ func TestGetTicksFromHigh(t *testing.T) { r := LogarithmicRange{} r.Min, r.Max = MinMax(values...) - ticks := r.GetTicks(nil, Style{}, FloatValueFormatter) + ticks := r.GetTicks(FloatValueFormatter) require.Len(t, ticks, 5) assert.InDelta(t, float64(1000), ticks[0].Value, 0) assert.InDelta(t, float64(10000), ticks[1].Value, 0) diff --git a/chartdraw/tick.go b/chartdraw/tick.go index d525f6b..aca1a7f 100644 --- a/chartdraw/tick.go +++ b/chartdraw/tick.go @@ -8,7 +8,7 @@ import ( // TicksProvider is a type that provides ticks. type TicksProvider interface { - GetTicks(r Renderer, defaults Style, vf ValueFormatter) []Tick + GetTicks(vf ValueFormatter) []Tick } // Tick represents a label on an axis. diff --git a/chartdraw/xaxis.go b/chartdraw/xaxis.go index 1f56b90..2bdc1ee 100644 --- a/chartdraw/xaxis.go +++ b/chartdraw/xaxis.go @@ -68,7 +68,7 @@ func (xa XAxis) GetTicks(r Renderer, ra Range, defaults Style, vf ValueFormatter return xa.Ticks } if tp, isTickProvider := ra.(TicksProvider); isTickProvider { - return tp.GetTicks(r, defaults, vf) + return tp.GetTicks(vf) } tickStyle := xa.Style.InheritFrom(defaults) return GenerateContinuousTicks(r, ra, false, tickStyle, vf) diff --git a/chartdraw/yaxis.go b/chartdraw/yaxis.go index 60c0423..1240d6e 100644 --- a/chartdraw/yaxis.go +++ b/chartdraw/yaxis.go @@ -73,7 +73,7 @@ func (ya YAxis) GetTicks(r Renderer, ra Range, defaults Style, vf ValueFormatter return ya.Ticks } if tp, isTickProvider := ra.(TicksProvider); isTickProvider { - return tp.GetTicks(r, defaults, vf) + return tp.GetTicks(vf) } tickStyle := ya.Style.InheritFrom(defaults) return GenerateContinuousTicks(r, ra, true, tickStyle, vf) diff --git a/examples/line_chart-4/main.go b/examples/line_chart-4/main.go index 139ded9..88604fc 100644 --- a/examples/line_chart-4/main.go +++ b/examples/line_chart-4/main.go @@ -136,7 +136,7 @@ func main() { } func populateData() (values [][]float64, xAxisLabels []string, labels []string, err error) { - for k, _ := range lensDefinitions { + for k := range lensDefinitions { labels = append(labels, k) } sort.Slice(labels, func(i, j int) bool {