Files
lightweight-charts-python/docs/source/reference/tables.md
louisnw f72baf95ba Polygon:
- Added async methods to polygon.
- The `requests` library is no longer required, with `urllib` being used instead.
- Added the `get_bar_data` function, which returns a dataframe of aggregate data from polygon.
- Opened up the `subscribe` and `unsubscribe` functions

Enhancements:
- Tables will now scroll when the rows exceed table height.

Bugs:
- Fixed a bug preventing async functions being used with horizontal line event.
- Fixed a bug causing the legend to show duplicate lines if the line was created after the legend.
- Fixed a bug causing the line hide icon to persist within the legend after deletion (#75)
- Fixed a bug causing the search box to be unfocused when the chart is loaded.
2023-08-27 00:20:05 +01:00

2.5 KiB

Table


Tables are panes that can be used to gain further functionality from charts. They are intended to be used for watchlists, order management, or position management. It should be accessed from the `create_table` common method.

The `Table` and `Row` objects act as dictionaries, and can be manipulated as such.

`width`/`height`
: Either given as a percentage (a `float` between 0 and 1) or as an integer representing pixel size.

`widths`
: Given as a `float` between 0 and 1.

`position`
: Used as you would with [`create_subchart`](#AbstractChart.create_subchart), representing how the table will float within the window.

`draggable`
: If `True`, then the window can be dragged to any position within the window.

`func`
: If given, this will be called when a row is clicked, returning the `Row` object in question.
___



````{py:method} new_row(*values, id: int) -> Row

Creates a new row within the table, and returns a `Row` object.

if `id` is passed it should be unique to all other rows. Otherwise, the `id` will be randomly generated.

Rows can be passed a string (header) item or a tuple to set multiple headings:

```python
row['Symbol'] = 'AAPL'
row['Symbol', 'Action'] = 'AAPL', 'BUY'
```

````
___



```{py:method} clear()

Clears and deletes all table rows.
```
___



````{py:method} format(column: str, format_str: str)

Sets the format to be used for the given column. `Table.VALUE` should be used as a placeholder for the cell value. For example:

```python
table.format('Daily %', f'{table.VALUE} %')
table.format('PL', f'$ {table.VALUE}')
```

````
___



```{py:method} visible(visible: bool)

Sets the visibility of the Table.

```


```{py:method} background_color(column: str, color: COLOR)

Sets the background color of the row cell.
```
___



```{py:method} text_color(column: str, color: COLOR)

Sets the foreground color of the row cell.
```
___



```{py:method} delete()

Deletes the row.
```

Tables can also have a footer containing a number of text boxes. To initialize this, call the `footer` attribute with the number of textboxes to be used:

```python
table.footer(3)  # Footer will be displayed, with 3 text boxes.
```
To edit the textboxes, treat `footer` as a list:

```python
table.footer[0] = 'Text Box 1'
table.footer[1] = 'Text Box 2'
table.footer[2] = 'Text Box 3'
```