showStatsDialog displays column statistics as a centered modal dialog
(statsS statsSummary, columnName string, colType int)
| 1030 | |
| 1031 | // showStatsDialog displays column statistics as a centered modal dialog |
| 1032 | func showStatsDialog(statsS statsSummary, columnName string, colType int) { |
| 1033 | // Create stats table |
| 1034 | statsTable := tview.NewTable() |
| 1035 | statsTable.SetSelectable(true, true) |
| 1036 | statsTable.SetBorders(false) |
| 1037 | statsTable.Select(0, 0) |
| 1038 | |
| 1039 | // Draw statistics |
| 1040 | drawStats(statsS, statsTable) |
| 1041 | |
| 1042 | // Create border with title and modern styling |
| 1043 | statsTable.SetBorder(true) |
| 1044 | statsTable.SetBorderColor(tcell.NewRGBColor(100, 200, 255)) |
| 1045 | |
| 1046 | typeName := type2name(colType) |
| 1047 | title := fmt.Sprintf(" 📊 Statistics: %s [%s] ", columnName, typeName) |
| 1048 | |
| 1049 | // Add filter indicator if data is filtered |
| 1050 | if isFiltered && len(activeFilters) > 0 { |
| 1051 | title = fmt.Sprintf(" 📊 Statistics: %s [%s] (Filtered Data - %d filters active) ", columnName, typeName, len(activeFilters)) |
| 1052 | } |
| 1053 | |
| 1054 | statsTable.SetTitle(title) |
| 1055 | statsTable.SetTitleAlign(tview.AlignCenter) |
| 1056 | |
| 1057 | // Create plot view |
| 1058 | plotView := tview.NewTextView(). |
| 1059 | SetDynamicColors(true). |
| 1060 | SetText(statsS.getPlot()). |
| 1061 | SetTextAlign(tview.AlignLeft) |
| 1062 | plotView.SetBorder(true) |
| 1063 | plotView.SetTitle(" 📈 Visual Distribution ") |
| 1064 | plotView.SetTitleAlign(tview.AlignCenter) |
| 1065 | plotView.SetBorderColor(tcell.NewRGBColor(255, 150, 50)) |
| 1066 | |
| 1067 | // Create a flex layout with stats on left and plot on right |
| 1068 | statsContent := tview.NewFlex(). |
| 1069 | SetDirection(tview.FlexColumn). |
| 1070 | AddItem(statsTable, 0, 1, true). |
| 1071 | AddItem(plotView, 0, 1, false) |
| 1072 | |
| 1073 | // Handle key events |
| 1074 | statsContent.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { |
| 1075 | // Escape or q - close dialog |
| 1076 | if event.Key() == tcell.KeyEscape || (event.Key() == tcell.KeyRune && event.Rune() == 'q') { |
| 1077 | UI.RemovePage("statsDialog") |
| 1078 | app.SetFocus(bufferTable) |
| 1079 | return nil |
| 1080 | } |
| 1081 | |
| 1082 | // gg - go to top |
| 1083 | if event.Key() == tcell.KeyRune && event.Rune() == 'g' { |
| 1084 | if lastKeyWasG { |
| 1085 | _, column := statsTable.GetSelection() |
| 1086 | statsTable.Select(0, column) |
| 1087 | statsTable.ScrollToBeginning() |
| 1088 | lastKeyWasG = false |
| 1089 | return nil |