FastTable
Introduction
FastTable
widget in Supervisely allows for displaying and manipulating data of various dataset statistics and processing it on the server side.
The FastTable
widget allows searching, sorting by column and order, and the ability to customize data. It also allows updating table data in real-time through Python code.
😲 The main feature of FastTable
in that all information is processed on the server side and transmitted in the size of the active page of the table to the client, thus making its operation more efficient.
Function signature
Data structure example
Parameters
Parameters | Type | Description |
---|---|---|
|
| Table data |
|
| Table columns |
|
| Columns options |
|
| Project metadata |
|
| Number of the first fixed columns |
|
| Table page size in number of rows |
|
| Index of the column by which sorting works |
|
| Sort order |
|
| Width of table |
|
| ID of the widget |
data
Table data in different formats:
type: Optional[Union[list, pd.DataFrame]]
default value: None
Python
list
with structure:Where:
data_list
- list withrows
Pandas
DataFrame
:Where:
columns
- list of column namesdata
- list withrows
row
- list with values, requireslen(row) == len(columns)
columns
Column names.
💡 If data
in DataFrame
type is passed, specifying columns
will overwrite it in DataFrame
type: Optional[list]
default value: None
columns_options
List of dictionaries with column options. len(columns_options)
must equal len(columns)
to properly add options. If the column has no options, just pass an empty dictionary {}
Each dictionary may contain:
type
- with value of typestr
, determines special column type, depending on which styles will be applied, now supports onlyclass
as special type, you don't need to specify a type for the regular onessubtitle
- with value of typestr
, provide additional clarification, specify units of measurement, offer context, and enhance overall understanding of the datamaxValue
- with value of typeint
, determines the maximum value for the column and activates special bars that visualize how close the value is to the maximum valuepostfix
- with value of typestr
, is substituted after each value to denote dimensionalitytooltip
- with value of typestr
, tooltip with description for a column
type: Optional[list[dict]]
default value: None
project_meta
Project metadata with classes used to apply special styles for columns with type
:class
type: Optional[Union[ProjectMeta, dict]]
default value: None
fixed_columns
Number of the first fixed columns if the table has horizontal scrolling.
💡 Currently supports only 1
or None
as value.
type: Optional[Literal[1]]
default value: None
page_size
Table page size in number of rows
type: int
default value: 10
sort_column_idx
Index of the column by which sorting works.
💡 Cannot be used without sort_order
, if one of parameters is not set - the sorting will follow the original data structure.
type: int
default value: None
sort_order
Sort order.
💡 Cannot be used without sort_column_idx
, if one of parameters is not set - the sorting will follow the original data structure.
type: Optional[Literal["asc", "desc"]]
default value: None
width
Width of table.
type: Optional[str]
default value: auto
widget_id
ID of the widget.
type: str
default value: None
Methods and attributes
Attributes and Methods | Description |
---|---|
| Get or set number of fixed columns (left to right) property. |
| Get or set number project meta property. |
| Get or set table page size property. |
| Read and set table data from JSON format. |
| Read and set table data from |
| Convert table data to JSON format. Full table or active page only. |
| Convert table data to pandas |
| Deselect a table cell. |
| Get selected table row info. |
| Get selected table cell info. |
| Insert new row in table by index. |
| Remove row from table by index. |
| Search source data for |
| Sort table rows by given column ID and/or order direction. |
| Decorator function is handled when table row is clicked. |
| Decorator function is handled when table cell is clicked. |
read_json()
The data
structure must correspond to the dictionary given in the example below 👇
Structure:
columns
- list of column namesdata
- list withrows
row
- list with values, requireslen(row) == len(columns)
columnsOptions
- list of dictionaries in which settings for each column are storedtype
- determines special type of column, depending on which styles will be applied, now supports onlyclass
as special type, you don't need to specify a type for regularsubtitle
- provide additional clarification, specify units of measurement, offer context, and enhance overall understanding of the datamaxValue
- determines the maximum value for the column and activates special bars that visualize how close the value is to the maximum valuepostfix
- is substituted after each value to denote dimensionalitytooltip
- tooltip with description for a column
options
- dict with table optionsfixColumns
- number of first fixed table columns. ℹ️ Currently, only the first column is supportedsort
- dict with applied sorting optionscolumnIndex
- index of thecolumn
, by the values of which the data should be sortedorder
- sort order
pageSize
- how manyrows
will be displayed on the table page
Here is an example of the described structure: json_data_example
This data is under MIT license. Source
An example of a table built from this JSON can be seen on the datasets' page on Dataset Ninja.
Mini App Example
You can find this example in our Github repository:
ui-widgets-demos/tables/006_fast_table/src/main.py
Import libraries
Init API client
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
Prepare data and meta that will be used to create example table
Initialize FastTable
widget
FastTable
widgetCreate app layout
Prepare a layout for app using Card
widget with the content
parameter and place widget that we've just created in the Container
widget.
Create app using layout
Create an app object with layout parameter.
Add functions to control widget from python code
Last updated