Change ticks to avoid values impacting each other
The recently introduced logic has an incorrect understanding of the `unit` parameter. This would result in too many ticks being outputted, particularly as datasets got larger. This fixes it by re-calculating the tick count using the `unit` param as originally intended.
This commit is contained in:
parent
19173dfd37
commit
c810369730
1 changed files with 3 additions and 2 deletions
|
|
@ -615,7 +615,8 @@ func (p *Painter) TextFit(body string, x, y, width int, textAligns ...string) ch
|
|||
return output
|
||||
}
|
||||
|
||||
func isTick(totalRange int, numTicks int, index int) bool {
|
||||
func isTick(totalRange int, unit int, index int) bool {
|
||||
numTicks := (totalRange / unit) + 1
|
||||
step := float64(totalRange-1) / float64(numTicks-1)
|
||||
for i := int(float64(index) / step); i < numTicks; i++ {
|
||||
value := int((float64(i) * step) + 0.5)
|
||||
|
|
@ -737,7 +738,7 @@ func (p *Painter) MultiText(opt MultiTextOption) *Painter {
|
|||
}
|
||||
} else {
|
||||
if index == len(opt.TextList) - 1 {
|
||||
x = start - box.Width()
|
||||
x = start - box.Width() + 10
|
||||
} else {
|
||||
x = start - box.Width()>>1
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue