Skip to main content

A custom Streamlit component for analytics cards

Project description

streamlit-analytics-cards

A project to create custom Streamlit components using React and TypeScript for analytics and insights.

View a demo: 💾 View it on PyPI: 👾

Using the component

Prerequisites

Installation

pip install streamlit-analytics-cards
or
python3 -m pip install streamlit-analytics-cards

Implementation

from streamlit_analytics_cards import card as stac
# Render the component in your Streamlit app
stac(
            template="CardOne",
            title="Attrition Diversity",
            subtitle="Female Attrition",
            main_value="4.7%",
            secondary_value="52",
            delta="Y/Y 5.1%, -0.4%",
            chart_data=df["Number of Exits"].tolist(),
            x_axis_label=df.columns[0],
            color_scheme={"background": "#FFFFFF", "text": "#000000"},
            key="card_1",
        )

For developers

Prerequisites

Before you start, ensure you have the following installed on your system:


Installation

  1. Clone the repository:

    git clone https://github.com/natxc/streamlit-analytics-cards.git
    cd streamlit-analytics-cards
    
  2. Set up the Python environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    pip install -r requirements.txt
    
  3. Install frontend dependencies: Navigate to the frontend/ folder and install the required Node.js packages:

    cd frontend
    npm install
    

Development

Run the Frontend

Start the development server for the React app:

npm start

This will start a local development server at http://localhost:3000.


Run the Streamlit

In the root directory, start the Streamlit app:

streamlit run streamlit_app/app.py

Production Build

  1. Build the Frontend: Navigate to the frontend/ folder and run:

    npm run build
    

    This will create a production-ready build in the frontend/build directory.

  2. Run Streamlit in Production Mode: Ensure _RELEASE is set to True in the __init__.py file:

    _RELEASE = True
    

    Then start the Streamlit app:

    streamlit run streamlit_app/app.py
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_analytics_cards-0.0.2.tar.gz (562.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_analytics_cards-0.0.2-py3-none-any.whl (566.9 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_analytics_cards-0.0.2.tar.gz.

File metadata

File hashes

Hashes for streamlit_analytics_cards-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8fa0bb3cf9b8b1345ddb5e5de7b53f5c824724ff57522b91b746ebadd057bc09
MD5 3bb2d60df3de4f204fb7d6271948f907
BLAKE2b-256 1ee594db51418bfddfe31bf5f232baef252aaa6d8b87ba36d915ef1241757b6d

See more details on using hashes here.

File details

Details for the file streamlit_analytics_cards-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_analytics_cards-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8d9b90d08a9df9834b9f3664cc21f6eca76a821481db4c40b4c29d1419d2ef7b
MD5 9d1dd02eee7231441eb62fe14e0b75be
BLAKE2b-256 100e48d99118f3362229cc7cff5ba2d9e71329e409c80242785296e823dd9dee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page