File size: 1,833 Bytes
f4a4f34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62fd708
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f4a4f34
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""This module implements the table component for the AI Dashboard."""

from typing import Any
import logging

from dash import dash_table

from ..base import BaseTablePlugin

logger = logging.getLogger(__name__)


class SampleTablePlugin(BaseTablePlugin):
    """A sample table plugin for the AI Dashboard."""

    name = "Sample Table"

    def controls(self) -> None:
        """Generate plot controls."""
        logger.debug("Generating controls for SampleTablePlugin.")

    def render(self, **kwargs: Any) -> Any:
        """Render the table component."""

        return dash_table.DataTable(  # type: ignore
            id="sample-table",
            columns=[
                {
                    "name": col,
                    "id": col,
                    "hideable": True,
                    "deletable": False,
                    "renamable": False,
                }
                for col in self.dataframe.columns
            ],
            data=self.dataframe.to_dict("records"),
            page_size=len(self.dataframe),
            page_action="native",
            filter_action="native",
            row_selectable=None,
            column_selectable="multi",
            editable=False,
            fixed_rows={"headers": True},
            style_table={"overflowY": "auto", "overflowX": "auto", "height": "500px"},
            style_cell={
                "textAlign": "center",
                "padding": "6px",
                "border": "1px solid #ccc",
                "fontFamily": "Times New Roman, Times, serif",
            },
            style_header={"backgroundColor": "#f0f0f0", "fontWeight": "bold"},
        )

    def register_callbacks(self, app: Any) -> None:
        """Register callbacks for the table plugin."""
        logger.debug("Registering callbacks for SampleTablePlugin.")