Skip to main content
Instantiate a dashboard from an HTML string inside a Python dashboard file. This class can be imported from the squirrels.dashboards or the squirrels module.

Constructor

Creates a HtmlDashboard object.
def __init__(self, content: io.StringIO | str) -> None:

Example

Here’s an example of creating an HTML dashboard with Plotly:
from squirrels.dashboards import HtmlDashboard
from squirrels.arguments import DashboardArgs
import plotly.express as px

async def main(sqrl: DashboardArgs) -> HtmlDashboard:
    # Get dataset
    df = await sqrl.dataset("sales_data")
    
    # Create interactive plotly chart
    fig = px.line(
        df.to_pandas(), 
        x='date', 
        y='revenue',
        title='Sales Revenue Over Time'
    )
    
    # Convert to HTML
    html_content = fig.to_html(include_plotlyjs='cdn')
    
    # Return as HtmlDashboard
    return HtmlDashboard(content=html_content)