@@ -24,10 +24,10 @@ public Task OnLoadAsync(Kernel kernel)
2424
2525 public static void RegisterDataFrame ( )
2626 {
27- Formatter < DataFrame > . Register ( ( df , writer ) =>
27+ Formatter . Register < DataFrame > ( ( df , writer ) =>
2828 {
29- const int MAX = 10000 ;
30- const int SIZE = 10 ;
29+ const int maxRowCount = 10000 ;
30+ const int rowsPerPage = 25 ;
3131
3232 var uniqueId = DateTime . Now . Ticks ;
3333
@@ -37,15 +37,15 @@ public static void RegisterDataFrame()
3737 } ;
3838 header . AddRange ( df . Columns . Select ( c => ( IHtmlContent ) th ( c . Name ) ) ) ;
3939
40- if ( df . Rows . Count > SIZE )
40+ if ( df . Rows . Count > rowsPerPage )
4141 {
42- var maxMessage = df . Rows . Count > MAX ? $ " (showing a max of { MAX } rows)" : string . Empty ;
42+ var maxMessage = df . Rows . Count > maxRowCount ? $ " (showing a max of { maxRowCount } rows)" : string . Empty ;
4343 var title = h3 [ style : "text-align: center;" ] ( $ "DataFrame - { df . Rows . Count } rows { maxMessage } ") ;
4444
4545 // table body
46- var maxRows = Math . Min ( MAX , df . Rows . Count ) ;
46+ var rowCount = Math . Min ( maxRowCount , df . Rows . Count ) ;
4747 var rows = new List < List < IHtmlContent > > ( ) ;
48- for ( var index = 0 ; index < maxRows ; index ++ )
48+ for ( var index = 0 ; index < rowCount ; index ++ )
4949 {
5050 var cells = new List < IHtmlContent >
5151 {
@@ -58,29 +58,29 @@ public static void RegisterDataFrame()
5858 rows . Add ( cells ) ;
5959 }
6060
61- //navigator
61+ //navigator
6262 var footer = new List < IHtmlContent > ( ) ;
6363 BuildHideRowsScript ( uniqueId ) ;
6464
65- var paginateScriptFirst = BuildHideRowsScript ( uniqueId ) + GotoPageIndex ( uniqueId , 0 ) + BuildPageScript ( uniqueId , SIZE ) ;
65+ var paginateScriptFirst = BuildHideRowsScript ( uniqueId ) + GotoPageIndex ( uniqueId , 0 ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
6666 footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptFirst ] ( "⏮" ) ) ;
6767
68- var paginateScriptPrevTen = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , - 10 , ( maxRows - 1 ) / SIZE ) + BuildPageScript ( uniqueId , SIZE ) ;
68+ var paginateScriptPrevTen = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , - 10 , ( rowCount - 1 ) / rowsPerPage ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
6969 footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptPrevTen ] ( "⏪" ) ) ;
7070
71- var paginateScriptPrev = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , - 1 , ( maxRows - 1 ) / SIZE ) + BuildPageScript ( uniqueId , SIZE ) ;
71+ var paginateScriptPrev = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , - 1 , ( rowCount - 1 ) / rowsPerPage ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
7272 footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptPrev ] ( "◀️" ) ) ;
7373
7474 footer . Add ( b [ style : "margin: 2px;" ] ( "Page" ) ) ;
7575 footer . Add ( b [ id : $ "page_{ uniqueId } ", style : "margin: 2px;" ] ( "1" ) ) ;
7676
77- var paginateScriptNext = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , 1 , ( maxRows - 1 ) / SIZE ) + BuildPageScript ( uniqueId , SIZE ) ;
77+ var paginateScriptNext = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , 1 , ( rowCount - 1 ) / rowsPerPage ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
7878 footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptNext ] ( "▶️" ) ) ;
7979
80- var paginateScriptNextTen = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , 10 , ( maxRows - 1 ) / SIZE ) + BuildPageScript ( uniqueId , SIZE ) ;
80+ var paginateScriptNextTen = BuildHideRowsScript ( uniqueId ) + UpdatePageIndex ( uniqueId , 10 , ( rowCount - 1 ) / rowsPerPage ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
8181 footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptNextTen ] ( "⏩" ) ) ;
8282
83- var paginateScriptLast = BuildHideRowsScript ( uniqueId ) + GotoPageIndex ( uniqueId , ( maxRows - 1 ) / SIZE ) + BuildPageScript ( uniqueId , SIZE ) ;
83+ var paginateScriptLast = BuildHideRowsScript ( uniqueId ) + GotoPageIndex ( uniqueId , ( rowCount - 1 ) / rowsPerPage ) + BuildPageScript ( uniqueId , rowsPerPage ) ;
8484 footer . Add ( button [ style : "margin: 2px;" , onclick : paginateScriptLast ] ( "⏭️" ) ) ;
8585
8686 //table
@@ -93,7 +93,7 @@ public static void RegisterDataFrame()
9393 writer . Write ( t ) ;
9494
9595 //show first page
96- writer . Write ( $ "<script>{ BuildPageScript ( uniqueId , SIZE ) } </script>") ;
96+ writer . Write ( $ "<script>{ BuildPageScript ( uniqueId , rowsPerPage ) } </script>") ;
9797 }
9898 else
9999 {
0 commit comments