Skip to content

Commit

Permalink
chartdraw: Removed unused parameters from GetTicks function
Browse files Browse the repository at this point in the history
  • Loading branch information
jentfoo committed Jan 23, 2025
1 parent 17d5f78 commit 6c0ed07
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions chartdraw/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion chartdraw/logarithmic_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions chartdraw/logarithmic_range_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion chartdraw/tick.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion chartdraw/xaxis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion chartdraw/yaxis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/line_chart-4/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6c0ed07

Please sign in to comment.