Skip to content

Card#

Card #

Card(
    *,
    content: Union[LayoutItem, List[LayoutItem]],
    header: Optional[
        Union[TemplatedStringItem, CardHeader]
    ] = None
)

Groups content with widgets, grids, and selectable sections.

The Card class is a fundamental component in a dashboard layout, allowing users to group and organize content. It provides a container for various layout items such as widgets, cards, grids, and selectable sections.

Constructor for Card.

Parameters:

Name Type Description Default
content Union[LayoutItem, List[LayoutItem]]

content within the Card. One of Widget, Card, Grid, SelectableSection.

required
header Optional[Union[TemplatedStringItem, CardHeader]]

Header card spec. Defaults to None, i.e. a card without title.

None

Examples:#

Create a Card layout and add a widget
import pandas as pd
from engineai.sdk.dashboard.dashboard import Dashboard
from engineai.sdk.dashboard.layout import Card
from engineai.sdk.dashboard.widgets import maps

data = pd.DataFrame(
    data=[{"region": "PT", "value": 10}, {"region": "GB", "value": 100}]
)

Dashboard(
    app_slug="engineai-docs-steps",
    workspace_slug="engineai-docs-steps",
    content=Card(content=maps.Geo(data=data)),
)
Create a Card layout with multiple Widgets
import pandas as pd
from engineai.sdk.dashboard.dashboard import Dashboard
from engineai.sdk.dashboard.layout import Card
from engineai.sdk.dashboard.widgets import maps

data = pd.DataFrame(
    data=[{"region": "PT", "value": 10}, {"region": "GB", "value": 100}]
)

Dashboard(
    app_slug="engineai-docs-steps",
    workspace_slug="engineai-docs-steps",
    content=Card(content=[maps.Geo(data=data), maps.Geo(data=data)]),
)

CardHeader #

CardHeader(
    *chips: CardChip,
    title: Optional[TemplatedStringItem] = None
)

Provides card title and chips for additional information.

The CardHeader class represents the header of a card, providing additional information such as title and chips.

Constructor for CardHeader.

Parameters:

Name Type Description Default
chips CardChip

chips to be added to the card header.

()
title Optional[TemplatedStringItem]

Card title.

None

Examples:#

Create a Card layout with a title
import pandas as pd
from engineai.sdk.dashboard import layout
from engineai.sdk.dashboard.dashboard import Dashboard
from engineai.sdk.dashboard.widgets import pie

data = pd.DataFrame(
    {
        "category": ["A", "B"],
        "value": [1, 2],
    },
)

Dashboard(
    app_slug="engineai-docs-steps",
    workspace_slug="engineai-docs-steps",
    content=layout.Card(
        content=pie.Pie(data=data), header=layout.CardHeader(title="Header Title")
    ),
)

CardChip #

CardChip(
    *,
    label: Union[str, GenericLink],
    tooltip_text: Optional[
        List[TemplatedStringItem]
    ] = None,
    prefix: str = "",
    suffix: str = ""
)

Labels or links within a card header for additional context.

The CardChip class represents individual chips within a card header, providing additional labels or links.

Constructor for CardChip.

Parameters:

Name Type Description Default
label Union[str, GenericLink]

Card Header label value. Can assume a static label or a single GenericLink.

required
tooltip_text Optional[List[TemplatedStringItem]]

informational pop up text. Each element of list is displayed as a separate paragraph. Can only use this option if the label is set.

None
prefix str

prefix value to use in before each label.

''
suffix str

suffix value to use in after each label.

''

Examples:#

Create a Card with multiple chips.
# Using a Chip with a static label and a Chip with a Toggle widget.
import pandas as pd
from engineai.sdk.dashboard import layout
from engineai.sdk.dashboard.dashboard import Dashboard
from engineai.sdk.dashboard.widgets import maps
from engineai.sdk.dashboard.widgets import toggle

data = pd.DataFrame(
    data=[{"id": 1, "label": "Option 1"}, {"id": 2, "label": "Option 2"}]
)
toggle_widget = toggle.Toggle(data=data)

chip = layout.CardChip(label="Chip 1")
linked_chip = layout.CardChip(label=toggle_widget.selected.label)

map_data = pd.DataFrame(
    data=[{"region": "PT", "value": 10}, {"region": "GB", "value": 100}]
)
Dashboard(
    app_slug="engineai-docs-steps",
    workspace_slug="engineai-docs-steps",
    content=[
        toggle_widget,
        layout.Card(
            content=maps.Geo(data=map_data), header=layout.CardHeader(chip, linked_chip)
        ),
    ],
)