buildChart builds a gui object of type: Chart
(b *Builder, am map[string]interface{})
| 629 | |
| 630 | // buildChart builds a gui object of type: Chart |
| 631 | func buildChart(b *Builder, am map[string]interface{}) (IPanel, error) { |
| 632 | |
| 633 | // Builds window and sets its common attributes |
| 634 | chart := NewChart(0, 0) |
| 635 | err := b.SetAttribs(am, chart) |
| 636 | if err != nil { |
| 637 | return nil, err |
| 638 | } |
| 639 | |
| 640 | // Sets optional title |
| 641 | if title := am[AttribTitle]; title != nil { |
| 642 | chart.SetTitle(title.(string), 14) |
| 643 | } |
| 644 | |
| 645 | // Sets x scale attibutes |
| 646 | if v := am[AttribScalex]; v != nil { |
| 647 | sx := v.(map[string]interface{}) |
| 648 | // Sets optional x scale margin |
| 649 | if mx := sx[AttribMargin]; mx != nil { |
| 650 | chart.SetMarginX(mx.(float32)) |
| 651 | } |
| 652 | // Sets optional x scale format |
| 653 | if fx := sx[AttribFormat]; fx != nil { |
| 654 | chart.SetFormatX(fx.(string)) |
| 655 | } |
| 656 | // Sets optional x scale font size |
| 657 | if fsize := sx[AttribFontSize]; fsize != nil { |
| 658 | chart.SetFontSizeX(float64(fsize.(float32))) |
| 659 | } |
| 660 | // Number of lines |
| 661 | lines := 4 |
| 662 | if v := sx[AttribLines]; v != nil { |
| 663 | lines = v.(int) |
| 664 | } |
| 665 | // Lines color |
| 666 | color4 := math32.NewColor4("Black") |
| 667 | if v := sx[AttribColor]; v != nil { |
| 668 | color4 = v.(*math32.Color4) |
| 669 | } |
| 670 | color := color4.ToColor() |
| 671 | chart.SetScaleX(lines, &color) |
| 672 | // Range first |
| 673 | firstX := float32(0) |
| 674 | if v := sx[AttribFirstx]; v != nil { |
| 675 | firstX = v.(float32) |
| 676 | } |
| 677 | // Range step |
| 678 | stepX := float32(1) |
| 679 | if v := sx[AttribStepx]; v != nil { |
| 680 | stepX = v.(float32) |
| 681 | } |
| 682 | // Range count step |
| 683 | countStepX := float32(1) |
| 684 | if v := sx[AttribStepx]; v != nil { |
| 685 | countStepX = v.(float32) |
| 686 | } |
| 687 | chart.SetRangeX(firstX, stepX, countStepX) |
| 688 | } |
nothing calls this directly
no test coverage detected