updateLabelsY updates the Y scale labels text and positions
()
| 341 | |
| 342 | // updateLabelsY updates the Y scale labels text and positions |
| 343 | func (ch *Chart) updateLabelsY() { |
| 344 | |
| 345 | if ch.scaleY == nil { |
| 346 | return |
| 347 | } |
| 348 | |
| 349 | th := float32(0) |
| 350 | if ch.title != nil { |
| 351 | th = ch.title.height |
| 352 | } |
| 353 | |
| 354 | nlines := ch.scaleY.lines |
| 355 | vstep := (ch.maxY - ch.minY) / float32(nlines-1) |
| 356 | pstep := (ch.ContentHeight() - th - ch.top - ch.bottom) / float32(nlines-1) |
| 357 | value := ch.minY |
| 358 | for i := 0; i < nlines; i++ { |
| 359 | label := ch.labelsY[i] |
| 360 | label.SetText(fmt.Sprintf(ch.formatY, value)) |
| 361 | px := ch.left - 4 - label.Width() |
| 362 | if px < 0 { |
| 363 | px = 0 |
| 364 | } |
| 365 | py := ch.ContentHeight() - ch.bottom - float32(i)*pstep |
| 366 | label.SetPosition(px, py-label.Height()/2) |
| 367 | value += vstep |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | // calcRangeY calculates the minimum and maximum y values for all graphs |
| 372 | func (ch *Chart) calcRangeY() { |
no test coverage detected