@@ -464,6 +464,122 @@ func main() {
464
464
teamLookup .Resize (fyne .NewSize (1200 , 600 ))
465
465
teamLookup .SetFixedSize (true )
466
466
467
+ teamLookupN := apptcpjwt .NewWindow ("Team Lookup V 2.0" )
468
+ teamLookupN .Resize (fyne .NewSize (1000 , 600 ))
469
+ teamLookupN .SetCloseIntercept (func () {
470
+ teamLookupN .Hide ()
471
+ })
472
+ teamLookupNChoice := ""
473
+ teamLookupNDropDown := widget .NewSelect ([]string {"AutoAmps" , "AutoSpeaker" , "AutoLeave" , "TeleopAmps" , "TeleopSpeaker" , "Penalties" , "TechPenalties" }, func (s string ) { teamLookupNChoice = s })
474
+
475
+ teamLookupNAverages := widget .NewLabel ("" )
476
+ teamLookupNMedians := widget .NewLabel ("" )
477
+
478
+ teamLookupNChart := canvas .NewImageFromFile ("graph.png" )
479
+ teamLookupNChart .SetMinSize (fyne .NewSize (1024 , 400 ))
480
+ teamLookupNChart .FillMode = canvas .ImageFillContain
481
+ teamLookupNChart .Resize (fyne .NewSize (1024 , 400 ))
482
+
483
+ teamLookupNSearch := widget .NewEntry ()
484
+ teamLookupNSearch .SetPlaceHolder ("Team Number" ) //lld linker jwt
485
+
486
+ teamLookupNHBox := container .NewHSplit (teamLookupNSearch , teamLookupNDropDown )
487
+ teamLookupNHBox .SetOffset (0.5 )
488
+ previous := ""
489
+ teamLookupNRender := widget .NewButton ("FETCH" , func () {
490
+ datas := map [string ][][]int {
491
+ "AutoAmps" : {},
492
+ "AutoSpeaker" : {},
493
+ "TeleopAmps" : {},
494
+ "TeleopSpeaker" : {},
495
+ }
496
+ if previous != teamLookupNSearch .Text {
497
+ increments := []chart.Tick {}
498
+ for i := 1 ; i < 11 ; i ++ {
499
+ increments = append (increments , chart.Tick {Value : float64 (i ), Label : fmt .Sprintf ("%.2f" , float64 (i ))})
500
+ }
501
+
502
+ for _ , v := range allData {
503
+
504
+ if v .TeamName != teamLookupNSearch .Text || strconv .Itoa (v .TeamNumber ) != teamLookupNSearch .Text {
505
+ continue
506
+ }
507
+ datas ["AutoAmps" ] = append (datas ["AutoAmps" ], []int {v .AutoAmps , v .MatchNumber })
508
+ datas ["AutoSpeaker" ] = append (datas ["AutoSpeaker" ], []int {v .AutoSpeaker , v .MatchNumber })
509
+ datas ["TeleopAmps" ] = append (datas ["TeleopAmps" ], []int {v .TeleopAmps , v .MatchNumber })
510
+ datas ["TeleopSpeaker" ] = append (datas ["TeleopSpeaker" ], []int {v .TeleopSpeaker , v .MatchNumber })
511
+ //could use reflection
512
+ for k , v := range datas {
513
+ sort .Slice (v , func (i , j int ) bool {
514
+ return v [i ][1 ] < v [j ][1 ]
515
+ })
516
+ values := []chart.Value {}
517
+ for _ , val := range v {
518
+ values = append (values , chart.Value {Value : float64 (val [0 ]), Label : fmt .Sprintf ("Match %v (Score: %v)" , val [1 ], val [0 ])})
519
+ }
520
+
521
+ graph := chart.
522
+ BarChart {
523
+ Title : k ,
524
+ Background : chart.Style {
525
+ Padding : chart.Box {
526
+ Top : 40 ,
527
+ Bottom : 40 ,
528
+ },
529
+ },
530
+ YAxis : chart.YAxis {
531
+ Name : k ,
532
+ Range : & chart.ContinuousRange {Min : 0 , Max : 10 },
533
+ TickStyle : chart.Style {StrokeWidth : 2.0 , StrokeColor : chart .ColorBlack },
534
+ Ticks : increments ,
535
+ },
536
+ Height : 612 ,
537
+ Width : 1024 ,
538
+ Bars : values ,
539
+ }
540
+ bufToWrite , _ := os .Create (fmt .Sprintf ("graphs/%v.png" , k ))
541
+ _ = graph .Render (chart .PNG , bufToWrite )
542
+
543
+ }
544
+ }
545
+ previous = teamLookupNSearch .Text
546
+ }
547
+ exists := false
548
+ for _ , val := range x {
549
+ if teamLookupNSearch .Text == val [2 ] {
550
+ exists = true
551
+ teamLookupNAverages .SetText (fmt .Sprintf ("Averages: %v" , val [headers [teamLookupNChoice ]]))
552
+ }
553
+
554
+ }
555
+ if ! exists {
556
+ dialog .ShowError (errors .New (fmt .Sprintf ("Team '%v' not found" , teamLookupNSearch .Text )), teamLookupN )
557
+ }
558
+ for _ , val := range medians {
559
+ if teamLookupNSearch .Text == val [2 ] {
560
+ teamLookupNMedians .SetText (fmt .Sprintf ("Medians: %v" , val [headers [teamLookupNChoice ]]))
561
+ }
562
+ }
563
+
564
+ //ternary
565
+ //unicode.all
566
+
567
+ fmt .Println (datas )
568
+
569
+ teamLookupNChart .File = "graphs/" + teamLookupNChoice + ".png"
570
+ teamLookupNChart .Refresh ()
571
+
572
+ //if !exists {
573
+ // dialog.ShowError(errors.New(fmt.Sprintf("Team '%v' not found", teamLookupNSearch.Text)), teamLookupN)
574
+ //}
575
+ })
576
+
577
+ teamLookupN .SetContent (container .NewVBox (teamLookupNHBox , teamLookupNRender , teamLookupNChart , teamLookupNAverages , teamLookupNMedians ))
578
+
579
+ teamLookupNShow := widget .NewButtonWithIcon ("Show Team Lookup lld" , theme .AccountIcon (), func () {
580
+ teamLookupN .Show ()
581
+ })
582
+
467
583
matchScheduleShow := apptcpjwt .NewWindow ("Match Schedule" )
468
584
matchScheduleShow .Resize (fyne .NewSize (1200 , 600 ))
469
585
matchScheduleShow .SetFixedSize (true )
@@ -935,7 +1051,7 @@ func main() {
935
1051
medians = generateMedians (tcp )
936
1052
medianTable .Refresh ()
937
1053
averageTable .Refresh ()
938
- }), matchScheduleShowButton , widget .NewButtonWithIcon ("Display Raw" , theme .GridIcon (), func () {
1054
+ }), matchScheduleShowButton , teamLookupNShow , widget .NewButtonWithIcon ("Display Raw" , theme .GridIcon (), func () {
939
1055
settings .Show ()
940
1056
}), widget .NewButtonWithIcon ("Display Averages" , theme .RadioButtonIcon (), func () {
941
1057
averageWindow .Show ()
0 commit comments