(buffer *bytes.Buffer, colWidth int, xAmount int, yAmount int)
| 408 | } |
| 409 | |
| 410 | func (p HeatmapPrinter) renderData(buffer *bytes.Buffer, colWidth int, xAmount int, yAmount int) { |
| 411 | for i, datum := range p.Data { |
| 412 | if p.Boxed { |
| 413 | buffer.WriteString(p.SeparatorStyle.Sprint(p.VerticalSeparator)) |
| 414 | } |
| 415 | for j, f := range datum { |
| 416 | if j == 0 && p.HasHeader { |
| 417 | ct := internal.CenterText(p.Axis.YAxis[i], colWidth) |
| 418 | if len(ct) < colWidth { |
| 419 | ct += strings.Repeat(" ", colWidth-len(ct)) |
| 420 | } |
| 421 | buffer.WriteString(p.AxisStyle.Sprint(ct)) |
| 422 | if p.Grid { |
| 423 | buffer.WriteString(p.SeparatorStyle.Sprint(p.VerticalSeparator)) |
| 424 | } |
| 425 | } |
| 426 | var ct string |
| 427 | if p.OnlyColoredCells { |
| 428 | ct = internal.CenterText(" ", colWidth) |
| 429 | } else { |
| 430 | ct = internal.CenterText(Sprintf("%v", f), colWidth) |
| 431 | } |
| 432 | if len(ct) < colWidth { |
| 433 | if len(Sprintf("%v", f)) == 1 { |
| 434 | ct += strings.Repeat(" ", colWidth-len(ct)) |
| 435 | } else { |
| 436 | ct = strings.Repeat(" ", colWidth-len(ct)) + ct |
| 437 | } |
| 438 | } |
| 439 | if p.EnableRGB { |
| 440 | rgb := p.RGBRange[0].Fade(p.minValue, p.maxValue, f, p.RGBRange[1:]...) |
| 441 | rgbStyle := NewRGBStyle(p.TextRGB, rgb) |
| 442 | if p.EnableComplementaryColor { |
| 443 | complimentary := NewRGB(internal.Complementary(rgb.R, rgb.G, rgb.B)) |
| 444 | rgbStyle = NewRGBStyle(complimentary, rgb) |
| 445 | } |
| 446 | buffer.WriteString(rgbStyle.Sprint(ct)) |
| 447 | } else { |
| 448 | color := getColor(p.minValue, p.maxValue, f, p.Colors...) |
| 449 | fgColor := p.TextColor |
| 450 | if p.EnableComplementaryColor { |
| 451 | fgColor = complementaryColors[color] |
| 452 | } |
| 453 | buffer.WriteString(fgColor.Sprint(color.Sprintf("%s", ct))) |
| 454 | } |
| 455 | if j < xAmount { |
| 456 | if !p.Boxed && p.HasHeader && j == xAmount-1 { |
| 457 | continue |
| 458 | } |
| 459 | if p.Grid { |
| 460 | buffer.WriteString(p.SeparatorStyle.Sprint(p.VerticalSeparator)) |
| 461 | } |
| 462 | } |
| 463 | if p.Boxed && !p.HasHeader && j == xAmount { |
| 464 | buffer.WriteString(p.SeparatorStyle.Sprint(p.VerticalSeparator)) |
| 465 | } |
| 466 | } |
| 467 |
no test coverage detected