Spaces:
Sleeping
Sleeping
Commit ·
f4a4f34
1
Parent(s): 0eff045
Add table plot
Browse files
src/ai_dashboard/table_plugin/table_sample.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""This module implements the table component for the AI Dashboard."""
|
| 2 |
+
|
| 3 |
+
from typing import Any
|
| 4 |
+
import logging
|
| 5 |
+
|
| 6 |
+
from dash import dash_table
|
| 7 |
+
|
| 8 |
+
from ..base import BaseTablePlugin
|
| 9 |
+
|
| 10 |
+
logger = logging.getLogger(__name__)
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class SampleTablePlugin(BaseTablePlugin):
|
| 14 |
+
"""A sample table plugin for the AI Dashboard."""
|
| 15 |
+
|
| 16 |
+
name = "Sample Table"
|
| 17 |
+
|
| 18 |
+
def controls(self) -> None:
|
| 19 |
+
"""Generate plot controls."""
|
| 20 |
+
logger.debug("Generating controls for SampleTablePlugin.")
|
| 21 |
+
|
| 22 |
+
def render(self, **kwargs: Any) -> Any:
|
| 23 |
+
"""Render the table component."""
|
| 24 |
+
|
| 25 |
+
return dash_table.DataTable( # type: ignore
|
| 26 |
+
id="sample-table",
|
| 27 |
+
columns=[{"name": col, "id": col} for col in self.dataframe.columns],
|
| 28 |
+
data=self.dataframe.head(10).to_dict("records"),
|
| 29 |
+
page_size=10,
|
| 30 |
+
style_table={"overflowX": "auto"},
|
| 31 |
+
style_cell={
|
| 32 |
+
"textAlign": "center",
|
| 33 |
+
"padding": "6px",
|
| 34 |
+
"border": "1px solid #ccc",
|
| 35 |
+
"fontFamily": "Times New Roman, Times, serif",
|
| 36 |
+
},
|
| 37 |
+
style_header={"backgroundColor": "#f0f0f0", "fontWeight": "bold"},
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
def register_callbacks(self, app: Any) -> None:
|
| 41 |
+
"""Register callbacks for the table plugin."""
|
| 42 |
+
logger.debug("Registering callbacks for SampleTablePlugin.")
|