newVisualizeTab creates all Visualize widgets and returns the tab.
(ctx context.Context)
| 991 | |
| 992 | // newVisualizeTab creates all Visualize widgets and returns the tab. |
| 993 | func newVisualizeTab(ctx context.Context) (*vizWidgets, *tab.Tab, error) { |
| 994 | // ── Radar ──────────────────────────────────────────────────────────────── |
| 995 | rdr, err := radar.New( |
| 996 | radar.SweepSpeed(50.0), |
| 997 | radar.BeamWidth(28.0), |
| 998 | radar.RangeRings(3), |
| 999 | radar.BeamColor(0, 200, 64), |
| 1000 | radar.ContactColor(255, 140, 0), |
| 1001 | radar.ContactChar('◆'), |
| 1002 | radar.Border(linestyle.Round), |
| 1003 | radar.BorderTitle(" RADAR SWEEP "), |
| 1004 | ) |
| 1005 | if err != nil { |
| 1006 | return nil, nil, err |
| 1007 | } |
| 1008 | |
| 1009 | // Seed initial contacts. |
| 1010 | initContacts := []*radar.Contact{ |
| 1011 | {Angle: 42.0, Distance: 0.35, Label: "A1"}, |
| 1012 | {Angle: 158.0, Distance: 0.62, Label: "B2"}, |
| 1013 | {Angle: 270.0, Distance: 0.80, Label: "C3"}, |
| 1014 | } |
| 1015 | if err := rdr.SetContacts(initContacts); err != nil { |
| 1016 | return nil, nil, err |
| 1017 | } |
| 1018 | |
| 1019 | // ── Donut (modal) ──────────────────────────────────────────────────────── |
| 1020 | don2, err := donut.New( |
| 1021 | donut.HolePercent(35), |
| 1022 | donut.CellOpts(cell.FgColor(cell.ColorNumber(75))), |
| 1023 | donut.TextCellOpts(cell.Bold(), cell.FgColor(cell.ColorWhite)), |
| 1024 | donut.Label("System Load"), |
| 1025 | donut.LabelAlign(align.HorizontalCenter), |
| 1026 | ) |
| 1027 | if err != nil { |
| 1028 | return nil, nil, err |
| 1029 | } |
| 1030 | if err := don2.Percent(62, donut.Label("62%")); err != nil { |
| 1031 | return nil, nil, err |
| 1032 | } |
| 1033 | |
| 1034 | // ── LineChart with threshold (modal) ───────────────────────────────────── |
| 1035 | lineW, err := linechart.New( |
| 1036 | linechart.BrailleOnly(), |
| 1037 | linechart.ThresholdLine(0.75, cell.FgColor(cell.ColorNumber(167))), |
| 1038 | linechart.YAxisCustomScale(-1.1, 1.1), |
| 1039 | linechart.AxesCellOpts(cell.FgColor(cell.ColorNumber(240))), |
| 1040 | linechart.YLabelCellOpts(cell.FgColor(cell.ColorNumber(244))), |
| 1041 | linechart.XLabelCellOpts(cell.FgColor(cell.ColorNumber(244))), |
| 1042 | ) |
| 1043 | if err != nil { |
| 1044 | return nil, nil, err |
| 1045 | } |
| 1046 | |
| 1047 | // ── Build Modal with three draggable sub-windows ────────────────────────── |
| 1048 | radarDW := modal.NewDraggableWidget("modal-radar", rdr, 0, 0, 42, 24, nil) |
| 1049 | radarDW.Title = "Radar Sweep" |
| 1050 | radarDW.Border = true |
no test coverage detected