PolyMathOrg / DataFrame

DataFrame in Pharo - tabular data structures for data analysis
MIT License
74 stars 29 forks source link

Extract DataFramePresenter into a class that can be reused #248

Open olekscode opened 1 year ago

olekscode commented 1 year ago

To inspect a DataFrame, we create a Spec table:

inspectionItems: aBuilder
    <inspectorPresentationOrder: 0 title: 'DataFrame'>

    | table |
    table := aBuilder newTable.

    table addColumn: (SpIndexTableColumn new
        title: '#';
        sortFunction: #yourself ascending;
        beNotExpandable;
        yourself).

    (self columnNames) doWithIndex: [ :headerName :columnIndex |
        table addColumn: (SpStringTableColumn
            title: headerName
            evaluated: [ :rowWithName | rowWithName at: columnIndex + 1 ]) ].

    table items: self asArrayOfRowsWithName.

    ^ table

It would be nice to extract this table into a separate class DataFramePresenter that could be reused in different applications to display data frames. In future, we could make this presenter cooler by adding more features (filtering, sorting, searching, etc.)